Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Fix: return null if category or tag has no post
Browse files Browse the repository at this point in the history
  • Loading branch information
lyujp committed Jul 19, 2024
1 parent 2ffd8af commit 223600b
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ private PostsListDto packagePost(Integer pageNum, Integer pageSize, Integer type
LambdaQueryWrapper<PostTags> postTagsLambdaQueryWrapper = new LambdaQueryWrapper<>();
postTagsLambdaQueryWrapper.eq(PostTags::getTagId,id);
List<Long> postTagsList = postTagsService.list(postTagsLambdaQueryWrapper).stream().map(PostTags::getPostId).toList();
if(postTagsList.isEmpty()){
return null;
}
postsQueryWrapper.eq(Posts::getType, 1).eq(Posts::getVisible, true)
.in(Posts::getId, postTagsList);
}else if(filter == 3){
LambdaQueryWrapper<PostCategories> postCategoriesLambdaQueryWrapper = new LambdaQueryWrapper<>();
postCategoriesLambdaQueryWrapper.eq(PostCategories::getCategoryId,id);
List<Long> postCategoriesList = postCategoriesService.list(postCategoriesLambdaQueryWrapper).stream().map(PostCategories::getPostId).collect(Collectors.toList());
if(postCategoriesList.isEmpty()){
return null;
}
postsQueryWrapper.eq(Posts::getType, 1).eq(Posts::getVisible, true)
.in(Posts::getId, postCategoriesList);
}
Expand Down

0 comments on commit 223600b

Please sign in to comment.