use of com.dimple.project.common.domain.Category in project DimpleBlog by martin-chips.
the class CategoryServiceImpl method selectCategoryList.
@Override
public List<Category> selectCategoryList(Category bgCategory) {
List<Category> categoryList = bgCategoryMapper.selectCategoryList(bgCategory);
List<Long> categoryIds = categoryList.stream().map(Category::getId).collect(Collectors.toList());
if (ObjectUtils.isEmpty(categoryIds)) {
return categoryList;
}
List<Blog> blogList = blogMapper.selectBlogListByCategoryIds(categoryIds);
for (Category category : categoryList) {
List<Blog> collect = blogList.stream().filter(e -> category.getId().equals(e.getCategoryId())).collect(Collectors.toList());
category.setBlogList(collect);
}
return categoryList;
}
Aggregations