Преглед изворни кода

bugfix:2440评价关注功能

刘云鑫 пре 3 месеци
родитељ
комит
a70e224952

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/CommonRatingVo.java

@@ -14,6 +14,8 @@ public class CommonRatingVo extends CommonRating {
     private String userImage;
     @ApiModelProperty(name = "userName", value = "用户名")
     private String userName;
+    @ApiModelProperty(name = "phone", value = "用户手机号")
+    private String phone;
     @ApiModelProperty(name = "isLike", value = "是否点赞")
     private Integer isLike;
     @ApiModelProperty(name = "storeName", value = "门店名称")
@@ -34,4 +36,6 @@ public class CommonRatingVo extends CommonRating {
     private Integer isCollect;
     @ApiModelProperty(name = "commentCount", value = "评论数量")
     private Long commentCount;
+    @ApiModelProperty(name = "isFollow", value = "是否关注")
+    private Integer isFollow;
 }

+ 4 - 2
alien-store/src/main/java/shop/alien/store/controller/AiAuditController.java

@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiSort;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -32,6 +33,7 @@ import java.util.Map;
 @RestController
 @RequestMapping("/aiAudit")
 @RequiredArgsConstructor
+@RefreshScope
 public class AiAuditController {
 
     private final RestTemplate restTemplate;
@@ -48,10 +50,10 @@ public class AiAuditController {
     @Value("${third-party-login.base-url:http://192.168.2.250:9100/ai/user-auth-core/api/v1/auth/login}")
     private String loginUrl;
 
-    @Value("${third-party-text-check.base-url:http://192.168.2.250:9100/ai/auto-review/api/v1/trade_relevance/check}")
+    @Value("${third-party-text-check.base-url:http://124.93.18.180:8892/api/v1/moderate}")
     private String aiTextCheckUrl;
 
-    @Value("${third-party-content_compliance-check.base-url:http://192.168.2.250:9100/ai/auto-review/api/v1/content_compliance/check}")
+    @Value("${third-party-content_compliance-check.base-url:http://124.93.18.180:8892/api/v1/moderate}")
     private String aiContentCheckUrl;
 
     @ApiOperation("ai文本审核")

+ 7 - 3
alien-store/src/main/java/shop/alien/store/controller/CommonRatingController.java

@@ -86,12 +86,16 @@ public class CommonRatingController {
     public R getCommentDetail(@RequestParam Integer ratingId, @RequestParam Long userId) {
         log.info("CommonRatingController.getRatingDetail?id={}&userId={}", ratingId, userId);
         if (ratingId == null) {
-            throw new IllegalArgumentException("参数[ratingId]不能为空");
+            return R.fail("参数[ratingId]不能为空");
         }
         if (userId == null) {
-            throw new IllegalArgumentException("参数[userId]不能为空");
+            return R.fail("参数[userId]不能为空");
+        }
+        try {
+            return R.data(commonRatingService.getRatingDetail(ratingId, userId));
+        } catch (IllegalArgumentException e) {
+            return R.fail(e.getMessage());
         }
-        return R.data(commonRatingService.getRatingDetail(ratingId, userId));
     }
 
     /**删除评价

+ 46 - 6
alien-store/src/main/java/shop/alien/store/service/impl/CommonRatingServiceImpl.java

@@ -65,6 +65,7 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
     private final CommonCommentMapper commonCommentMapper;
     private final LifeLikeRecordMapper lifeLikeRecordMapper;
     private final LifeCollectMapper lifeCollectMapper;
+    private final LifeFansMapper lifeFansMapper;
 
 
     public static final List<String> SERVICES_LIST = ImmutableList.of(
@@ -248,11 +249,40 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
         }
         CommonRatingVo commonRatingVo = new CommonRatingVo();
         BeanUtils.copyProperties(commonRating, commonRatingVo);
-        LifeUser lifeUser = lifeUserMapper.selectById(Integer.parseInt(commonRating.getUserId().toString()));
-        // 设置评论用户信息
-        commonRatingVo.setUserImage(lifeUser.getUserImage());
-        commonRatingVo.setUserName(lifeUser.getUserName());
+        LifeUser ratingUser = lifeUserMapper.selectById(Integer.parseInt(commonRating.getUserId().toString()));
+        if (ratingUser == null){
+            throw new IllegalArgumentException("评价用户不存在");
+        }
+        // 设置评价用户信息
+        commonRatingVo.setUserImage(ratingUser.getUserImage());
+        commonRatingVo.setUserName(ratingUser.getUserName());
+        commonRatingVo.setPhone(ratingUser.getUserPhone());
         // 查询当前用户点赞列表(仅评价)
+        setIsLike(ratingId, userId, commonRatingVo);
+        LifeUser loginUser = lifeUserMapper.selectById(userId);
+        if (loginUser == null){
+            throw new IllegalArgumentException("登录用户不存在");
+        }
+        // 查询当前用户关注列表
+        List<LifeFans> lifeFans = lifeFansMapper.selectList(new QueryWrapper<LifeFans>().lambda()
+                .eq(LifeFans::getFollowedId, "user_".concat(ratingUser.getUserPhone()))
+                .eq(LifeFans::getFansId, "user_".concat(loginUser.getUserPhone()))
+                .eq(LifeFans::getFansType, "1")
+                .eq(LifeFans::getDeleteFlag, 0));
+        // 设置是否关注
+        commonRatingVo.setIsFollow(lifeFans.size() > 0 ? 1 : 0);
+        // 根据业务类型处理
+        extractedWithBusinessType(ratingId, userId, commonRatingVo);
+        return commonRatingVo;
+    }
+
+    /**
+     * 设置是否点赞
+     * @param ratingId 评价id
+     * @param userId 用户id
+     * @param commonRatingVo 评价vo
+     */
+    private void setIsLike(Integer ratingId, Long userId, CommonRatingVo commonRatingVo) {
         List<LifeLikeRecord> lifeLikeRecords = lifeLikeRecordMapper.selectList(new QueryWrapper<LifeLikeRecord>().lambda()
                 .eq(LifeLikeRecord::getDianzanId, userId)
                 .eq(LifeLikeRecord::getHuifuId, ratingId)
@@ -263,10 +293,21 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
         } else {
             commonRatingVo.setIsLike(0);
         }
-        // 根据业务类型处理
+    }
+
+    /**
+     * 根据业务类型处理
+     * @param ratingId 评价id
+     * @param userId 用户id
+     * @param commonRatingVo 评价vo
+     */
+    private void extractedWithBusinessType(Integer ratingId, Long userId, CommonRatingVo commonRatingVo) {
         if(commonRatingVo.getBusinessType().equals(RatingBusinessTypeEnum.STORE_RATING.getBusinessType())){
             // 1店铺信息
             StoreInfo storeInfo = storeInfoMapper.selectById(commonRatingVo.getBusinessId());
+            if(storeInfo == null){
+                throw new IllegalArgumentException("店铺不存在");
+            }
             if( null != storeInfo) {
                 commonRatingVo.setStoreName(storeInfo.getStoreName());
                 commonRatingVo.setStoreEvaluate(storeInfo.getStoreEvaluate());
@@ -315,7 +356,6 @@ public class CommonRatingServiceImpl extends ServiceImpl<CommonRatingMapper, Com
             commonRatingVo.setCommentCount(count.get());
             commonRatingVo.setChildCommonComments(commonCommentVos);
         }
-        return commonRatingVo;
     }
 
     private List<CommonCommentVo> getChildCommentsRecursively(Long id, Long userId) {