fix: exclude==null不列入精选

This commit is contained in:
Tim
2025-08-21 17:56:27 +08:00
parent cf722f5707
commit 0b8e550097

View File

@@ -464,13 +464,14 @@ public class PostService {
return paginate(sortByPinnedAndCreated(posts), page, pageSize); return paginate(sortByPinnedAndCreated(posts), page, pageSize);
} }
public List<Post> listFeaturedPosts(java.util.List<Long> categoryIds, public List<Post> listFeaturedPosts(List<Long> categoryIds,
java.util.List<Long> tagIds, List<Long> tagIds,
Integer page, Integer page,
Integer pageSize) { Integer pageSize) {
List<Post> posts; List<Post> posts;
boolean hasCategories = categoryIds != null && !categoryIds.isEmpty(); boolean hasCategories = categoryIds != null && !categoryIds.isEmpty();
boolean hasTags = tagIds != null && !tagIds.isEmpty(); boolean hasTags = tagIds != null && !tagIds.isEmpty();
if (hasCategories && hasTags) { if (hasCategories && hasTags) {
posts = listPostsByCategoriesAndTags(categoryIds, tagIds, null, null); posts = listPostsByCategoriesAndTags(categoryIds, tagIds, null, null);
} else if (hasCategories) { } else if (hasCategories) {
@@ -480,10 +481,17 @@ public class PostService {
} else { } else {
posts = listPosts(); 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); return paginate(sortByPinnedAndCreated(posts), page, pageSize);
} }
public List<Post> listPendingPosts() { public List<Post> listPendingPosts() {
return postRepository.findByStatus(PostStatus.PENDING); return postRepository.findByStatus(PostStatus.PENDING);
} }