|
@@ -0,0 +1,102 @@
|
|
|
+package com.chelvc.cloud.maintain.controller;
|
|
|
+
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.GoodsAssessDto;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.AssessModifyParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.AssessQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.AssessRecoverModifyParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.service.AssessService;
|
|
|
+import com.chelvc.framework.base.annotation.ResponseWrapping;
|
|
|
+import com.chelvc.framework.base.context.SessionContextHolder;
|
|
|
+import com.chelvc.framework.redis.config.RedisConfigurer;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 评价管理
|
|
|
+ * @author valley
|
|
|
+ * @date 2024/01/26 00:08
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Validated
|
|
|
+@RestController
|
|
|
+@ResponseWrapping
|
|
|
+@PreAuthorize("isScope('EMPLOYEE')")
|
|
|
+public class AssessController {
|
|
|
+
|
|
|
+ private static final String DEFAULT_MSG= "亲爱的顾客,感谢您认可我们的服务,我们会努力做的更好,祝您生活愉快!";
|
|
|
+ @Autowired
|
|
|
+ private RedisConfigurer redis;
|
|
|
+ @DubboReference
|
|
|
+ AssessService assessService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return 获取默认评价内容
|
|
|
+ */
|
|
|
+ @GetMapping("/assess/getDefaultMsg")
|
|
|
+ public String getDefaultAssessMsg(){
|
|
|
+ Long userId = SessionContextHolder.getSession().getId();
|
|
|
+ Object obj = redis.redisTemplate().opsForValue().get("assess:defaultAssess " + userId);
|
|
|
+ return obj == null ? DEFAULT_MSG : obj.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param msg 评价内容
|
|
|
+ * 修改默认评价
|
|
|
+ */
|
|
|
+ @PostMapping("/assess/saveDefaultMsg")
|
|
|
+ public void getDefaultAssessMsg(String msg){
|
|
|
+ Long userId = SessionContextHolder.getSession().getId();
|
|
|
+ redis.redisTemplate().opsForValue().set("assess:defaultAssess " + userId, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 针对订单发布评价
|
|
|
+ */
|
|
|
+ @PostMapping("/assess/add")
|
|
|
+ public Long addAssess(@RequestBody AssessModifyParam param){
|
|
|
+ return assessService.add(param);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 评价查询
|
|
|
+ */
|
|
|
+ @GetMapping("/assess/query")
|
|
|
+ public List<GoodsAssessDto> addAssess(@RequestBody AssessQueryParam param){
|
|
|
+ return assessService.query(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 评价回复
|
|
|
+ */
|
|
|
+ @PostMapping("/assess/recover/add")
|
|
|
+ public Long addAssessRecover(@RequestBody AssessRecoverModifyParam param){
|
|
|
+ return assessService.addAssessRecover(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 90天评价所有商品得分计算
|
|
|
+ */
|
|
|
+ @PostMapping("/assess/computeAvgScore")
|
|
|
+ public void addAssessRecover(){
|
|
|
+ assessService.computeAvgScore();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取商品分数,包含总平均分、各周期平均分
|
|
|
+ */
|
|
|
+ @GetMapping("/goodsScore")
|
|
|
+ public Map<String, BigDecimal> getGoodsScore(@Min(value = 0, message = "商品id必须大于0") Long goodsId){
|
|
|
+ return assessService.getGoodsScore(goodsId);
|
|
|
+ }
|
|
|
+}
|