| | |
| | | package com.ruoyi.errand.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.errand.constant.DelFlagConstant; |
| | |
| | | import com.ruoyi.errand.mapper.OrderMapper; |
| | | import com.ruoyi.errand.object.dto.app.AddEvaluationDTO; |
| | | import com.ruoyi.errand.service.EvaluationService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Service |
| | | public class EvaluationServiceImpl extends ServiceImpl<EvaluationMapper, Evaluation> implements EvaluationService { |
| | | |
| | | @Autowired |
| | | private OrderMapper orderMapper; |
| | | |
| | | @Override |
| | |
| | | }else { |
| | | throw new ServiceException("评价类型错误"); |
| | | } |
| | | //查看订单是否评价过 |
| | | LambdaQueryWrapper<Evaluation> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(Evaluation::getType, addEvaluationDTO.getType()); |
| | | lambdaQueryWrapper.eq(Evaluation::getOrderId,addEvaluationDTO.getOrderId()); |
| | | Evaluation one = this.getOne(lambdaQueryWrapper); |
| | | if (one!=null){ |
| | | throw new ServiceException("该订单已评价过,请去修改"); |
| | | } |
| | | Evaluation evaluation = new Evaluation(); |
| | | evaluation.setOrderId(addEvaluationDTO.getOrderId()); |
| | | evaluation.setType(addEvaluationDTO.getType()); |
| | |
| | | evaluation.setCreateTime(LocalDateTime.now()); |
| | | this.save(evaluation); |
| | | } |
| | | |
| | | @Override |
| | | public void edit(AddEvaluationDTO addEvaluationDTO) { |
| | | Evaluation evaluation = this.getById(addEvaluationDTO.getEvaluationId()); |
| | | if (evaluation==null){ |
| | | throw new ServiceException("该评价不存在"); |
| | | } |
| | | evaluation.setRating(addEvaluationDTO.getRating()); |
| | | evaluation.setContent(addEvaluationDTO.getContent()); |
| | | evaluation.setUpdateTime(LocalDateTime.now()); |
| | | this.updateById(evaluation); |
| | | } |
| | | } |