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.CookEvaluaOrderMapper;
import com.bonus.canteen.core.cook.domain.CookEvaluaOrder;
import com.bonus.canteen.core.cook.service.ICookEvaluaOrderService;

/**
 * 订单评价Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class CookEvaluaOrderServiceImpl implements ICookEvaluaOrderService {
    @Autowired
    private CookEvaluaOrderMapper cookEvaluaOrderMapper;

    /**
     * 查询订单评价
     * 
     * @param evaluaId 订单评价主键
     * @return 订单评价
     */
    @Override
    public CookEvaluaOrder selectCookEvaluaOrderByEvaluaId(Long evaluaId) {
        return cookEvaluaOrderMapper.selectCookEvaluaOrderByEvaluaId(evaluaId);
    }

    /**
     * 查询订单评价列表
     * 
     * @param cookEvaluaOrder 订单评价
     * @return 订单评价
     */
    @Override
    public List<CookEvaluaOrder> selectCookEvaluaOrderList(CookEvaluaOrder cookEvaluaOrder) {
        return cookEvaluaOrderMapper.selectCookEvaluaOrderList(cookEvaluaOrder);
    }

    /**
     * 新增订单评价
     * 
     * @param cookEvaluaOrder 订单评价
     * @return 结果
     */
    @Override
    public int insertCookEvaluaOrder(CookEvaluaOrder cookEvaluaOrder) {
        cookEvaluaOrder.setCreateTime(DateUtils.getNowDate());
        try {
            return cookEvaluaOrderMapper.insertCookEvaluaOrder(cookEvaluaOrder);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改订单评价
     * 
     * @param cookEvaluaOrder 订单评价
     * @return 结果
     */
    @Override
    public int updateCookEvaluaOrder(CookEvaluaOrder cookEvaluaOrder) {
        cookEvaluaOrder.setUpdateTime(DateUtils.getNowDate());
        try {
            return cookEvaluaOrderMapper.updateCookEvaluaOrder(cookEvaluaOrder);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

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

    /**
     * 删除订单评价信息
     * 
     * @param evaluaId 订单评价主键
     * @return 结果
     */
    @Override
    public int deleteCookEvaluaOrderByEvaluaId(Long evaluaId) {
        return cookEvaluaOrderMapper.deleteCookEvaluaOrderByEvaluaId(evaluaId);
    }
}
