fangqing 4 месяцев назад
Родитель
Сommit
050bd98cd7

+ 9 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityCommentController.java

@@ -339,6 +339,7 @@ public class CommunityCommentController extends BaseController {
         if (Objects.isNull(articleId)) {
             return AjaxResult.error("参数异常!");
         }
+        Long userId = SecurityUtils.getUserId();
         List<CommunitySearchCommentVo> commentVos = new ArrayList<>();
         try {
             int offset = (pageNum - 1) * pageSize;
@@ -356,7 +357,9 @@ public class CommunityCommentController extends BaseController {
                 vo.setAvatar(sysUserService.selectUserById(vo.getUserId()).getAvatar());
                 vo.setNickName(sysUserService.selectUserById(vo.getUserId()).getNickName());
                 vo.setCommentLikeCount(communityCommentLikeMapper.selectList(new QueryWrapper<CommunityCommentLike>().eq("comment_id", vo.getId())).size());
-
+                //设置当前用户是否点赞
+                List<CommunityCommentLike> commentLikes = communityCommentLikeMapper.selectList(new QueryWrapper<CommunityCommentLike>().eq("comment_id", vo.getId()).eq("user_id", userId));
+                vo.setCommentLike(!commentLikes.isEmpty());
                 //如果是二级评论则执行这个接口
                 CommunityCommentReply communityCommentReply = communityCommentReplyMapper.selectOne(new QueryWrapper<CommunityCommentReply>().eq("id", vo.getId()).and((wrapper) -> {
                     wrapper.ne("is_delete", true).or().isNull("is_delete");
@@ -368,6 +371,11 @@ public class CommunityCommentController extends BaseController {
                     List<CommunityCommentLike> commentLikeList = communityCommentLikeMapper.selectList(new QueryWrapper<CommunityCommentLike>()
                             .eq("reply_id", communityCommentReply.getId()));
                     vo.setCommentLikeCount(commentLikeList.size());
+
+                    //二级评论是否点赞
+                    List<CommunityCommentLike> commentLikesReply = communityCommentLikeMapper.selectList(new QueryWrapper<CommunityCommentLike>().eq("reply_id", vo.getId()).eq("user_id", userId));
+                    vo.setCommentLike(!commentLikesReply.isEmpty());
+
                     //找到一级评论获取 父评论 用户头像和ID
                     CommunityArticleComment communityArticleComment = communityArticleCommentMapper.selectOne(new QueryWrapper<CommunityArticleComment>().eq("id", communityCommentReply.getCommentId()).and((wrapper) -> {
                         wrapper.ne("is_delete", true).or().isNull("is_delete");

+ 0 - 5
ruoyi-generator/src/main/java/com/ruoyi/generator/vo/CommunitySearchCommentVo.java

@@ -88,11 +88,6 @@ public class CommunitySearchCommentVo extends BaseEntity implements Serializable
     @ApiModelProperty("评论下回复剩余总数")
     private int replyCount;
 
-    /**
-     * 是否是回复
-     */
-    @ApiModelProperty("是否是回复")
-    private boolean isReply;
 
     /**
      * 图片地址