package com.bonus.canteen.core.cook.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.cook.mapper.CookEvaluaDetailMapper;
import com.bonus.canteen.core.cook.domain.CookEvaluaDetail;
import com.bonus.canteen.core.cook.service.ICookEvaluaDetailService;

/**
 * 订单评价菜品Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class CookEvaluaDetailServiceImpl implements ICookEvaluaDetailService {
    @Autowired
    private CookEvaluaDetailMapper cookEvaluaDetailMapper;

    /**
     * 查询订单评价菜品
     * 
     * @param evaluaDetailId 订单评价菜品主键
     * @return 订单评价菜品
     */
    @Override
    public CookEvaluaDetail selectCookEvaluaDetailByEvaluaDetailId(Long evaluaDetailId) {
        return cookEvaluaDetailMapper.selectCookEvaluaDetailByEvaluaDetailId(evaluaDetailId);
    }

    /**
     * 查询订单评价菜品列表
     * 
     * @param cookEvaluaDetail 订单评价菜品
     * @return 订单评价菜品
     */
    @Override
    public List<CookEvaluaDetail> selectCookEvaluaDetailList(CookEvaluaDetail cookEvaluaDetail) {
        return cookEvaluaDetailMapper.selectCookEvaluaDetailList(cookEvaluaDetail);
    }

    /**
     * 新增订单评价菜品
     * 
     * @param cookEvaluaDetail 订单评价菜品
     * @return 结果
     */
    @Override
    public int insertCookEvaluaDetail(CookEvaluaDetail cookEvaluaDetail) {
        cookEvaluaDetail.setCreateTime(DateUtils.getNowDate());
        try {
            return cookEvaluaDetailMapper.insertCookEvaluaDetail(cookEvaluaDetail);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改订单评价菜品
     * 
     * @param cookEvaluaDetail 订单评价菜品
     * @return 结果
     */
    @Override
    public int updateCookEvaluaDetail(CookEvaluaDetail cookEvaluaDetail) {
        cookEvaluaDetail.setUpdateTime(DateUtils.getNowDate());
        try {
            return cookEvaluaDetailMapper.updateCookEvaluaDetail(cookEvaluaDetail);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

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

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