Ver Fonte

refactor(service): 优化举报内容信息查询逻辑

- 将动态信息查询结果从列表改为单个对象并设置到item中
- 将评论信息查询结果从列表改为单个对象并设置到item中
- 更新VO类中的动态和评论信息字段类型为单一对象
- 保持图片路径拆分逻辑不变但作用于新的单一对象
- 统一变量命名风格提高代码可读性
zjy há 6 dias atrás
pai
commit
d729b96361

+ 2 - 2
alien-entity/src/main/java/shop/alien/entity/second/vo/SecondUserViolationDetailVo.java

@@ -36,10 +36,10 @@ public class SecondUserViolationDetailVo extends SecondUserViolationVo{
 
     // 动态信息
     @ApiModelProperty(value = "动态信息")
-    List<LifeUserDynamics> dynamicsList;
+    LifeUserDynamics dynamicsInfo;
 
     // 评论信息
     @ApiModelProperty(value = "评论信息")
-    List<LifeComment> commentList;
+    LifeComment commentInfo;
 
 }

+ 8 - 6
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserViolationServiceImpl.java

@@ -769,10 +769,11 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
         List<String> videoFileType = Arrays.asList("mp4", "avi", "mov", "wmv", "flv", "mkv");
 
         if ("2".equals(item.getReportContextType())) {
-            LifeUserDynamics dynamicsList = lifeUserDynamicsMapper.selectById(id);
+            LifeUserDynamics dynamicsInfo = lifeUserDynamicsMapper.selectById(id);
+            item.setDynamicsInfo(dynamicsInfo);
             // 将逗号分隔的图片路径拆分成 List<String>
-            if (dynamicsList != null && StringUtils.isNotEmpty(dynamicsList.getImagePath())) {
-                List<String> imagePathList = Arrays.stream(dynamicsList.getImagePath().split(","))
+            if (dynamicsInfo != null && StringUtils.isNotEmpty(dynamicsInfo.getImagePath())) {
+                List<String> imagePathList = Arrays.stream(dynamicsInfo.getImagePath().split(","))
                         .map(String::trim)
                         .filter(StringUtils::isNotEmpty)
                         .collect(Collectors.toList());
@@ -782,10 +783,11 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
 
         if ("3".equals(item.getReportContextType())) {
             // TODO: 处理评论类型
-            LifeComment commentList = lifeCommentMapper.selectById(id);
+            LifeComment commentInfo = lifeCommentMapper.selectById(id);
+            item.setCommentInfo(commentInfo);
             // 将逗号分隔的图片路径拆分成 List<String>
-            if (commentList != null && StringUtils.isNotEmpty(commentList.getImagePath())) {
-                List<String> imagePathList = Arrays.stream(commentList.getImagePath().split(","))
+            if (commentInfo != null && StringUtils.isNotEmpty(commentInfo.getImagePath())) {
+                List<String> imagePathList = Arrays.stream(commentInfo.getImagePath().split(","))
                         .map(String::trim)
                         .filter(StringUtils::isNotEmpty)
                         .collect(Collectors.toList());