package com.bonus.canteen.core.kitchen.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.kitchen.mapper.KitchenDeviceLifeMapper;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceLife;
import com.bonus.canteen.core.kitchen.service.IKitchenDeviceLifeService;

/**
 * 厨房设备生命周期Service业务层处理
 * 
 * @author xsheng
 * @date 2025-06-16
 */
@Service
public class KitchenDeviceLifeServiceImpl implements IKitchenDeviceLifeService {
    @Autowired
    private KitchenDeviceLifeMapper kitchenDeviceLifeMapper;

    /**
     * 查询厨房设备生命周期
     * 
     * @param id 厨房设备生命周期主键
     * @return 厨房设备生命周期
     */
    @Override
    public KitchenDeviceLife selectKitchenDeviceLifeById(Long id) {
        return kitchenDeviceLifeMapper.selectKitchenDeviceLifeById(id);
    }

    /**
     * 查询厨房设备生命周期列表
     * 
     * @param kitchenDeviceLife 厨房设备生命周期
     * @return 厨房设备生命周期
     */
    @Override
    public List<KitchenDeviceLife> selectKitchenDeviceLifeList(KitchenDeviceLife kitchenDeviceLife) {
        return kitchenDeviceLifeMapper.selectKitchenDeviceLifeList(kitchenDeviceLife);
    }

    /**
     * 新增厨房设备生命周期
     * 
     * @param kitchenDeviceLife 厨房设备生命周期
     * @return 结果
     */
    @Override
    public int insertKitchenDeviceLife(KitchenDeviceLife kitchenDeviceLife) {
        kitchenDeviceLife.setCreateTime(DateUtils.getNowDate());
        try {
            return kitchenDeviceLifeMapper.insertKitchenDeviceLife(kitchenDeviceLife);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改厨房设备生命周期
     * 
     * @param kitchenDeviceLife 厨房设备生命周期
     * @return 结果
     */
    @Override
    public int updateKitchenDeviceLife(KitchenDeviceLife kitchenDeviceLife) {
        kitchenDeviceLife.setUpdateTime(DateUtils.getNowDate());
        try {
            return kitchenDeviceLifeMapper.updateKitchenDeviceLife(kitchenDeviceLife);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除厨房设备生命周期
     * 
     * @param ids 需要删除的厨房设备生命周期主键
     * @return 结果
     */
    @Override
    public int deleteKitchenDeviceLifeByIds(Long[] ids) {
        return kitchenDeviceLifeMapper.deleteKitchenDeviceLifeByIds(ids);
    }

    /**
     * 删除厨房设备生命周期信息
     * 
     * @param id 厨房设备生命周期主键
     * @return 结果
     */
    @Override
    public int deleteKitchenDeviceLifeById(Long id) {
        return kitchenDeviceLifeMapper.deleteKitchenDeviceLifeById(id);
    }
}
