Просмотр исходного кода

Merge branch 'dev' of http://192.168.1.245:11111/jinjilong/onlineEducation-fwd into dev

honorfire 8 месяцев назад
Родитель
Сommit
259c02a226

+ 15 - 1
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/controller/UserCommentController.java

@@ -53,7 +53,7 @@ public class UserCommentController {
     private UserCommentService userCommentService;
 
     /**
-     * 获取user_comment分页
+     * 最新评论list获取
      *
      * @author pans
      * @date  2025/06/27 11:07
@@ -65,6 +65,20 @@ public class UserCommentController {
         return CommonResult.data(userCommentService.page(userCommentPageParam));
     }
 
+
+    /**
+     * 热门评论list获取
+     *
+     * @author pans
+     * @date  2025/06/27 11:07
+     */
+    @ApiOperationSupport(order = 1)
+    @ApiOperation("获取user_comment分页")
+    @GetMapping("/disk/comment/pageList")
+    public CommonResult<Page<UserCommentVo>> pageList(UserCommentPageParam userCommentPageParam) {
+        return CommonResult.data(userCommentService.pageList(userCommentPageParam));
+    }
+
     /**
      * 添加user_comment
      *

+ 2 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/mapper/UserCommentMapper.java

@@ -35,4 +35,6 @@ public interface UserCommentMapper extends BaseMapper<UserComment> {
     List<UserCommentVo> selectCommentNoPid(@Param("resourceId") String resourceId,@Param("userId") String userId);
 
     List<UserCommentVo> queryListCount(String resourceId);
+
+    Page<UserCommentVo> pageList(@Param("page") Page<Object> objectPage, @Param("resourceId") String resourceId, @Param("userId") String userId);
 }

+ 19 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/mapper/mapping/UserCommentMapper.xml

@@ -16,6 +16,7 @@
         WHERE
             resource_id=#{resourceId}
           and	pid IS NULL
+        order by a.id desc
     </select>
 
 
@@ -42,4 +43,22 @@
     </select>
 
 
+    <select id="pageList" resultType="vip.xiaonuo.disk.vo.comment.UserCommentVo">
+        SELECT
+            a.id,
+            a.pid,
+            a.comment_name commentName,
+            a.user_id userId,
+            a.comment_time,
+            ifnull(a.give_num,0) giveNum,
+            (SELECT count(1) FROM  user_comment_give WHERE comment_id=a.id AND user_id=#{userId} and  delete_flag='NOT_DELETE') giveNumSelf,
+            b.name  userName
+        FROM
+            user_comment a LEFT JOIN  sys_user b ON a. user_id=b.id
+        WHERE
+            resource_id=#{resourceId}
+          and	pid IS NULL
+          order by  a.give_num DESC,a.id desc
+    </select>
+
 </mapper>

+ 2 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/UserCommentService.java

@@ -77,4 +77,6 @@ public interface UserCommentService extends IService<UserComment> {
     void give(@Valid @NotNull(message="评论id不能为空") Integer id);
 
     String giveCancel(@Valid @NotNull(message="评论id不能为空") Integer id);
+
+    Page<UserCommentVo> pageList(UserCommentPageParam userCommentPageParam);
 }

+ 16 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/impl/UserCommentServiceImpl.java

@@ -68,6 +68,20 @@ public class UserCommentServiceImpl extends ServiceImpl<UserCommentMapper, UserC
         return page;
     }
 
+
+
+    @Override
+    public Page<UserCommentVo> pageList(UserCommentPageParam userCommentPageParam) {
+        Page<UserCommentVo> page=userCommentMapper.pageList(CommonPageRequest.defaultPage(),userCommentPageParam.getResourceId(),StpLoginUserUtil.getLoginUser().getId());
+        List<UserCommentVo> list=userCommentMapper.selectCommentNoPid(userCommentPageParam.getResourceId(),StpLoginUserUtil.getLoginUser().getId());
+        page.getRecords().stream().forEach(item -> {
+            List<UserCommentVo> child= list.stream().filter(itemchild-> itemchild.getPid().equals(item.getId())).collect(Collectors.toList());
+            item.setChild(child);
+            item.setChildSize(child.size());
+        });
+        return page;
+    }
+
     @Override
     public List<UserCommentVo> queryList(String resourceId)
     {
@@ -139,6 +153,8 @@ public class UserCommentServiceImpl extends ServiceImpl<UserCommentMapper, UserC
     }
 
 
+
+
     public UserComment queryEntity(Integer id) {
         UserComment userComment = this.getById(id);
         if(ObjectUtil.isEmpty(userComment)) {