package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TDeviceSetMapper;
import com.ruoyi.system.domain.TDeviceSet;
import com.ruoyi.system.service.ITDeviceSetService;

/**
 * 设备设置Service业务层处理
 * 
 * @author zhengjie
 * @date 2023-09-20
 */
@Service
public class TDeviceSetServiceImpl implements ITDeviceSetService 
{
    @Autowired
    private TDeviceSetMapper tDeviceSetMapper;

    /**
     * 查询设备设置
     * 
     * @param id 设备设置主键
     * @return 设备设置
     */
    @Override
    public TDeviceSet selectTDeviceSetById(Integer id)
    {
        return tDeviceSetMapper.selectTDeviceSetById(id);
    }


    /**
     * 查询设备设置
     *
     * @param deviceIdCode 设备号
     * @return 设备设置
     */
    @Override
    public TDeviceSet selectTDeviceSetByCode(String deviceIdCode) {
        return tDeviceSetMapper.selectTDeviceSetByCode(deviceIdCode);
    }

    /**
     * 查询设备设置列表
     * 
     * @param tDeviceSet 设备设置
     * @return 设备设置
     */
    @Override
    public List<TDeviceSet> selectTDeviceSetList(TDeviceSet tDeviceSet)
    {
        return tDeviceSetMapper.selectTDeviceSetList(tDeviceSet);
    }

    /**
     * 新增设备设置
     * 
     * @param tDeviceSet 设备设置
     * @return 结果
     */
    @Override
    public int insertTDeviceSet(TDeviceSet tDeviceSet)
    {
        if (StringUtils.isNull(this.selectTDeviceSetByCode(tDeviceSet.getDeviceIdCode()))){
            return tDeviceSetMapper.insertTDeviceSet(tDeviceSet);
        }else{
            return this.updateTDeviceSet(tDeviceSet);
        }
    }

    /**
     * 修改设备设置
     * 
     * @param tDeviceSet 设备设置
     * @return 结果
     */
    @Override
    public int updateTDeviceSet(TDeviceSet tDeviceSet)
    {
        return tDeviceSetMapper.updateTDeviceSet(tDeviceSet);
    }

    /**
     * 批量删除设备设置
     * 
     * @param ids 需要删除的设备设置主键
     * @return 结果
     */
    @Override
    public int deleteTDeviceSetByIds(Integer[] ids)
    {
        return tDeviceSetMapper.deleteTDeviceSetByIds(ids);
    }

    /**
     * 删除设备设置信息
     * 
     * @param id 设备设置主键
     * @return 结果
     */
    @Override
    public int deleteTDeviceSetById(Integer id)
    {
        return tDeviceSetMapper.deleteTDeviceSetById(id);
    }
}
