package com.bonus.canteen.core.cook.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.cook.mapper.CookRecipeBindDeviceMapper;
import com.bonus.canteen.core.cook.domain.CookRecipeBindDevice;
import com.bonus.canteen.core.cook.service.ICookRecipeBindDeviceService;

/**
 * 设备绑定多档口子Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class CookRecipeBindDeviceServiceImpl implements ICookRecipeBindDeviceService {
    @Autowired
    private CookRecipeBindDeviceMapper cookRecipeBindDeviceMapper;

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

    /**
     * 查询设备绑定多档口子列表
     * 
     * @param cookRecipeBindDevice 设备绑定多档口子
     * @return 设备绑定多档口子
     */
    @Override
    public List<CookRecipeBindDevice> selectCookRecipeBindDeviceList(CookRecipeBindDevice cookRecipeBindDevice) {
        return cookRecipeBindDeviceMapper.selectCookRecipeBindDeviceList(cookRecipeBindDevice);
    }

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

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

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

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