diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java index 5236869..fe15d5d 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/CommentController.java @@ -310,7 +310,15 @@ public class CommentController extends BaseController { comment.setAvatar(Constants.RESOURCE_PREFIX+userLoginDto.getAvatar()); comment.setLocation(IpUtil.getIpLocation(getIpAddr(request))); Comment commentResp = commentService.save(comment,userLoginDto); - + UserInfo commentUserInfo = userInfoService.findById(comment.getUserId()); + if (StringUtils.isNotEmpty(commentUserInfo.getBadges())){ + Set badgeSet = new HashSet<>(); + Arrays.stream(commentUserInfo.getBadges().split(",")).forEach(b->{ + int code=Integer.valueOf(b.substring(0, 1)); + badgeSet.add(code); + }); + commentResp.setBadgeList(new ArrayList<>(badgeSet)); + } return Result.success(commentResp); } diff --git a/luoo_comment/src/main/java/com/luoo/comment/dao/CommentDao.java b/luoo_comment/src/main/java/com/luoo/comment/dao/CommentDao.java index 161b17a..f93ee7d 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/dao/CommentDao.java +++ b/luoo_comment/src/main/java/com/luoo/comment/dao/CommentDao.java @@ -11,6 +11,7 @@ public interface CommentDao extends MongoRepository { public Page findByParentId(String parentId, Pageable pageable); public Page findByRootIdAndReplyToUserIdNotNullOrderByPublishTimeDesc(String rootId, Pageable pageable); + public Page findByRootIdAndReplyToUserIdNotNullOrderByThumbupCountDescPublishTimeDesc(String rootId, Pageable pageable); public Page findByJournalId(String journalId, Pageable pageable); public Page findByJournalIdOrderByPublishTimeDesc(String journalId, Pageable pageable); public Page findByJournalIdOrderByThumbupCountDesc(String journalId, Pageable pageable); diff --git a/luoo_comment/src/main/java/com/luoo/comment/pojo/Comment.java b/luoo_comment/src/main/java/com/luoo/comment/pojo/Comment.java index cd02d8e..89b62b2 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/pojo/Comment.java +++ b/luoo_comment/src/main/java/com/luoo/comment/pojo/Comment.java @@ -1,12 +1,14 @@ package com.luoo.comment.pojo; import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.springframework.data.annotation.Id; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; +import java.util.List; @Data @@ -63,4 +65,8 @@ public class Comment implements Serializable { private String replyToNickname; + + @ApiModelProperty(value = "用户标识,贡献者:1 ") + private List badgeList; + } diff --git a/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java b/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java index 71cfee0..fd703c1 100644 --- a/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java +++ b/luoo_comment/src/main/java/com/luoo/comment/service/CommentService.java @@ -198,7 +198,7 @@ public class CommentService { public Page findByParentId(String parentId, int page, int size) { Pageable pageable = PageRequest.of(page-1,size); - return commentDao.findByRootIdAndReplyToUserIdNotNullOrderByPublishTimeDesc(parentId,pageable); + return commentDao.findByRootIdAndReplyToUserIdNotNullOrderByThumbupCountDescPublishTimeDesc(parentId,pageable); } diff --git a/luoo_music/src/main/java/com/luoo/music/dto/mapper/CommentMapper.java b/luoo_music/src/main/java/com/luoo/music/dto/mapper/CommentMapper.java index d7dba14..36ea2bb 100644 --- a/luoo_music/src/main/java/com/luoo/music/dto/mapper/CommentMapper.java +++ b/luoo_music/src/main/java/com/luoo/music/dto/mapper/CommentMapper.java @@ -87,7 +87,7 @@ public class CommentMapper { - commentDTO.setCommentList((List) cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_HOT_COMMENTS,journalId, key-> CommentMapper.getList(journalId,commentDao,userClient),false)); + commentDTO.setCommentList((List) cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_HOT_COMMENTS,journalId, key-> CommentMapper.getList(journalId,commentDao,userClient),false).getValue()); /** * 获取期刊总评论数 一级评论数加上父评论的总回复数 */