|
|
|
@ -3,6 +3,7 @@ package cc.bnblogs.service; |
|
|
|
|
import cc.bnblogs.common.ArticleSearch; |
|
|
|
|
import cc.bnblogs.common.PageHelper; |
|
|
|
|
import cc.bnblogs.mapper.ArticleMapper; |
|
|
|
|
import cc.bnblogs.mapper.CategoryMapper; |
|
|
|
|
import cc.bnblogs.mapper.CommentMapper; |
|
|
|
|
import cc.bnblogs.mapper.TagMapper; |
|
|
|
|
import cc.bnblogs.pojo.Article; |
|
|
|
@ -42,11 +43,13 @@ public class ArticleService { |
|
|
|
|
private final TagMapper tagMapper; |
|
|
|
|
private final ArticleMapper articleMapper; |
|
|
|
|
private final CommentMapper commentMapper; |
|
|
|
|
private final CategoryMapper categoryMapper; |
|
|
|
|
|
|
|
|
|
public ArticleService(ArticleMapper articleMapper, TagMapper tagMapper, CommentMapper commentMapper) { |
|
|
|
|
public ArticleService(ArticleMapper articleMapper, TagMapper tagMapper, CommentMapper commentMapper, CategoryMapper categoryMapper) { |
|
|
|
|
this.articleMapper = articleMapper; |
|
|
|
|
this.tagMapper = tagMapper; |
|
|
|
|
this.commentMapper = commentMapper; |
|
|
|
|
this.categoryMapper = categoryMapper; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -64,6 +67,14 @@ public class ArticleService { |
|
|
|
|
public long count() { |
|
|
|
|
return articleMapper.count(); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 获取该分类下的文章数 |
|
|
|
|
* @param id 分类id |
|
|
|
|
* @return 文章数 |
|
|
|
|
*/ |
|
|
|
|
public long countByCategoryId(Integer id){ |
|
|
|
|
return articleMapper.countByCategory(categoryMapper.getOne(id)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据id查询文章对象 |
|
|
|
@ -212,4 +223,8 @@ public class ArticleService { |
|
|
|
|
articleMapper.updateArticleViews(id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateToDefaultCategory(Integer articleCategoryId){ |
|
|
|
|
articleMapper.updateToDefaultCategory(articleCategoryId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|