diff --git a/backend/src/main/java/com/openisle/service/PostService.java b/backend/src/main/java/com/openisle/service/PostService.java index d62a7fa40..a3038d478 100644 --- a/backend/src/main/java/com/openisle/service/PostService.java +++ b/backend/src/main/java/com/openisle/service/PostService.java @@ -464,13 +464,14 @@ public class PostService { return paginate(sortByPinnedAndCreated(posts), page, pageSize); } - public List listFeaturedPosts(java.util.List categoryIds, - java.util.List tagIds, + public List listFeaturedPosts(List categoryIds, + List tagIds, Integer page, Integer pageSize) { List posts; boolean hasCategories = categoryIds != null && !categoryIds.isEmpty(); boolean hasTags = tagIds != null && !tagIds.isEmpty(); + if (hasCategories && hasTags) { posts = listPostsByCategoriesAndTags(categoryIds, tagIds, null, null); } else if (hasCategories) { @@ -480,10 +481,17 @@ public class PostService { } else { posts = listPosts(); } - posts = posts.stream().filter(p -> !Boolean.TRUE.equals(p.getRssExcluded())).toList(); + + // 仅保留 getRssExcluded 为 0 且不为空 + // 若字段类型是 Boolean(包装类型),0 等价于 false: + posts = posts.stream() + .filter(p -> p.getRssExcluded() != null && !p.getRssExcluded()) + .toList(); + return paginate(sortByPinnedAndCreated(posts), page, pageSize); } + public List listPendingPosts() { return postRepository.findByStatus(PostStatus.PENDING); }