|
@@ -2,6 +2,7 @@ package com.mszlu.blog.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.mszlu.blog.dao.dos.Archives;
|
|
|
import com.mszlu.blog.dao.mapper.ArticleMapper;
|
|
|
import com.mszlu.blog.dao.pojo.Article;
|
|
|
import com.mszlu.blog.service.ArticleService;
|
|
@@ -43,6 +44,36 @@ public class ArticleServiceImpl implements ArticleService {
|
|
|
return Result.success(articleVoList);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result hotArticle(int limit) {
|
|
|
+ LambdaQueryWrapper<Article> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.orderByDesc(Article::getViewCounts);
|
|
|
+ queryWrapper.select(Article::getId,Article::getTitle);
|
|
|
+ queryWrapper.last("limit"+limit);
|
|
|
+ //select id.title from article order by view_counts desc limit 5
|
|
|
+ List<Article> articles = articleMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ return Result.success(copyList(articles,false,false));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result newsArticle(int limit) {
|
|
|
+ LambdaQueryWrapper<Article> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.orderByDesc(Article::getCreateDate);
|
|
|
+ queryWrapper.select(Article::getId,Article::getTitle);
|
|
|
+ queryWrapper.last("limit "+limit);
|
|
|
+ //select id.title from article order by create_data desc limit 5
|
|
|
+ List<Article> articles = articleMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ return Result.success(copyList(articles,false,false));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result listArchives() {
|
|
|
+ List<Archives> archivesList = articleMapper.listArchives();
|
|
|
+ return Result.success(archivesList);
|
|
|
+ }
|
|
|
+
|
|
|
private List<ArticleVo> copyList(List<Article> records,boolean isTag,boolean isAuthor) {
|
|
|
List<ArticleVo> articleVoList = new ArrayList<>();
|
|
|
for (Article record : records){
|