Commit 36c3d6f5 authored by 刘基明's avatar 刘基明

评论排序

parent 969228b0
...@@ -17,8 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,8 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
@Service @Service
public class CommentManager { public class CommentManager {
...@@ -68,11 +70,7 @@ public class CommentManager { ...@@ -68,11 +70,7 @@ public class CommentManager {
} }
//是否点赞及点赞数 //是否点赞及点赞数
String commentId = commentQo.getCommentId(); String commentId = commentQo.getCommentId();
if (likeCommentList.contains(commentId)) { commentQo.setHasLiked(likeCommentList.contains(commentId));
commentQo.setHasLiked(true);
} else {
commentQo.setHasLiked(false);
}
Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT); Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT);
commentQo.setLikeCount(countByTypeAndId); commentQo.setLikeCount(countByTypeAndId);
...@@ -81,8 +79,10 @@ public class CommentManager { ...@@ -81,8 +79,10 @@ public class CommentManager {
// List<CommentLv2Qo> commentLv2Qos = ConvertUtil.commentLv2Entity2Qos(CommentLv2Entities); // List<CommentLv2Qo> commentLv2Qos = ConvertUtil.commentLv2Entity2Qos(CommentLv2Entities);
// commentQo.setCommentLv2Qos(commentLv2Qos); // commentQo.setCommentLv2Qos(commentLv2Qos);
} }
//排序
return commentQos; return commentQos.stream().sorted(Comparator.comparing(CommentQo::getLikeCount,Comparator.reverseOrder()).
thenComparing(CommentQo::getUpdateTime,Comparator.reverseOrder()))
.collect(Collectors.toList());
} }
//点赞评论/取消点赞 //点赞评论/取消点赞
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment