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.CookRecipeDetailMapper;
import com.bonus.canteen.core.cook.domain.CookRecipeDetail;
import com.bonus.canteen.core.cook.service.ICookRecipeDetailService;

/**
 * 菜品计划详情信息Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class CookRecipeDetailServiceImpl implements ICookRecipeDetailService {
    @Autowired
    private CookRecipeDetailMapper cookRecipeDetailMapper;

    /**
     * 查询菜品计划详情信息
     * 
     * @param recipeDetailId 菜品计划详情信息主键
     * @return 菜品计划详情信息
     */
    @Override
    public CookRecipeDetail selectCookRecipeDetailByRecipeDetailId(Long recipeDetailId) {
        return cookRecipeDetailMapper.selectCookRecipeDetailByRecipeDetailId(recipeDetailId);
    }

    /**
     * 查询菜品计划详情信息列表
     * 
     * @param cookRecipeDetail 菜品计划详情信息
     * @return 菜品计划详情信息
     */
    @Override
    public List<CookRecipeDetail> selectCookRecipeDetailList(CookRecipeDetail cookRecipeDetail) {
        return cookRecipeDetailMapper.selectCookRecipeDetailList(cookRecipeDetail);
    }

    /**
     * 新增菜品计划详情信息
     * 
     * @param cookRecipeDetail 菜品计划详情信息
     * @return 结果
     */
    @Override
    public int insertCookRecipeDetail(CookRecipeDetail cookRecipeDetail) {
        cookRecipeDetail.setCreateTime(DateUtils.getNowDate());
        try {
            return cookRecipeDetailMapper.insertCookRecipeDetail(cookRecipeDetail);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改菜品计划详情信息
     * 
     * @param cookRecipeDetail 菜品计划详情信息
     * @return 结果
     */
    @Override
    public int updateCookRecipeDetail(CookRecipeDetail cookRecipeDetail) {
        cookRecipeDetail.setUpdateTime(DateUtils.getNowDate());
        try {
            return cookRecipeDetailMapper.updateCookRecipeDetail(cookRecipeDetail);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除菜品计划详情信息
     * 
     * @param recipeDetailIds 需要删除的菜品计划详情信息主键
     * @return 结果
     */
    @Override
    public int deleteCookRecipeDetailByRecipeDetailIds(Long[] recipeDetailIds) {
        return cookRecipeDetailMapper.deleteCookRecipeDetailByRecipeDetailIds(recipeDetailIds);
    }

    /**
     * 删除菜品计划详情信息信息
     * 
     * @param recipeDetailId 菜品计划详情信息主键
     * @return 结果
     */
    @Override
    public int deleteCookRecipeDetailByRecipeDetailId(Long recipeDetailId) {
        return cookRecipeDetailMapper.deleteCookRecipeDetailByRecipeDetailId(recipeDetailId);
    }
}
