package com.bonus.canteen.core.menu.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.menu.mapper.MenuRecipeDetailMapper;
import com.bonus.canteen.core.menu.domain.MenuRecipeDetail;
import com.bonus.canteen.core.menu.service.IMenuRecipeDetailService;

/**
 * 菜品计划详情信息Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-03
 */
@Service
public class MenuRecipeDetailServiceImpl implements IMenuRecipeDetailService {
    @Autowired
    private MenuRecipeDetailMapper menuRecipeDetailMapper;

    /**
     * 查询菜品计划详情信息
     * 
     * @param id 菜品计划详情信息主键
     * @return 菜品计划详情信息
     */
    @Override
    public MenuRecipeDetail selectMenuRecipeDetailById(Long id) {
        return menuRecipeDetailMapper.selectMenuRecipeDetailById(id);
    }

    /**
     * 查询菜品计划详情信息列表
     * 
     * @param menuRecipeDetail 菜品计划详情信息
     * @return 菜品计划详情信息
     */
    @Override
    public List<MenuRecipeDetail> selectMenuRecipeDetailList(MenuRecipeDetail menuRecipeDetail) {
        return menuRecipeDetailMapper.selectMenuRecipeDetailList(menuRecipeDetail);
    }

    /**
     * 新增菜品计划详情信息
     * 
     * @param menuRecipeDetail 菜品计划详情信息
     * @return 结果
     */
    @Override
    public int insertMenuRecipeDetail(MenuRecipeDetail menuRecipeDetail) {
        menuRecipeDetail.setCreateTime(DateUtils.getNowDate());
        try {
            return menuRecipeDetailMapper.insertMenuRecipeDetail(menuRecipeDetail);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改菜品计划详情信息
     * 
     * @param menuRecipeDetail 菜品计划详情信息
     * @return 结果
     */
    @Override
    public int updateMenuRecipeDetail(MenuRecipeDetail menuRecipeDetail) {
        menuRecipeDetail.setUpdateTime(DateUtils.getNowDate());
        try {
            return menuRecipeDetailMapper.updateMenuRecipeDetail(menuRecipeDetail);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

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

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