Search in sources :

Example 1 with Blog

use of com.dimple.project.blog.domain.Blog in project DimpleBlog by martin-chips.

the class BlogServiceImpl method selectBlogById.

@Override
public Blog selectBlogById(Long id) {
    Blog blog = blogMapper.selectBlogById(id);
    blog.setTagTitleList(getTagTitleListByBlogId(id));
    return blog;
}
Also used : Blog(com.dimple.project.blog.domain.Blog)

Example 2 with Blog

use of com.dimple.project.blog.domain.Blog in project DimpleBlog by martin-chips.

the class BlogServiceImpl method selectBlogDetailById.

@Override
public Blog selectBlogDetailById(Long id) {
    Blog blog = blogMapper.selectBlogByIdQuery(id);
    blog.setTagList(tagService.selectTagListByBlogId(id));
    // 获取commentList
    blog.setCommentList(commentMapper.selectCommentListByPageId(id));
    // 设置点击数量+1
    blogMapper.incrementBlogClick(id);
    return blog;
}
Also used : Blog(com.dimple.project.blog.domain.Blog)

Example 3 with Blog

use of com.dimple.project.blog.domain.Blog 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)

Example 4 with Blog

use of com.dimple.project.blog.domain.Blog in project DimpleBlog by martin-chips.

the class FrontController method blogDetail.

@GetMapping("/blog/{id}")
@VLog(title = "查看博客", pageId = "#id")
public AjaxResult blogDetail(@PathVariable Long id) {
    Blog blog = frontService.selectBlogDetailById(id);
    frontService.incrementBlogClick(id);
    return AjaxResult.success(blog);
}
Also used : Blog(com.dimple.project.blog.domain.Blog) GetMapping(org.springframework.web.bind.annotation.GetMapping) VLog(com.dimple.framework.aspectj.lang.annotation.VLog)

Example 5 with Blog

use of com.dimple.project.blog.domain.Blog in project DimpleBlog by martin-chips.

the class FrontServiceImpl method selectBlogDetailById.

@Override
@Cacheable(value = CacheConstants.CACHE_NAME_FRONT_BLOG_ITEM, key = "'BlogId:' +#id")
@CacheExpire(expire = 1, type = TimeType.MINUTES)
public Blog selectBlogDetailById(Long id) {
    Blog blog = frontMapper.selectBlogDetailById(id);
    // get all comment
    blog.setCommentList(selectCommentListByPageId(id));
    return blog;
}
Also used : Blog(com.dimple.project.blog.domain.Blog) CacheExpire(com.dimple.framework.config.redis.CacheExpire) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Blog (com.dimple.project.blog.domain.Blog)5 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 VLog (com.dimple.framework.aspectj.lang.annotation.VLog)1 CacheExpire (com.dimple.framework.config.redis.CacheExpire)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 Cacheable (org.springframework.cache.annotation.Cacheable)1 Service (org.springframework.stereotype.Service)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1