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.MenuRecipeDishesMapper;
import com.bonus.canteen.core.menu.domain.MenuRecipeDishes;
import com.bonus.canteen.core.menu.service.IMenuRecipeDishesService;

/**
 * 菜品计划菜品关联Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-03
 */
@Service
public class MenuRecipeDishesServiceImpl implements IMenuRecipeDishesService {
    @Autowired
    private MenuRecipeDishesMapper menuRecipeDishesMapper;

    /**
     * 查询菜品计划菜品关联
     * 
     * @param id 菜品计划菜品关联主键
     * @return 菜品计划菜品关联
     */
    @Override
    public MenuRecipeDishes selectMenuRecipeDishesById(Long id) {
        return menuRecipeDishesMapper.selectMenuRecipeDishesById(id);
    }

    /**
     * 查询菜品计划菜品关联列表
     * 
     * @param menuRecipeDishes 菜品计划菜品关联
     * @return 菜品计划菜品关联
     */
    @Override
    public List<MenuRecipeDishes> selectMenuRecipeDishesList(MenuRecipeDishes menuRecipeDishes) {
        return menuRecipeDishesMapper.selectMenuRecipeDishesList(menuRecipeDishes);
    }

    /**
     * 新增菜品计划菜品关联
     * 
     * @param menuRecipeDishes 菜品计划菜品关联
     * @return 结果
     */
    @Override
    public int insertMenuRecipeDishes(MenuRecipeDishes menuRecipeDishes) {
        menuRecipeDishes.setCreateTime(DateUtils.getNowDate());
        try {
            return menuRecipeDishesMapper.insertMenuRecipeDishes(menuRecipeDishes);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改菜品计划菜品关联
     * 
     * @param menuRecipeDishes 菜品计划菜品关联
     * @return 结果
     */
    @Override
    public int updateMenuRecipeDishes(MenuRecipeDishes menuRecipeDishes) {
        menuRecipeDishes.setUpdateTime(DateUtils.getNowDate());
        try {
            return menuRecipeDishesMapper.updateMenuRecipeDishes(menuRecipeDishes);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

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

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