From 31410fd84cd8a3fb6a0d5b26ba2478fe9e6c499f Mon Sep 17 00:00:00 2001 From: smileNicky <3623307211@qq.com> Date: Fri, 1 Feb 2019 16:02:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=B1=BB=E5=88=AB=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myblog/repository/ArticleRepository.java | 8 +++++ .../net/myblog/service/ArticleService.java | 9 ++++++ .../controller/LabelArticleController.java | 29 +++++++++++++++++-- .../jsp/myblog/article/article_label.jsp | 2 +- .../WEB-INF/jsp/myblog/frame/navsidebar.jsp | 2 +- 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/src/main/java/net/myblog/repository/ArticleRepository.java b/src/src/main/java/net/myblog/repository/ArticleRepository.java index 9ce2a1a..5d6db16 100644 --- a/src/src/main/java/net/myblog/repository/ArticleRepository.java +++ b/src/src/main/java/net/myblog/repository/ArticleRepository.java @@ -47,4 +47,12 @@ public interface ArticleRepository extends PagingAndSortingRepository listArticleByTypeId(@Param("typeId")int typeId); } diff --git a/src/src/main/java/net/myblog/service/ArticleService.java b/src/src/main/java/net/myblog/service/ArticleService.java index 5e8bb48..fc4fdb0 100644 --- a/src/src/main/java/net/myblog/service/ArticleService.java +++ b/src/src/main/java/net/myblog/service/ArticleService.java @@ -118,4 +118,13 @@ public class ArticleService { public Article getArticleInfo(int articleId) { return articleRepository.getArticleInfo(articleId); } + + /** + * 根据类别id或者文章列表 + * @param typeId + * @return + */ + public List
listArticleByTypeId(int typeId) { + return articleRepository.listArticleByTypeId(typeId); + } } diff --git a/src/src/main/java/net/myblog/web/controller/LabelArticleController.java b/src/src/main/java/net/myblog/web/controller/LabelArticleController.java index d7d1592..1d9c364 100644 --- a/src/src/main/java/net/myblog/web/controller/LabelArticleController.java +++ b/src/src/main/java/net/myblog/web/controller/LabelArticleController.java @@ -1,18 +1,41 @@ package net.myblog.web.controller; +import net.myblog.entity.Article; import net.myblog.service.ArticleService; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; +import java.util.List; + +/** + *
+ *  文章类别控制类
+ * 
+ * + * @author nicky + *
+ * 修改记录
+ *    修改后版本:     修改人:  修改日期: 2019年02月01日  修改内容:
+ * 
+ */ @Controller +@RequestMapping("/article/label") public class LabelArticleController extends BaseController{ @Autowired ArticleService articleService; - + + @RequestMapping(value = "/toListLabelArticle",method = RequestMethod.GET) + public ModelAndView toListLabelArticle(@RequestParam("typeId")String typeId){ + ModelAndView mv = this.getModelAndView(); + List
articles = this.articleService.listArticleByTypeId(Integer.parseInt(typeId)); + mv.addObject("articles", articles); + mv.setViewName("myblog/article/article_label"); + return mv; + } } diff --git a/src/src/main/webapp/WEB-INF/jsp/myblog/article/article_label.jsp b/src/src/main/webapp/WEB-INF/jsp/myblog/article/article_label.jsp index 29e5ae1..6f77eb9 100644 --- a/src/src/main/webapp/WEB-INF/jsp/myblog/article/article_label.jsp +++ b/src/src/main/webapp/WEB-INF/jsp/myblog/article/article_label.jsp @@ -41,7 +41,7 @@ background:url("plugins/easyui-1.3.4/themes/icons/search.png") no-repeat scroll

    - + ${ar.articleName }

    ${ar.articleContent }

    diff --git a/src/src/main/webapp/WEB-INF/jsp/myblog/frame/navsidebar.jsp b/src/src/main/webapp/WEB-INF/jsp/myblog/frame/navsidebar.jsp index 3e1fcce..f5e13aa 100644 --- a/src/src/main/webapp/WEB-INF/jsp/myblog/frame/navsidebar.jsp +++ b/src/src/main/webapp/WEB-INF/jsp/myblog/frame/navsidebar.jsp @@ -74,7 +74,7 @@ document.write(' -
  • ${a.name }
  • +
  • ${a.name }
  • -- GitLab