Add ranking endpoint and UI

This commit is contained in:
Tim
2025-07-09 20:48:58 +08:00
parent db58af31c9
commit befe0ff470
4 changed files with 88 additions and 11 deletions

View File

@@ -107,6 +107,17 @@ public class PostService {
return listPostsByCategories(null, null, null);
}
public List<Post> listPostsByViews(Integer page, Integer pageSize) {
Pageable pageable = null;
if (page != null && pageSize != null) {
pageable = PageRequest.of(page, pageSize);
}
if (pageable != null) {
return postRepository.findByStatusOrderByViewsDesc(PostStatus.PUBLISHED, pageable);
}
return postRepository.findByStatusOrderByViewsDesc(PostStatus.PUBLISHED);
}
public List<Post> listPostsByCategories(java.util.List<Long> categoryIds,
Integer page,
Integer pageSize) {