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.MenuEvaluaDetailMapper;
import com.bonus.canteen.core.menu.domain.MenuEvaluaDetail;
import com.bonus.canteen.core.menu.service.IMenuEvaluaDetailService;

/**
 * 订单评价菜品Service业务层处理
 * 
 * @author xsheng
 * @date 2025-04-20
 */
@Service
public class MenuEvaluaDetailServiceImpl implements IMenuEvaluaDetailService {
    @Autowired
    private MenuEvaluaDetailMapper menuEvaluaDetailMapper;

    /**
     * 查询订单评价菜品
     * 
     * @param detailId 订单评价菜品主键
     * @return 订单评价菜品
     */
    @Override
    public MenuEvaluaDetail selectMenuEvaluaDetailById(Long detailId) {
        return menuEvaluaDetailMapper.selectMenuEvaluaDetailById(detailId);
    }

    /**
     * 查询订单评价菜品列表
     * 
     * @param menuEvaluaDetail 订单评价菜品
     * @return 订单评价菜品
     */
    @Override
    public List<MenuEvaluaDetail> selectMenuEvaluaDetailList(MenuEvaluaDetail menuEvaluaDetail) {
        return menuEvaluaDetailMapper.selectMenuEvaluaDetailList(menuEvaluaDetail);
    }

    /**
     * 新增订单评价菜品
     * 
     * @param menuEvaluaDetail 订单评价菜品
     * @return 结果
     */
    @Override
    public int insertMenuEvaluaDetail(MenuEvaluaDetail menuEvaluaDetail) {
        menuEvaluaDetail.setCreateTime(DateUtils.getNowDate());
        try {
            return menuEvaluaDetailMapper.insertMenuEvaluaDetail(menuEvaluaDetail);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述, " + e.getMessage());
        }
    }

    /**
     * 修改订单评价菜品
     * 
     * @param menuEvaluaDetail 订单评价菜品
     * @return 结果
     */
    @Override
    public int updateMenuEvaluaDetail(MenuEvaluaDetail menuEvaluaDetail) {
        menuEvaluaDetail.setUpdateTime(DateUtils.getNowDate());
        try {
            return menuEvaluaDetailMapper.updateMenuEvaluaDetail(menuEvaluaDetail);
        } catch (Exception e) {
            throw new ServiceException("错误信息描述, " + e.getMessage());
        }
    }

    /**
     * 批量删除订单评价菜品
     *
     * @param detailIds 需要删除的订单评价菜品主键
     * @return 结果
     */
    @Override
    public int deleteMenuEvaluaDetailByIds(Long[] detailIds) {
        return menuEvaluaDetailMapper.deleteMenuEvaluaDetailByIds(detailIds);
    }

    /**
     * 删除订单评价菜品信息
     * 
     * @param detailId 订单评价菜品主键
     * @return 结果
     */
    @Override
    public int deleteMenuEvaluaDetailById(Long detailId) {
        return menuEvaluaDetailMapper.deleteMenuEvaluaDetailById(detailId);
    }
}
