From 9ce74e850cfccd773698486a3dad48b6ed77a1f8 Mon Sep 17 00:00:00 2001 From: wangqing <408564126@qq.com> Date: Sat, 16 Mar 2024 23:07:45 +0800 Subject: [PATCH] fix commentlist top5-> top2 --- luoo_music/src/main/java/com/luoo/music/dao/CommentDao.java | 1 + .../main/java/com/luoo/music/dto/mapper/CommentMapper.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/luoo_music/src/main/java/com/luoo/music/dao/CommentDao.java b/luoo_music/src/main/java/com/luoo/music/dao/CommentDao.java index 5568882..c828b34 100644 --- a/luoo_music/src/main/java/com/luoo/music/dao/CommentDao.java +++ b/luoo_music/src/main/java/com/luoo/music/dao/CommentDao.java @@ -13,6 +13,7 @@ public interface CommentDao extends MongoRepository { public Page findByJournalId(String journalId, Pageable pageable); public List findTop5ByJournalIdOrderByThumbupCountDesc(String journalId); + public List findTop2ByJournalIdOrderByThumbupCountDesc(String journalId); public List findByJournalId(String journalId); 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 36ea2bb..2268bdf 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 @@ -28,7 +28,7 @@ public class CommentMapper { */ CommentDTO commentDTO=new CommentDTO(); - List commentList =commentDao.findTop5ByJournalIdOrderByThumbupCountDesc(journalId); + List commentList =commentDao.findTop2ByJournalIdOrderByThumbupCountDesc(journalId); commentDTO.setCommentList(commentList); /** * 获取期刊总评论数 一级评论数加上父评论的总回复数 @@ -62,7 +62,7 @@ public class CommentMapper { } public static List getList(String journalId,CommentDao commentDao,UserClient userClient){ - List commentList =commentDao.findTop5ByJournalIdOrderByThumbupCountDesc(journalId); + List commentList =commentDao.findTop2ByJournalIdOrderByThumbupCountDesc(journalId); if(commentList.size()>0){ commentList= commentList.stream().map(comment -> { UserInfoDTO userInfoDTO =userClient.findByUserId(comment.getUserId());