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

评论排序

parent 969228b0
......@@ -17,8 +17,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@Service
public class CommentManager {
......@@ -68,11 +70,7 @@ public class CommentManager {
}
//是否点赞及点赞数
String commentId = commentQo.getCommentId();
if (likeCommentList.contains(commentId)) {
commentQo.setHasLiked(true);
} else {
commentQo.setHasLiked(false);
}
commentQo.setHasLiked(likeCommentList.contains(commentId));
Integer countByTypeAndId = collectionService.getCountByTypeAndId(commentId, CollectionTypeEnum.LIKE_COMMENT);
commentQo.setLikeCount(countByTypeAndId);
......@@ -81,8 +79,10 @@ public class CommentManager {
// List<CommentLv2Qo> commentLv2Qos = ConvertUtil.commentLv2Entity2Qos(CommentLv2Entities);
// 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