diff --git a/len-blog/src/main/java/com/len/controller/ArticleController.java b/len-blog/src/main/java/com/len/controller/ArticleController.java index 837ffe4..5a4df12 100644 --- a/len-blog/src/main/java/com/len/controller/ArticleController.java +++ b/len-blog/src/main/java/com/len/controller/ArticleController.java @@ -2,16 +2,22 @@ package com.len.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import com.len.entity.ArticleCategory; import com.len.entity.ArticleList; import com.len.entity.BlogArticle; +import com.len.entity.BlogCategory; +import com.len.service.ArticleCategoryService; import com.len.service.BlogArticleService; +import com.len.service.BlogCategoryService; import com.len.util.JsonUtil; import com.len.util.ReType; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import tk.mybatis.mapper.entity.Condition; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -31,6 +37,12 @@ public class ArticleController { @Autowired private BlogArticleService articleService; + @Autowired + private ArticleCategoryService articleCategoryService; + + @Autowired + private BlogCategoryService categoryService; + private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @GetMapping("/articleList") @@ -50,10 +62,11 @@ public class ArticleController { } @GetMapping("/article/list") - public ReType getList(BlogArticle article, Integer page, Integer limit) { + public ReType getList(String code, Integer page, Integer limit) { limit = limit > 100 ? 100 : limit; Page startPage = PageHelper.startPage(page, limit); - List articles = articleService.selectListByPage(article); + + List articles = articleService.selectArticle(code); List articleLists = new ArrayList<>(); articles.forEach(s -> articleLists.add( @@ -62,6 +75,7 @@ public class ArticleController { format.format(s.getCreateDate()), s.getContent()) ) ); + long total = startPage.getTotal(); return new ReType(startPage.getTotal(), startPage.getPageNum(), articleLists); } diff --git a/len-blog/src/main/java/com/len/controller/BlogAdminController.java b/len-blog/src/main/java/com/len/controller/BlogAdminController.java index 7af430a..81c03f8 100644 --- a/len-blog/src/main/java/com/len/controller/BlogAdminController.java +++ b/len-blog/src/main/java/com/len/controller/BlogAdminController.java @@ -55,7 +55,6 @@ public class BlogAdminController { @GetMapping("/article/getList") public ReType getArticleList(BlogArticle article, Integer page, Integer limit) { - Principal principal = LenUser.getPrincipal(); return articleService.getList(article, page, limit); } diff --git a/len-blog/src/main/java/com/len/mapper/BlogArticleMapper.java b/len-blog/src/main/java/com/len/mapper/BlogArticleMapper.java index b9a0fa9..7606f5f 100644 --- a/len-blog/src/main/java/com/len/mapper/BlogArticleMapper.java +++ b/len-blog/src/main/java/com/len/mapper/BlogArticleMapper.java @@ -2,6 +2,11 @@ package com.len.mapper; import com.len.base.BaseMapper; import com.len.entity.BlogArticle; +import org.apache.ibatis.annotations.Param; + +import java.util.List; public interface BlogArticleMapper extends BaseMapper { + + List selectArticle(@Param("code") String code); } \ No newline at end of file diff --git a/len-blog/src/main/java/com/len/service/BlogArticleService.java b/len-blog/src/main/java/com/len/service/BlogArticleService.java index 0c76ba0..ace7b58 100644 --- a/len-blog/src/main/java/com/len/service/BlogArticleService.java +++ b/len-blog/src/main/java/com/len/service/BlogArticleService.java @@ -4,6 +4,8 @@ import com.len.base.BaseService; import com.len.entity.BlogArticle; import com.len.util.JsonUtil; +import java.util.List; + /** * @author zhuxiaomeng * @date 2018/9/9. @@ -12,4 +14,6 @@ import com.len.util.JsonUtil; public interface BlogArticleService extends BaseService { public JsonUtil getDetail(String code); + + List selectArticle(String code); } diff --git a/len-blog/src/main/java/com/len/service/impl/BlogArticleServiceImpl.java b/len-blog/src/main/java/com/len/service/impl/BlogArticleServiceImpl.java index 6cd1602..46b520b 100644 --- a/len-blog/src/main/java/com/len/service/impl/BlogArticleServiceImpl.java +++ b/len-blog/src/main/java/com/len/service/impl/BlogArticleServiceImpl.java @@ -78,4 +78,9 @@ public class BlogArticleServiceImpl extends BaseServiceImpl json.setFlag(true); return json; } + + @Override + public List selectArticle(String code) { + return blogArticleMapper.selectArticle(code); + } } diff --git a/len-blog/src/main/resources/mapper/BlogArticleMapper.xml b/len-blog/src/main/resources/mapper/BlogArticleMapper.xml index ee6dc4d..bfced5f 100644 --- a/len-blog/src/main/resources/mapper/BlogArticleMapper.xml +++ b/len-blog/src/main/resources/mapper/BlogArticleMapper.xml @@ -28,4 +28,25 @@ order by read_number asc,create_date desc + + \ No newline at end of file