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

import java.util.Collections;
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.KitchenWasteMealMapper;
import com.bonus.canteen.core.kitchen.domain.KitchenWasteMeal;
import com.bonus.canteen.core.kitchen.service.IKitchenWasteMealService;

/**
 * 厨房餐余浪费Service业务层处理
 * 
 * @author xsheng
 * @date 2025-06-16
 */
@Service
public class KitchenWasteMealServiceImpl implements IKitchenWasteMealService {
    @Autowired
    private KitchenWasteMealMapper kitchenWasteMealMapper;

    /**
     * 查询厨房餐余浪费
     * 
     * @param ledgerId 厨房餐余浪费主键
     * @return 厨房餐余浪费
     */
    @Override
    public KitchenWasteMeal selectKitchenWasteMealByLedgerId(Long ledgerId) {
        return kitchenWasteMealMapper.selectKitchenWasteMealByLedgerId(ledgerId);
    }

    /**
     * 查询厨房餐余浪费列表
     * 
     * @param kitchenWasteMeal 厨房餐余浪费
     * @return 厨房餐余浪费
     */
    @Override
    public List<KitchenWasteMeal> selectKitchenWasteMealList(KitchenWasteMeal kitchenWasteMeal) {
        return kitchenWasteMealMapper.selectKitchenWasteMealList(kitchenWasteMeal);
    }

    /**
     * 新增厨房餐余浪费
     * 
     * @param kitchenWasteMeal 厨房餐余浪费
     * @return 结果
     */
    @Override
    public int insertKitchenWasteMeal(KitchenWasteMeal kitchenWasteMeal) {
        kitchenWasteMeal.setCreateTime(DateUtils.getNowDate());
        try {
            return kitchenWasteMealMapper.insertKitchenWasteMeal(kitchenWasteMeal);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改厨房餐余浪费
     * 
     * @param kitchenWasteMeal 厨房餐余浪费
     * @return 结果
     */
    @Override
    public int updateKitchenWasteMeal(KitchenWasteMeal kitchenWasteMeal) {
        kitchenWasteMeal.setUpdateTime(DateUtils.getNowDate());
        try {
            return kitchenWasteMealMapper.updateKitchenWasteMeal(kitchenWasteMeal);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除厨房餐余浪费
     * 
     * @param ledgerIds 需要删除的厨房餐余浪费主键
     * @return 结果
     */
    @Override
    public int deleteKitchenWasteMealByLedgerIds(Long[] ledgerIds) {
        return kitchenWasteMealMapper.deleteKitchenWasteMealByLedgerIds(ledgerIds);
    }

    /**
     * 删除厨房餐余浪费信息
     * 
     * @param ledgerId 厨房餐余浪费主键
     * @return 结果
     */
    @Override
    public int deleteKitchenWasteMealByLedgerId(Long ledgerId) {
        return kitchenWasteMealMapper.deleteKitchenWasteMealByLedgerId(ledgerId);
    }

    @Override
    public List<KitchenWasteMeal> selectKitchenWasteMealListCount(KitchenWasteMeal kitchenWasteMeal) {
        return kitchenWasteMealMapper.selectKitchenWasteMealListCount(kitchenWasteMeal);
    }
}
