|
@@ -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");
|