diff --git a/src/main/java/run/halo/app/controller/admin/api/JournalController.java b/src/main/java/run/halo/app/controller/admin/api/JournalController.java index d60a29210..708518113 100644 --- a/src/main/java/run/halo/app/controller/admin/api/JournalController.java +++ b/src/main/java/run/halo/app/controller/admin/api/JournalController.java @@ -50,7 +50,7 @@ public class JournalController { } @GetMapping - @ApiOperation("Gets latest journals") + @ApiOperation("Lists journals") public Page pageBy(@PageableDefault(sort = "updateTime", direction = DESC) Pageable pageable, JournalQuery journalQuery) { Page journalPage = journalService.pageBy(journalQuery, pageable); diff --git a/src/main/java/run/halo/app/repository/JournalCommentRepository.java b/src/main/java/run/halo/app/repository/JournalCommentRepository.java index 904d849a8..737ff89a8 100644 --- a/src/main/java/run/halo/app/repository/JournalCommentRepository.java +++ b/src/main/java/run/halo/app/repository/JournalCommentRepository.java @@ -1,8 +1,14 @@ package run.halo.app.repository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.lang.NonNull; import run.halo.app.model.entity.JournalComment; +import run.halo.app.model.projection.CommentChildrenCountProjection; +import run.halo.app.model.projection.CommentCountProjection; import run.halo.app.repository.base.BaseCommentRepository; +import java.util.List; + /** * Journal comment repository. * @@ -11,8 +17,18 @@ import run.halo.app.repository.base.BaseCommentRepository; */ public interface JournalCommentRepository extends BaseCommentRepository { -// @Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) from JournalComment comment where comment.postId in ?1 group by comment.postId") -// @NonNull -// @Override -// List countByPostIds(@NonNull Iterable postIds); + @Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) " + + "from JournalComment comment " + + "where comment.postId in ?1 group by comment.postId") + @NonNull + @Override + List countByPostIds(@NonNull Iterable postIds); + + @Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " + + "from JournalComment comment " + + "where comment.parentId in ?1 " + + "group by comment.parentId") + @NonNull + @Override + List findDirectChildrenCount(@NonNull Iterable commentIds); } diff --git a/src/main/java/run/halo/app/repository/PostCommentRepository.java b/src/main/java/run/halo/app/repository/PostCommentRepository.java index 461801739..974178d46 100644 --- a/src/main/java/run/halo/app/repository/PostCommentRepository.java +++ b/src/main/java/run/halo/app/repository/PostCommentRepository.java @@ -1,8 +1,14 @@ package run.halo.app.repository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.lang.NonNull; import run.halo.app.model.entity.PostComment; +import run.halo.app.model.projection.CommentChildrenCountProjection; +import run.halo.app.model.projection.CommentCountProjection; import run.halo.app.repository.base.BaseCommentRepository; +import java.util.List; + /** * PostComment repository. * @@ -11,9 +17,17 @@ import run.halo.app.repository.base.BaseCommentRepository; */ public interface PostCommentRepository extends BaseCommentRepository { -// @Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) from PostComment comment where comment.postId in ?1 group by comment.postId") -// @NonNull -// @Override -// List countByPostIds(@NonNull Iterable postIds); + @Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) " + + "from PostComment comment " + + "where comment.postId in ?1 group by comment.postId") + @NonNull + @Override + List countByPostIds(@NonNull Iterable postIds); + @Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " + + "from PostComment comment " + + "where comment.parentId in ?1 " + + "group by comment.parentId") + @NonNull + List findDirectChildrenCount(@NonNull Iterable commentIds); } diff --git a/src/main/java/run/halo/app/repository/SheetCommentRepository.java b/src/main/java/run/halo/app/repository/SheetCommentRepository.java index a197e143d..e121952b5 100644 --- a/src/main/java/run/halo/app/repository/SheetCommentRepository.java +++ b/src/main/java/run/halo/app/repository/SheetCommentRepository.java @@ -1,8 +1,14 @@ package run.halo.app.repository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.lang.NonNull; import run.halo.app.model.entity.SheetComment; +import run.halo.app.model.projection.CommentChildrenCountProjection; +import run.halo.app.model.projection.CommentCountProjection; import run.halo.app.repository.base.BaseCommentRepository; +import java.util.List; + /** * Sheet comment repository. * @@ -10,9 +16,18 @@ import run.halo.app.repository.base.BaseCommentRepository; * @date 19-4-24 */ public interface SheetCommentRepository extends BaseCommentRepository { -// -// @Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) from SheetComment comment where comment.postId in ?1 group by comment.postId") -// @NonNull -// @Override -// List countByPostIds(@NonNull Iterable postIds); + + @Query("select new run.halo.app.model.projection.CommentCountProjection(count(comment.id), comment.postId) " + + "from SheetComment comment " + + "where comment.postId in ?1 group by comment.postId") + @NonNull + @Override + List countByPostIds(@NonNull Iterable postIds); + + @Query("select new run.halo.app.model.projection.CommentChildrenCountProjection(count(comment.id), comment.parentId) " + + "from SheetComment comment " + + "where comment.parentId in ?1 " + + "group by comment.parentId") + @NonNull + List findDirectChildrenCount(@NonNull Iterable commentIds); }