package com.bonus.material.iot.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.material.iot.mapper.IotMachineBindMapper;
import com.bonus.material.iot.domain.IotMachineBind;
import com.bonus.material.iot.service.IIotMachineBindService;

/**
 * 设备类型绑定Service业务层处理
 * 
 * @author xsheng
 * @date 2024-10-16
 */
@Service
public class IotMachineBindServiceImpl implements IIotMachineBindService {
    @Autowired
    private IotMachineBindMapper iotMachineBindMapper;

    /**
     * 查询设备类型绑定
     * 
     * @param id 设备类型绑定主键
     * @return 设备类型绑定
     */
    @Override
    public IotMachineBind selectIotMachineBindById(Long id) {
        return iotMachineBindMapper.selectIotMachineBindById(id);
    }

    /**
     * 查询设备类型绑定列表
     * 
     * @param iotMachineBind 设备类型绑定
     * @return 设备类型绑定
     */
    @Override
    public List<IotMachineBind> selectIotMachineBindList(IotMachineBind iotMachineBind) {
        return iotMachineBindMapper.selectIotMachineBindList(iotMachineBind);
    }

    /**
     * 新增设备类型绑定
     * 
     * @param iotMachineBind 设备类型绑定
     * @return 结果
     */
    @Override
    public int insertIotMachineBind(IotMachineBind iotMachineBind) {
        iotMachineBind.setCreateTime(DateUtils.getNowDate());
        try {
            return iotMachineBindMapper.insertIotMachineBind(iotMachineBind);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改设备类型绑定
     * 
     * @param iotMachineBind 设备类型绑定
     * @return 结果
     */
    @Override
    public int updateIotMachineBind(IotMachineBind iotMachineBind) {
        iotMachineBind.setUpdateTime(DateUtils.getNowDate());
        try {
            return iotMachineBindMapper.updateIotMachineBind(iotMachineBind);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 批量删除设备类型绑定
     * 
     * @param ids 需要删除的设备类型绑定主键
     * @return 结果
     */
    @Override
    public int deleteIotMachineBindByIds(Long[] ids) {
        return iotMachineBindMapper.deleteIotMachineBindByIds(ids);
    }

    /**
     * 删除设备类型绑定信息
     * 
     * @param id 设备类型绑定主键
     * @return 结果
     */
    @Override
    public int deleteIotMachineBindById(Long id) {
        return iotMachineBindMapper.deleteIotMachineBindById(id);
    }
}
