package com.bonus.canteen.core.device.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.canteen.core.device.mapper.DeviceBindMapper;
import com.bonus.canteen.core.device.domain.DeviceBind;
import com.bonus.canteen.core.device.service.IDeviceBindService;

/**
 * 设备绑定多档口子Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class DeviceBindServiceImpl implements IDeviceBindService {
    @Autowired
    private DeviceBindMapper deviceBindMapper;

    /**
     * 查询设备绑定多档口子
     * 
     * @param id 设备绑定多档口子主键
     * @return 设备绑定多档口子
     */
    @Override
    public DeviceBind selectDeviceBindById(Long id) {
        return deviceBindMapper.selectDeviceBindById(id);
    }

    /**
     * 查询设备绑定多档口子列表
     * 
     * @param deviceBind 设备绑定多档口子
     * @return 设备绑定多档口子
     */
    @Override
    public List<DeviceBind> selectDeviceBindList(DeviceBind deviceBind) {
        return deviceBindMapper.selectDeviceBindList(deviceBind);
    }

    /**
     * 新增设备绑定多档口子
     * 
     * @param deviceBind 设备绑定多档口子
     * @return 结果
     */
    @Override
    public int insertDeviceBind(DeviceBind deviceBind) {
        deviceBind.setCreateTime(DateUtils.getNowDate());
        try {
            return deviceBindMapper.insertDeviceBind(deviceBind);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改设备绑定多档口子
     * 
     * @param deviceBind 设备绑定多档口子
     * @return 结果
     */
    @Override
    public int updateDeviceBind(DeviceBind deviceBind) {
        deviceBind.setUpdateTime(DateUtils.getNowDate());
        try {
            return deviceBindMapper.updateDeviceBind(deviceBind);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除设备绑定多档口子
     * 
     * @param ids 需要删除的设备绑定多档口子主键
     * @return 结果
     */
    @Override
    public int deleteDeviceBindByIds(Long[] ids) {
        return deviceBindMapper.deleteDeviceBindByIds(ids);
    }

    /**
     * 删除设备绑定多档口子信息
     * 
     * @param id 设备绑定多档口子主键
     * @return 结果
     */
    @Override
    public int deleteDeviceBindById(Long id) {
        return deviceBindMapper.deleteDeviceBindById(id);
    }
}
