package com.bonus.canteen.core.kitchen.service.impl;

import java.util.List;

import com.bonus.canteen.core.kitchen.dto.KitchenDeviceListDTO;
import com.bonus.canteen.core.kitchen.dto.KitchenDeviceUsageListDTO;
import com.bonus.canteen.core.kitchen.vo.KitchenDeviceUsageListVO;
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.KitchenDeviceUsageMapper;
import com.bonus.canteen.core.kitchen.domain.KitchenDeviceUsage;
import com.bonus.canteen.core.kitchen.service.IKitchenDeviceUsageService;

/**
 * 厨房设备使用记录Service业务层处理
 *
 * @author xsheng
 * @date 2025-06-16
 */
@Service
public class KitchenDeviceUsageServiceImpl implements IKitchenDeviceUsageService {
    @Autowired
    private KitchenDeviceUsageMapper kitchenDeviceUsageMapper;

    /**
     * 查询厨房设备使用记录
     *
     * @param usageId 厨房设备使用记录主键
     * @return 厨房设备使用记录
     */
    @Override
    public KitchenDeviceUsageListVO selectKitchenDeviceUsageByUsageId(Long usageId) {
        return kitchenDeviceUsageMapper.selectKitchenDeviceUsageByUsageId(usageId);
    }

    /**
     * 查询厨房设备使用记录列表
     *
     * @param kitchenDeviceUsage 厨房设备使用记录
     * @return 厨房设备使用记录
     */
    @Override
    public List<KitchenDeviceUsageListVO> selectKitchenDeviceUsageList(KitchenDeviceUsageListDTO kitchenDeviceUsage) {
        return kitchenDeviceUsageMapper.selectKitchenDeviceUsageList(kitchenDeviceUsage);
    }

    /**
     * 新增厨房设备使用记录
     *
     * @param kitchenDeviceUsage 厨房设备使用记录
     * @return 结果
     */
    @Override
    public int insertKitchenDeviceUsage(KitchenDeviceUsage kitchenDeviceUsage) {
        kitchenDeviceUsage.setCreateTime(DateUtils.getNowDate());
        try {
            return kitchenDeviceUsageMapper.insertKitchenDeviceUsage(kitchenDeviceUsage);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改厨房设备使用记录
     *
     * @param kitchenDeviceUsage 厨房设备使用记录
     * @return 结果
     */
    @Override
    public int updateKitchenDeviceUsage(KitchenDeviceUsage kitchenDeviceUsage) {
        kitchenDeviceUsage.setUpdateTime(DateUtils.getNowDate());
        try {
            return kitchenDeviceUsageMapper.updateKitchenDeviceUsage(kitchenDeviceUsage);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除厨房设备使用记录
     *
     * @param usageIds 需要删除的厨房设备使用记录主键
     * @return 结果
     */
    @Override
    public int deleteKitchenDeviceUsageByUsageIds(Long[] usageIds) {
        return kitchenDeviceUsageMapper.deleteKitchenDeviceUsageByUsageIds(usageIds);
    }

    /**
     * 删除厨房设备使用记录信息
     *
     * @param usageId 厨房设备使用记录主键
     * @return 结果
     */
    @Override
    public int deleteKitchenDeviceUsageByUsageId(Long usageId) {
        return kitchenDeviceUsageMapper.deleteKitchenDeviceUsageByUsageId(usageId);
    }
}
