Add count and description to category and tag dropdown

This commit is contained in:
Tim
2025-07-10 11:51:04 +08:00
parent bdbc7e72b7
commit a9cffc6e42
8 changed files with 139 additions and 38 deletions

View File

@@ -274,4 +274,12 @@ public class PostService {
public java.util.List<Post> getPostsByIds(java.util.List<Long> ids) {
return postRepository.findAllById(ids);
}
public long countPostsByCategory(Long categoryId) {
return postRepository.countByCategory_Id(categoryId);
}
public long countPostsByTag(Long tagId) {
return postRepository.countDistinctByTags_Id(tagId);
}
}

View File

@@ -54,4 +54,11 @@ public class TagService {
public List<Tag> listTags() {
return tagRepository.findAll();
}
public List<Tag> searchTags(String keyword) {
if (keyword == null || keyword.isBlank()) {
return tagRepository.findAll();
}
return tagRepository.findByNameContainingIgnoreCase(keyword);
}
}