mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-07 02:27:34 +08:00
fix: exclude==null不列入精选
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user