package com.zd.alg.smartlock.service.impl;

import com.zd.alg.smartlock.domain.SlUserRelation;
import com.zd.alg.smartlock.mapper.SlUserRelationMapper;
import com.zd.alg.smartlock.service.ISlUserRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * 人员关联Service业务层处理
 *
 * @author zd
 * @date 2022-09-02
 */
@Service
public class SlUserRelationServiceImpl implements ISlUserRelationService
{
    @Autowired
    private SlUserRelationMapper slUserRelationMapper;

    /**
     * 查询人员关联
     *
     * @param id 人员关联主键
     * @return 人员关联
     */
    @Override
    public SlUserRelation selectSlUserRelationById(Long id)
    {
        return slUserRelationMapper.selectSlUserRelationById(id);
    }

    /**
     * 查询人员关联列表
     *
     * @param slUserRelation 人员关联
     * @return 人员关联
     */
    @Override
    public List<SlUserRelation> selectSlUserRelationList(SlUserRelation slUserRelation)
    {
        return slUserRelationMapper.selectSlUserRelationList(slUserRelation);
    }

    @Override
    public List<SlUserRelation> getListByIds(List<Long> ids){
        if (ids.isEmpty()){
            new ArrayList<>();
        }
        return slUserRelationMapper.getListByIds(ids);
    }

    /**
     * 新增人员关联
     *
     * @param slUserRelation 人员关联
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertSlUserRelation(SlUserRelation slUserRelation)
    {
        return slUserRelationMapper.insertSlUserRelation(slUserRelation);
    }

    /**
     * 修改人员关联
     *
     * @param slUserRelation 人员关联
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateSlUserRelation(SlUserRelation slUserRelation)
    {
        return slUserRelationMapper.updateSlUserRelation(slUserRelation);
    }

    /**
     * 批量删除人员关联
     *
     * @param ids 需要删除的人员关联主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteSlUserRelationByIds(Long[] ids)
    {
        return slUserRelationMapper.deleteSlUserRelationByIds(ids);
    }

    /**
     * 删除人员关联信息
     *
     * @param id 人员关联主键
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteSlUserRelationById(Long id)
    {
        return slUserRelationMapper.deleteSlUserRelationById(id);
    }
}
