package com.bonus.canteen.core.basic.service.impl;

import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.basic.mapper.BasicCanteenEvaluateMapper;
import com.bonus.canteen.core.basic.domain.BasicCanteenEvaluate;
import com.bonus.canteen.core.basic.service.IBasicCanteenEvaluateService;

/**
 * 食堂评价Service业务层处理
 * 
 * @author xsheng
 * @date 2025-05-25
 */
@Service
public class BasicCanteenEvaluateServiceImpl implements IBasicCanteenEvaluateService {
    @Autowired
    private BasicCanteenEvaluateMapper basicCanteenEvaluateMapper;

    /**
     * 查询食堂评价
     * 
     * @param evaluateId 食堂评价主键
     * @return 食堂评价
     */
    @Override
    public BasicCanteenEvaluate selectBasicCanteenEvaluateByEvaluateId(Long evaluateId) {
        return basicCanteenEvaluateMapper.selectBasicCanteenEvaluateByEvaluateId(evaluateId);
    }

    /**
     * 查询食堂评价列表
     * 
     * @param basicCanteenEvaluate 食堂评价
     * @return 食堂评价
     */
    @Override
    public List<BasicCanteenEvaluate> selectBasicCanteenEvaluateList(BasicCanteenEvaluate basicCanteenEvaluate) {
        return basicCanteenEvaluateMapper.selectBasicCanteenEvaluateList(basicCanteenEvaluate);
    }

    /**
     * 新增食堂评价
     * 
     * @param basicCanteenEvaluate 食堂评价
     * @return 结果
     */
    @Override
    public int insertBasicCanteenEvaluate(BasicCanteenEvaluate basicCanteenEvaluate) {
        basicCanteenEvaluate.setCreateTime(DateUtils.getNowDate());
        basicCanteenEvaluate.setCreateBy(SecurityUtils.getUsername());
        basicCanteenEvaluate.setUserId(SecurityUtils.getUserId());
        basicCanteenEvaluate.setEvaluateDate(DateUtils.getNowDate());
        try {
            return basicCanteenEvaluateMapper.insertBasicCanteenEvaluate(basicCanteenEvaluate);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 修改食堂评价
     * 
     * @param basicCanteenEvaluate 食堂评价
     * @return 结果
     */
    @Override
    public int updateBasicCanteenEvaluate(BasicCanteenEvaluate basicCanteenEvaluate) {
        basicCanteenEvaluate.setUpdateTime(DateUtils.getNowDate());
        try {
            return basicCanteenEvaluateMapper.updateBasicCanteenEvaluate(basicCanteenEvaluate);
        } catch (Exception e) {
            throw new ServiceException(e.getMessage());
        }
    }

    /**
     * 批量删除食堂评价
     * 
     * @param evaluateIds 需要删除的食堂评价主键
     * @return 结果
     */
    @Override
    public int deleteBasicCanteenEvaluateByEvaluateIds(Long[] evaluateIds) {
        return basicCanteenEvaluateMapper.deleteBasicCanteenEvaluateByEvaluateIds(evaluateIds);
    }

    /**
     * 删除食堂评价信息
     * 
     * @param evaluateId 食堂评价主键
     * @return 结果
     */
    @Override
    public int deleteBasicCanteenEvaluateByEvaluateId(Long evaluateId) {
        return basicCanteenEvaluateMapper.deleteBasicCanteenEvaluateByEvaluateId(evaluateId);
    }
}
