Search in sources :

Example 1 with Category

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;
}
Also used : List(java.util.List) CategoryMapper(com.dimple.project.blog.mapper.CategoryMapper) ConvertUtils(com.dimple.common.utils.ConvertUtils) CategoryService(com.dimple.project.blog.service.CategoryService) DateUtils(com.dimple.common.utils.DateUtils) Service(org.springframework.stereotype.Service) SecurityUtils(com.dimple.common.utils.SecurityUtils) Blog(com.dimple.project.blog.domain.Blog) ObjectUtils(com.dimple.common.utils.ObjectUtils) Category(com.dimple.project.common.domain.Category) Collectors(java.util.stream.Collectors) BlogMapper(com.dimple.project.blog.mapper.BlogMapper) Category(com.dimple.project.common.domain.Category) Blog(com.dimple.project.blog.domain.Blog)

Aggregations

ConvertUtils (com.dimple.common.utils.ConvertUtils)1 DateUtils (com.dimple.common.utils.DateUtils)1 ObjectUtils (com.dimple.common.utils.ObjectUtils)1 SecurityUtils (com.dimple.common.utils.SecurityUtils)1 Blog (com.dimple.project.blog.domain.Blog)1 BlogMapper (com.dimple.project.blog.mapper.BlogMapper)1 CategoryMapper (com.dimple.project.blog.mapper.CategoryMapper)1 CategoryService (com.dimple.project.blog.service.CategoryService)1 Category (com.dimple.project.common.domain.Category)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Service (org.springframework.stereotype.Service)1