mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 06:50:53 +08:00
Implement AND logic for category and tag filters
This commit is contained in:
@@ -64,11 +64,19 @@ public class PostController {
|
||||
if (categoryId != null) {
|
||||
ids = java.util.List.of(categoryId);
|
||||
}
|
||||
if ((tagId != null || (tagIds != null && !tagIds.isEmpty()))) {
|
||||
List<Long> tids = tagIds;
|
||||
if (tagId != null) {
|
||||
tids = java.util.List.of(tagId);
|
||||
}
|
||||
List<Long> tids = tagIds;
|
||||
if (tagId != null) {
|
||||
tids = java.util.List.of(tagId);
|
||||
}
|
||||
|
||||
boolean hasCategories = ids != null && !ids.isEmpty();
|
||||
boolean hasTags = tids != null && !tids.isEmpty();
|
||||
|
||||
if (hasCategories && hasTags) {
|
||||
return postService.listPostsByCategoriesAndTags(ids, tids, page, pageSize)
|
||||
.stream().map(this::toDto).collect(Collectors.toList());
|
||||
}
|
||||
if (hasTags) {
|
||||
return postService.listPostsByTags(tids, page, pageSize)
|
||||
.stream().map(this::toDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user