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.MenuDishesMapper;
import com.bonus.canteen.menu.domain.MenuDishes;
import com.bonus.canteen.menu.service.IMenuDishesService;

/**
 * 菜品信息Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-03
 */
@Service
public class MenuDishesServiceImpl implements IMenuDishesService {
    @Autowired
    private MenuDishesMapper menuDishesMapper;

    /**
     * 查询菜品信息
     * 
     * @param id 菜品信息主键
     * @return 菜品信息
     */
    @Override
    public MenuDishes selectMenuDishesById(Long id) {
        return menuDishesMapper.selectMenuDishesById(id);
    }

    /**
     * 查询菜品信息列表
     * 
     * @param menuDishes 菜品信息
     * @return 菜品信息
     */
    @Override
    public List<MenuDishes> selectMenuDishesList(MenuDishes menuDishes) {
        return menuDishesMapper.selectMenuDishesList(menuDishes);
    }

    /**
     * 新增菜品信息
     * 
     * @param menuDishes 菜品信息
     * @return 结果
     */
    @Override
    public int insertMenuDishes(MenuDishes menuDishes) {
        menuDishes.setCreateTime(DateUtils.getNowDate());
        try {
            return menuDishesMapper.insertMenuDishes(menuDishes);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

    /**
     * 修改菜品信息
     * 
     * @param menuDishes 菜品信息
     * @return 结果
     */
    @Override
    public int updateMenuDishes(MenuDishes menuDishes) {
        menuDishes.setUpdateTime(DateUtils.getNowDate());
        try {
            return menuDishesMapper.updateMenuDishes(menuDishes);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述");
        }
    }

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

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