package com.bonus.canteen.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.menu.mapper.MenuRecipeMapper;
import com.bonus.canteen.menu.domain.MenuRecipe;
import com.bonus.canteen.menu.service.IMenuRecipeService;

/**
 * 菜品计划信息Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-03
 */
@Service
public class MenuRecipeServiceImpl implements IMenuRecipeService {
    @Autowired
    private MenuRecipeMapper menuRecipeMapper;

    /**
     * 查询菜品计划信息
     * 
     * @param id 菜品计划信息主键
     * @return 菜品计划信息
     */
    @Override
    public MenuRecipe selectMenuRecipeById(Long id) {
        return menuRecipeMapper.selectMenuRecipeById(id);
    }

    /**
     * 查询菜品计划信息列表
     * 
     * @param menuRecipe 菜品计划信息
     * @return 菜品计划信息
     */
    @Override
    public List<MenuRecipe> selectMenuRecipeList(MenuRecipe menuRecipe) {
        return menuRecipeMapper.selectMenuRecipeList(menuRecipe);
    }

    /**
     * 新增菜品计划信息
     * 
     * @param menuRecipe 菜品计划信息
     * @return 结果
     */
    @Override
    public int insertMenuRecipe(MenuRecipe menuRecipe) {
        menuRecipe.setCreateTime(DateUtils.getNowDate());
        try {
            return menuRecipeMapper.insertMenuRecipe(menuRecipe);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改菜品计划信息
     * 
     * @param menuRecipe 菜品计划信息
     * @return 结果
     */
    @Override
    public int updateMenuRecipe(MenuRecipe menuRecipe) {
        menuRecipe.setUpdateTime(DateUtils.getNowDate());
        try {
            return menuRecipeMapper.updateMenuRecipe(menuRecipe);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

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

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