From c4c668042dcac88ee3d4043e671cc1c70949906f Mon Sep 17 00:00:00 2001 From: shuzheng <469741414@qq.com> Date: Sun, 26 Mar 2017 02:01:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90cms=E5=89=8D=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cms/web/controller/ArticleController.java | 35 ++++ .../cms/web/controller/BlogController.java | 26 +++ .../web/controller/CategoryController.java | 70 ++++++++ .../cms/web/controller/IndexController.java | 78 +++++---- .../cms/web/controller/NewsController.java | 26 +++ .../cms/web/controller/PageController.java | 39 +++++ .../cms/web/controller/QaController.java | 26 +++ .../cms/web/controller/SearchController.java | 66 ++++++++ .../cms/web/controller/TagController.java | 73 +++++++++ .../cms/web/controller/TopicController.java | 61 +++++++ .../web/interceptor/CmsWebInterceptor.java | 62 +++++++ .../src/main/resources/springMVC-servlet.xml | 9 ++ .../src/main/webapp/WEB-INF/jsp/index.jsp | 151 ------------------ zheng-ui/src/zheng-cms-web/article/index.html | 106 ++++++++++++ zheng-ui/src/zheng-cms-web/blog/index.html | 105 ++++++++++++ .../src/zheng-cms-web/category/index.html | 109 +++++++++++++ zheng-ui/src/zheng-cms-web/inc/footer.jsp | 8 - zheng-ui/src/zheng-cms-web/inc/head.jsp | 7 - zheng-ui/src/zheng-cms-web/index.html | 94 +++++------ zheng-ui/src/zheng-cms-web/news/index.html | 105 ++++++++++++ zheng-ui/src/zheng-cms-web/page/index.html | 106 ++++++++++++ zheng-ui/src/zheng-cms-web/qa/index.html | 105 ++++++++++++ zheng-ui/src/zheng-cms-web/search/index.html | 109 +++++++++++++ zheng-ui/src/zheng-cms-web/tag/index.html | 109 +++++++++++++ zheng-ui/src/zheng-cms-web/topic/index.html | 106 ++++++++++++ zheng-ui/src/zheng-cms-web/topic/list.html | 109 +++++++++++++ 26 files changed, 1648 insertions(+), 252 deletions(-) create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/ArticleController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/BlogController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/CategoryController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/NewsController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/PageController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/QaController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/SearchController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TagController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TopicController.java create mode 100644 zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/interceptor/CmsWebInterceptor.java delete mode 100644 zheng-cms/zheng-cms-web/src/main/webapp/WEB-INF/jsp/index.jsp create mode 100644 zheng-ui/src/zheng-cms-web/article/index.html create mode 100644 zheng-ui/src/zheng-cms-web/blog/index.html create mode 100644 zheng-ui/src/zheng-cms-web/category/index.html delete mode 100644 zheng-ui/src/zheng-cms-web/inc/footer.jsp delete mode 100644 zheng-ui/src/zheng-cms-web/inc/head.jsp create mode 100644 zheng-ui/src/zheng-cms-web/news/index.html create mode 100644 zheng-ui/src/zheng-cms-web/page/index.html create mode 100644 zheng-ui/src/zheng-cms-web/qa/index.html create mode 100644 zheng-ui/src/zheng-cms-web/search/index.html create mode 100644 zheng-ui/src/zheng-cms-web/tag/index.html create mode 100644 zheng-ui/src/zheng-cms-web/topic/index.html create mode 100644 zheng-ui/src/zheng-cms-web/topic/list.html diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/ArticleController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/ArticleController.java new file mode 100644 index 00000000..baf35362 --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/ArticleController.java @@ -0,0 +1,35 @@ +package com.zheng.cms.web.controller; + +import com.zheng.cms.dao.model.CmsArticle; +import com.zheng.cms.rpc.api.CmsArticleService; +import com.zheng.common.base.BaseController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * 文章控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/article") +public class ArticleController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(ArticleController.class); + + @Autowired + private CmsArticleService cmsArticleService; + + @RequestMapping(value = "/{articleId}", method = RequestMethod.GET) + public String index(@PathVariable("articleId") int articleId, Model model) { + CmsArticle article = cmsArticleService.selectByPrimaryKey(articleId); + model.addAttribute("article", article); + return thymeleaf("/article/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/BlogController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/BlogController.java new file mode 100644 index 00000000..09cb6ec5 --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/BlogController.java @@ -0,0 +1,26 @@ +package com.zheng.cms.web.controller; + +import com.zheng.common.base.BaseController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * 博客首页控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/blog") +public class BlogController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(BlogController.class); + + @RequestMapping(value = "", method = RequestMethod.GET) + public String index(Model model) { + return thymeleaf("/blog/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/CategoryController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/CategoryController.java new file mode 100644 index 00000000..15642a8f --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/CategoryController.java @@ -0,0 +1,70 @@ +package com.zheng.cms.web.controller; + +import com.zheng.cms.dao.model.*; +import com.zheng.cms.rpc.api.*; +import com.zheng.common.base.BaseController; +import com.zheng.common.util.Paginator; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * 类目控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/category") +public class CategoryController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(CategoryController.class); + + @Autowired + private CmsCategoryService cmsCategoryService; + + @Autowired + private CmsArticleService cmsArticleService; + + @RequestMapping(value = "/{alias}", method = RequestMethod.GET) + public String index(@PathVariable("alias") String alias, + @RequestParam(required = false, defaultValue = "1", value = "page") int page, + @RequestParam(required = false, defaultValue = "orders", value = "sort") String sort, + @RequestParam(required = false, defaultValue = "desc", value = "order") String order, + HttpServletRequest request, + Model model) { + // 当前类目 + CmsCategoryExample cmsCategoryExample = new CmsCategoryExample(); + cmsCategoryExample.createCriteria() + .andAliasEqualTo(alias); + CmsCategory category = cmsCategoryService.selectFirstByExample(cmsCategoryExample); + model.addAttribute("category", category); + // 该类目文章列表 + int rows = 10; + CmsArticleExample cmsArticleExample = new CmsArticleExample(); + cmsArticleExample.createCriteria() + .andStatusEqualTo((byte) 1); + cmsArticleExample.setOffset((page - 1) * rows); + cmsArticleExample.setLimit(rows); + if (!StringUtils.isBlank(sort) && !StringUtils.isBlank(order)) { + cmsArticleExample.setOrderByClause(sort + " " + order); + } + List articles = cmsArticleService.selectByExample(cmsArticleExample); + model.addAttribute("articles", articles); + // 文章总数 + long total = cmsArticleService.countByExample(cmsArticleExample); + // 分页 + Paginator paginator = new Paginator(total, page, rows, request); + model.addAttribute("paginator", paginator); + return thymeleaf("/category/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/IndexController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/IndexController.java index c0c726b1..2fa03513 100644 --- a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/IndexController.java +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/IndexController.java @@ -1,9 +1,7 @@ package com.zheng.cms.web.controller; import com.zheng.cms.dao.model.*; -import com.zheng.cms.rpc.api.CmsCategoryService; -import com.zheng.cms.rpc.api.CmsMenuService; -import com.zheng.cms.rpc.api.CmsTagService; +import com.zheng.cms.rpc.api.*; import com.zheng.common.base.BaseController; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,35 +20,57 @@ import java.util.List; @Controller public class IndexController extends BaseController { - private static Logger _log = LoggerFactory.getLogger(IndexController.class); + private static Logger _log = LoggerFactory.getLogger(IndexController.class); - @Autowired - private CmsMenuService cmsMenuService; + @Autowired + private CmsMenuService cmsMenuService; - @Autowired - private CmsCategoryService cmsCategoryService; + @Autowired + private CmsCategoryService cmsCategoryService; - @Autowired - private CmsTagService cmsTagService; + @Autowired + private CmsTagService cmsTagService; - @RequestMapping(value = "", method = RequestMethod.GET) - public String index(Model model) { - // 菜单 - CmsMenuExample cmsMenuExample = new CmsMenuExample(); - cmsMenuExample.setOrderByClause("orders asc"); - List menus = cmsMenuService.selectByExample(cmsMenuExample); - model.addAttribute("menus", menus); - // 所有分类 - CmsCategoryExample cmsCategoryExample = new CmsCategoryExample(); - cmsCategoryExample.setOrderByClause("orders asc"); - List categories = cmsCategoryService.selectByExample(cmsCategoryExample); - model.addAttribute("categories", categories); - // 所有标签 - CmsTagExample cmsTagExample = new CmsTagExample(); - cmsTagExample.setOrderByClause("orders asc"); - List tags = cmsTagService.selectByExample(cmsTagExample); - model.addAttribute("tags", tags); - return thymeleaf("/index"); - } + @Autowired + private CmsTopicService cmsTopicService; + + @Autowired + private CmsArticleService cmsArticleService; + + @RequestMapping(value = "", method = RequestMethod.GET) + public String index(Model model) { + // 菜单 + CmsMenuExample cmsMenuExample = new CmsMenuExample(); + cmsMenuExample.setOrderByClause("orders asc"); + List menus = cmsMenuService.selectByExample(cmsMenuExample); + model.addAttribute("menus", menus); + // 所有类目 + CmsCategoryExample cmsCategoryExample = new CmsCategoryExample(); + cmsCategoryExample.setOrderByClause("orders asc"); + List categories = cmsCategoryService.selectByExample(cmsCategoryExample); + model.addAttribute("categories", categories); + // 所有标签 + CmsTagExample cmsTagExample = new CmsTagExample(); + cmsTagExample.setOrderByClause("orders asc"); + List tags = cmsTagService.selectByExample(cmsTagExample); + model.addAttribute("tags", tags); + // 最新5个专题 + CmsTopicExample cmsTopicExample = new CmsTopicExample(); + cmsTopicExample.setOrderByClause("ctime desc"); + List topics = cmsTopicService.selectByExample(cmsTopicExample); + model.addAttribute("topics", topics); + // 最新5条文章 + CmsArticleExample cmsArticleExample = new CmsArticleExample(); + cmsArticleExample.createCriteria() + .andStatusEqualTo((byte) 1); + cmsArticleExample.setOrderByClause("orders desc"); + List newArticles = cmsArticleService.selectByExample(cmsArticleExample); + model.addAttribute("newArticles", newArticles); + // 最火5条文章 + cmsArticleExample.setOrderByClause("readnumber desc"); + List hotArticles = cmsArticleService.selectByExample(cmsArticleExample); + model.addAttribute("hotArticles", hotArticles); + return thymeleaf("/index"); + } } \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/NewsController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/NewsController.java new file mode 100644 index 00000000..30b675c6 --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/NewsController.java @@ -0,0 +1,26 @@ +package com.zheng.cms.web.controller; + +import com.zheng.common.base.BaseController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * 资讯首页控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/news") +public class NewsController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(NewsController.class); + + @RequestMapping(value = "", method = RequestMethod.GET) + public String index(Model model) { + return thymeleaf("/news/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/PageController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/PageController.java new file mode 100644 index 00000000..6d7a2964 --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/PageController.java @@ -0,0 +1,39 @@ +package com.zheng.cms.web.controller; + +import com.zheng.cms.dao.model.CmsPage; +import com.zheng.cms.dao.model.CmsPageExample; +import com.zheng.cms.rpc.api.CmsPageService; +import com.zheng.common.base.BaseController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * 单页控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/page") +public class PageController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(PageController.class); + + @Autowired + private CmsPageService cmsPageService; + + @RequestMapping(value = "/{alias}", method = RequestMethod.GET) + public String index(@PathVariable("alias") String alias, Model model) { + CmsPageExample cmsPageExample = new CmsPageExample(); + cmsPageExample.createCriteria() + .andAliasEqualTo(alias); + CmsPage page = cmsPageService.selectFirstByExampleWithBLOBs(cmsPageExample); + model.addAttribute("page", page); + return thymeleaf("/page/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/QaController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/QaController.java new file mode 100644 index 00000000..12612deb --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/QaController.java @@ -0,0 +1,26 @@ +package com.zheng.cms.web.controller; + +import com.zheng.common.base.BaseController; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * 问答首页控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/qa") +public class QaController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(QaController.class); + + @RequestMapping(value = "", method = RequestMethod.GET) + public String index(Model model) { + return thymeleaf("/qa/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/SearchController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/SearchController.java new file mode 100644 index 00000000..bcab3d03 --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/SearchController.java @@ -0,0 +1,66 @@ +package com.zheng.cms.web.controller; + +import com.zheng.cms.dao.model.CmsArticle; +import com.zheng.cms.dao.model.CmsArticleExample; +import com.zheng.cms.dao.model.CmsTag; +import com.zheng.cms.dao.model.CmsTagExample; +import com.zheng.cms.rpc.api.CmsArticleService; +import com.zheng.cms.rpc.api.CmsTagService; +import com.zheng.common.base.BaseController; +import com.zheng.common.util.Paginator; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * 搜索控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/search") +public class SearchController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(SearchController.class); + + @Autowired + private CmsArticleService cmsArticleService; + + @RequestMapping(value = "/{keyword}", method = RequestMethod.GET) + public String index(@PathVariable("keyword") String keyword, + @RequestParam(required = false, defaultValue = "1", value = "page") int page, + @RequestParam(required = false, defaultValue = "orders", value = "sort") String sort, + @RequestParam(required = false, defaultValue = "desc", value = "order") String order, + HttpServletRequest request, + Model model) { + // 该关键字文章列表 + int rows = 10; + CmsArticleExample cmsArticleExample = new CmsArticleExample(); + cmsArticleExample.createCriteria() + .andStatusEqualTo((byte) 1) + .andTitleLike(keyword); + cmsArticleExample.setOffset((page - 1) * rows); + cmsArticleExample.setLimit(rows); + if (!StringUtils.isBlank(sort) && !StringUtils.isBlank(order)) { + cmsArticleExample.setOrderByClause(sort + " " + order); + } + List articles = cmsArticleService.selectByExample(cmsArticleExample); + model.addAttribute("articles", articles); + // 文章总数 + long total = cmsArticleService.countByExample(cmsArticleExample); + // 分页 + Paginator paginator = new Paginator(total, page, rows, request); + model.addAttribute("paginator", paginator); + return thymeleaf("/search/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TagController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TagController.java new file mode 100644 index 00000000..ed048e5a --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TagController.java @@ -0,0 +1,73 @@ +package com.zheng.cms.web.controller; + +import com.zheng.cms.dao.model.*; +import com.zheng.cms.rpc.api.CmsArticleService; +import com.zheng.cms.rpc.api.CmsCategoryService; +import com.zheng.cms.rpc.api.CmsTagService; +import com.zheng.cms.rpc.api.CmsTopicService; +import com.zheng.common.base.BaseController; +import com.zheng.common.util.Paginator; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * 标签控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/tag") +public class TagController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(TagController.class); + + @Autowired + private CmsTagService cmsTagService; + + @Autowired + private CmsArticleService cmsArticleService; + + @RequestMapping(value = "/{alias}", method = RequestMethod.GET) + public String index(@PathVariable("alias") String alias, + @RequestParam(required = false, defaultValue = "1", value = "page") int page, + @RequestParam(required = false, defaultValue = "orders", value = "sort") String sort, + @RequestParam(required = false, defaultValue = "desc", value = "order") String order, + HttpServletRequest request, + Model model) { + // 当前标签 + CmsTagExample cmsTagExample = new CmsTagExample(); + cmsTagExample.createCriteria() + .andAliasEqualTo(alias); + CmsTag tag = cmsTagService.selectFirstByExample(cmsTagExample); + model.addAttribute("tag", tag); + // 该标签文章列表 + int rows = 10; + CmsArticleExample cmsArticleExample = new CmsArticleExample(); + cmsArticleExample.createCriteria() + .andStatusEqualTo((byte) 1); + cmsArticleExample.setOffset((page - 1) * rows); + cmsArticleExample.setLimit(rows); + if (!StringUtils.isBlank(sort) && !StringUtils.isBlank(order)) { + cmsArticleExample.setOrderByClause(sort + " " + order); + } + List articles = cmsArticleService.selectByExample(cmsArticleExample); + model.addAttribute("articles", articles); + // 文章总数 + long total = cmsArticleService.countByExample(cmsArticleExample); + // 分页 + Paginator paginator = new Paginator(total, page, rows, request); + model.addAttribute("paginator", paginator); + return thymeleaf("/tag/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TopicController.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TopicController.java new file mode 100644 index 00000000..f4e4e772 --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/controller/TopicController.java @@ -0,0 +1,61 @@ +package com.zheng.cms.web.controller; + +import com.zheng.cms.dao.model.CmsTopic; +import com.zheng.cms.dao.model.CmsTopicExample; +import com.zheng.cms.rpc.api.CmsTopicService; +import com.zheng.common.base.BaseController; +import com.zheng.common.util.Paginator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * 专题首页控制器 + * Created by shuzheng on 2017/3/26. + */ +@Controller +@RequestMapping(value = "/topic") +public class TopicController extends BaseController { + + private static Logger _log = LoggerFactory.getLogger(TopicController.class); + + @Autowired + private CmsTopicService cmsTopicService; + + @RequestMapping(value = "/list", method = RequestMethod.GET) + public String list( + @RequestParam(required = false, defaultValue = "1", value = "page") int page, + HttpServletRequest request, + Model model) { + // 专题列表 + int rows = 10; + CmsTopicExample cmsTopicExample = new CmsTopicExample(); + cmsTopicExample.setOffset((page - 1) * rows); + cmsTopicExample.setLimit(rows); + List topics = cmsTopicService.selectByExample(cmsTopicExample); + model.addAttribute("topics", topics); + // 文章总数 + long total = cmsTopicService.countByExample(cmsTopicExample); + // 分页 + Paginator paginator = new Paginator(total, page, rows, request); + model.addAttribute("paginator", paginator); + return thymeleaf("/topic/list"); + } + + @RequestMapping(value = "{topicId}", method = RequestMethod.GET) + public String index(@PathVariable("topicId") int topicId, Model model) { + CmsTopic topic = cmsTopicService.selectByPrimaryKey(topicId); + model.addAttribute("topic", topic); + return thymeleaf("/topic/index"); + } + +} \ No newline at end of file diff --git a/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/interceptor/CmsWebInterceptor.java b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/interceptor/CmsWebInterceptor.java new file mode 100644 index 00000000..fd6bf38e --- /dev/null +++ b/zheng-cms/zheng-cms-web/src/main/java/com/zheng/cms/web/interceptor/CmsWebInterceptor.java @@ -0,0 +1,62 @@ +package com.zheng.cms.web.interceptor; + +import com.zheng.cms.dao.model.CmsMenu; +import com.zheng.cms.dao.model.CmsMenuExample; +import com.zheng.cms.rpc.api.CmsMenuService; +import com.zheng.common.util.PropertiesFileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 公共拦截器 + * Created by shuzheng on 2017/3/25. + */ +public class CmsWebInterceptor extends HandlerInterceptorAdapter { + + private static Logger _log = LoggerFactory.getLogger(CmsWebInterceptor.class); + + @Autowired + private CmsMenuService cmsMenuService; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + // 过滤ajax + if (null != request.getHeader("X-Requested-With") && request.getHeader("X-Requested-With").equalsIgnoreCase("XMLHttpRequest")) { + return true; + } + // zheng-ui静态资源配置信息 + String appName = PropertiesFileUtil.getInstance().get("app.name"); + String uiPath = PropertiesFileUtil.getInstance().get("zheng-ui.path"); + request.setAttribute("appName", appName); + request.setAttribute("uiPath", uiPath); + // 菜单 + CmsMenuExample cmsMenuExample = new CmsMenuExample(); + cmsMenuExample.setOrderByClause("orders asc"); + List menus = cmsMenuService.selectByExample(cmsMenuExample); + request.setAttribute("menus", menus); + return true; + } + + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { + super.postHandle(request, response, handler, modelAndView); + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { + super.afterCompletion(request, response, handler, ex); + } + + @Override + public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + super.afterConcurrentHandlingStarted(request, response, handler); + } + +} diff --git a/zheng-cms/zheng-cms-web/src/main/resources/springMVC-servlet.xml b/zheng-cms/zheng-cms-web/src/main/resources/springMVC-servlet.xml index 490ef006..9d328c36 100644 --- a/zheng-cms/zheng-cms-web/src/main/resources/springMVC-servlet.xml +++ b/zheng-cms/zheng-cms-web/src/main/resources/springMVC-servlet.xml @@ -11,6 +11,15 @@ + + + + + + + + + diff --git a/zheng-cms/zheng-cms-web/src/main/webapp/WEB-INF/jsp/index.jsp b/zheng-cms/zheng-cms-web/src/main/webapp/WEB-INF/jsp/index.jsp deleted file mode 100644 index 372ac2cd..00000000 --- a/zheng-cms/zheng-cms-web/src/main/webapp/WEB-INF/jsp/index.jsp +++ /dev/null @@ -1,151 +0,0 @@ -<%@ page contentType="text/html; charset=utf-8"%> -<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> -<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> - - - - - - 首页 - ZhengCms - - - - - - - - - - - - - - - - -
-
-
所有类目
- -
${category.name}
-
-
-
-
所有标签
- -
${tag.name}
-
-
-
- - -
-
-
-
- -
-
- -
-
- -
-
- -
-
-
-
- - - - - - \ No newline at end of file diff --git a/zheng-ui/src/zheng-cms-web/article/index.html b/zheng-ui/src/zheng-cms-web/article/index.html new file mode 100644 index 00000000..bb6b6cb1 --- /dev/null +++ b/zheng-ui/src/zheng-cms-web/article/index.html @@ -0,0 +1,106 @@ + + + + + 标题 - ZhengCms + + + + + + + + + + + + + + + + +
+

标题

+
内容
+
+ + +
+ Copyright © 2017 ZhangShuzheng All Rights Reserved +
+ + + + + + \ No newline at end of file diff --git a/zheng-ui/src/zheng-cms-web/blog/index.html b/zheng-ui/src/zheng-cms-web/blog/index.html new file mode 100644 index 00000000..b9d581ce --- /dev/null +++ b/zheng-ui/src/zheng-cms-web/blog/index.html @@ -0,0 +1,105 @@ + + + + + 博客首页 - ZhengCms + + + + + + + + + + + + + + + + +
+ 博客首页 +
+ + +
+ Copyright © 2017 ZhangShuzheng All Rights Reserved +
+ + + + + + \ No newline at end of file diff --git a/zheng-ui/src/zheng-cms-web/category/index.html b/zheng-ui/src/zheng-cms-web/category/index.html new file mode 100644 index 00000000..33b35e13 --- /dev/null +++ b/zheng-ui/src/zheng-cms-web/category/index.html @@ -0,0 +1,109 @@ + + + + + 类目 - ZhengCms + + + + + + + + + + + + + + + + +
+
+
类目文章列表
+
文章标题
+
+
+
+ + +
+ Copyright © 2017 ZhangShuzheng All Rights Reserved +
+ + + + + + \ No newline at end of file diff --git a/zheng-ui/src/zheng-cms-web/inc/footer.jsp b/zheng-ui/src/zheng-cms-web/inc/footer.jsp deleted file mode 100644 index b0aa9c33..00000000 --- a/zheng-ui/src/zheng-cms-web/inc/footer.jsp +++ /dev/null @@ -1,8 +0,0 @@ -<%@ page contentType="text/html; charset=utf-8"%> -<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> -<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> - - \ No newline at end of file diff --git a/zheng-ui/src/zheng-cms-web/inc/head.jsp b/zheng-ui/src/zheng-cms-web/inc/head.jsp deleted file mode 100644 index bcac6026..00000000 --- a/zheng-ui/src/zheng-cms-web/inc/head.jsp +++ /dev/null @@ -1,7 +0,0 @@ -<%@ page contentType="text/html; charset=utf-8"%> -<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> -<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> - \ No newline at end of file diff --git a/zheng-ui/src/zheng-cms-web/index.html b/zheng-ui/src/zheng-cms-web/index.html index 4beb5880..b5adfc84 100644 --- a/zheng-ui/src/zheng-cms-web/index.html +++ b/zheng-ui/src/zheng-cms-web/index.html @@ -8,16 +8,16 @@ - - + + - + @@ -38,20 +38,7 @@