diff --git a/src/src/main/java/net/myblog/repository/ArticleRepository.java b/src/src/main/java/net/myblog/repository/ArticleRepository.java index 9ce2a1a4d91c8b253ab76ab98b478aa337cb6e74..5d6db16268a5dce01e51c1463d8d0a14b6f05c7c 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 5e8bb4842dd2b0b170ba9d2fc5c7c9f8ff592fdf..fc4fdb0ec6198bb0a9113ae92e7e2922de7153c1 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 d7d159275d99a9ae28914d166c631edab1be11f2..1d9c3647abaed59dd44aaa6be163bc4812dcc454 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 29e5ae1cfbb942cf41cdbf827537766636fe8c98..6f77eb93ef971dbc6a1d5a0b41223ff3e6fd26bd 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 3e1fcceffc6e1d1eb9a40c5afe2add7be4e5127d..f5e13aac993b2c3562f7920b3506fd1d2e5a9aeb 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 }