From 4fd5cd16bba7ff5c7d3f747a97658764e7f77c4d Mon Sep 17 00:00:00 2001
From: shuzheng <469741414@qq.com>
Date: Thu, 2 Feb 2017 19:34:37 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0controller=E7=9A=84swagger?=
=?UTF-8?q?=E6=8F=8F=E8=BF=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/controller/ManageController.java | 18 +++++++++++--
.../cms/admin/controller/UserController.java | 27 -------------------
.../manage/CmsArticleController.java | 11 +++++++-
.../manage/CmsCategoryController.java | 11 +++++---
.../manage/CmsCommentController.java | 11 +++++++-
.../controller/manage/CmsTagController.java | 18 +++++++++++--
.../src/main/webapp/WEB-INF/jsp/user/list.jsp | 17 ------------
.../controller/manage/SystemController.java | 5 +++-
8 files changed, 64 insertions(+), 54 deletions(-)
delete mode 100644 zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/UserController.java
delete mode 100644 zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/user/list.jsp
diff --git a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/ManageController.java b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/ManageController.java
index f3c3ccf6..b6849d3e 100644
--- a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/ManageController.java
+++ b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/ManageController.java
@@ -1,9 +1,12 @@
package com.zheng.cms.admin.controller;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
/**
* 后台controller
@@ -11,16 +14,27 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
@RequestMapping("/manage")
+@Api(value = "后台控制器")
public class ManageController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(ManageController.class);
- @RequestMapping(value = {"", "/index"})
+ /**
+ * 后台首页
+ * @return
+ */
+ @ApiOperation(value = "后台首页")
+ @RequestMapping(value = {"", "/index"}, method = RequestMethod.GET)
public String index() {
return "/manage/index";
}
- @RequestMapping("/login")
+ /**
+ * 后台登录页
+ * @return
+ */
+ @ApiOperation(value = "后台登录页")
+ @RequestMapping(value = "/login", method = RequestMethod.GET)
public String login() {
return "/manage/login";
}
diff --git a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/UserController.java b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/UserController.java
deleted file mode 100644
index 4be4e10d..00000000
--- a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/UserController.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.zheng.cms.admin.controller;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * 用户管理
- * Created by shuzheng on 2016/12/10.
- */
-@Controller
-@RequestMapping("/manage/user")
-public class UserController extends BaseController {
-
- private static Logger _log = LoggerFactory.getLogger(UserController.class);
-
- /**
- * 列表
- * @return
- */
- @RequestMapping("/list")
- public String index() {
- return "/user/list";
- }
-
-}
\ No newline at end of file
diff --git a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsArticleController.java b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsArticleController.java
index f1ba4eaa..2615cdff 100644
--- a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsArticleController.java
+++ b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsArticleController.java
@@ -5,6 +5,8 @@ import com.zheng.cms.dao.model.CmsArticle;
import com.zheng.cms.dao.model.CmsArticleExample;
import com.zheng.cms.rpc.api.CmsArticleService;
import com.zheng.common.util.Paginator;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +26,7 @@ import java.util.List;
*/
@Controller
@RequestMapping("/manage/article")
+@Api(value = "文章控制器")
public class CmsArticleController extends BaseController {
private final static Logger _log = LoggerFactory.getLogger(CmsArticleController.class);
@@ -40,7 +43,8 @@ public class CmsArticleController extends BaseController {
* @param modelMap
* @return
*/
- @RequestMapping("/list")
+ @ApiOperation(value = "文章列表", notes = "获取文章列表并分页")
+ @RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(
@RequestParam(required = false, defaultValue = "1", value = "page") int page,
@RequestParam(required = false, defaultValue = "20", value = "rows") int rows,
@@ -67,6 +71,7 @@ public class CmsArticleController extends BaseController {
* 新增get
* @return
*/
+ @ApiOperation(value = "新增文章", notes = "新增文章页")
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add() {
return "/manage/article/add";
@@ -78,6 +83,7 @@ public class CmsArticleController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "新增文章", notes = "新增文章提交接口")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(CmsArticle cmsArticle, ModelMap modelMap) {
long time = System.currentTimeMillis();
@@ -95,6 +101,7 @@ public class CmsArticleController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "删除文章", notes = "批量删除文章")
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
public String delete(@PathVariable("ids") String ids, ModelMap modelMap) {
int count = cmsArticleService.deleteByPrimaryKeys(ids);
@@ -108,6 +115,7 @@ public class CmsArticleController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改文章", notes = "根据id修改文章页")
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
public String update(@PathVariable("id") int id, ModelMap modelMap) {
CmsArticle article = cmsArticleService.selectByPrimaryKey(id);
@@ -122,6 +130,7 @@ public class CmsArticleController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改文章", notes = "根据id修改文章提交接口")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
public String update(@PathVariable("id") int id, CmsArticle cmsArticle, ModelMap modelMap) {
int count = cmsArticleService.updateByPrimaryKeySelective(cmsArticle);
diff --git a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCategoryController.java b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCategoryController.java
index 7e1b2acf..b0abfa8c 100644
--- a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCategoryController.java
+++ b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCategoryController.java
@@ -5,6 +5,7 @@ import com.zheng.cms.dao.model.CmsCategory;
import com.zheng.cms.dao.model.CmsCategoryExample;
import com.zheng.cms.rpc.api.CmsCategoryService;
import com.zheng.common.util.Paginator;
+import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@@ -26,6 +27,7 @@ import java.util.List;
*/
@Controller
@RequestMapping("/manage/category")
+@Api(value = "类目控制器")
public class CmsCategoryController extends BaseController {
private final static Logger _log = LoggerFactory.getLogger(CmsCategoryController.class);
@@ -43,7 +45,7 @@ public class CmsCategoryController extends BaseController {
* @return
*/
@ApiOperation(value = "类目列表", notes = "获取类目列表并分页")
- @RequestMapping("/list")
+ @RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(
@RequestParam(required = false, defaultValue = "1", value = "page") int page,
@RequestParam(required = false, defaultValue = "20", value = "rows") int rows,
@@ -70,6 +72,7 @@ public class CmsCategoryController extends BaseController {
* 新增get
* @return
*/
+ @ApiOperation(value = "新增类目", notes = "新增类目页")
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add() {
return "/manage/category/add";
@@ -81,9 +84,8 @@ public class CmsCategoryController extends BaseController {
* @param modelMap
* @return
*/
- @ApiOperation(value = "创建类目", notes = "根据CmsCategory对象创建类目")
+ @ApiOperation(value = "新增类目", notes = "新增类目提交接口")
@ApiImplicitParam(name = "cmsCategory", value = "类目实体cmsCategory", required = true, dataType = "CmsCategory")
-
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(CmsCategory cmsCategory, ModelMap modelMap) {
long time = System.currentTimeMillis();
@@ -101,6 +103,7 @@ public class CmsCategoryController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "删除类目", notes = "批量删除类目")
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
public String delete(@PathVariable("ids") String ids, ModelMap modelMap) {
int count = cmsCategoryService.deleteByPrimaryKeys(ids);
@@ -114,6 +117,7 @@ public class CmsCategoryController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改类目", notes = "根据id修改类目页")
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
public String update(@PathVariable("id") int id, ModelMap modelMap) {
CmsCategory category = cmsCategoryService.selectByPrimaryKey(id);
@@ -128,6 +132,7 @@ public class CmsCategoryController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改类目", notes = "根据id修改类目提交接口")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
public String update(@PathVariable("id") int id, CmsCategory cmsCategory, ModelMap modelMap) {
int count = cmsCategoryService.updateByPrimaryKeySelective(cmsCategory);
diff --git a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCommentController.java b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCommentController.java
index 13158af7..c058dbaa 100644
--- a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCommentController.java
+++ b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsCommentController.java
@@ -5,6 +5,8 @@ import com.zheng.cms.dao.model.CmsComment;
import com.zheng.cms.dao.model.CmsCommentExample;
import com.zheng.cms.rpc.api.CmsCommentService;
import com.zheng.common.util.Paginator;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +26,7 @@ import java.util.List;
*/
@Controller
@RequestMapping("/manage/comment")
+@Api(value = "评论控制器")
public class CmsCommentController extends BaseController {
private final static Logger _log = LoggerFactory.getLogger(CmsCommentController.class);
@@ -40,7 +43,8 @@ public class CmsCommentController extends BaseController {
* @param modelMap
* @return
*/
- @RequestMapping("/list")
+ @ApiOperation(value = "评论列表", notes = "获取评论列表并分页")
+ @RequestMapping(value = "/list", method = RequestMethod.GET)
public String list(
@RequestParam(required = false, defaultValue = "1", value = "page") int page,
@RequestParam(required = false, defaultValue = "20", value = "rows") int rows,
@@ -67,6 +71,7 @@ public class CmsCommentController extends BaseController {
* 新增get
* @return
*/
+ @ApiOperation(value = "新增评论", notes = "新增评论页")
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add() {
return "/manage/comment/add";
@@ -78,6 +83,7 @@ public class CmsCommentController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "新增评论", notes = "新增评论提交接口")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(CmsComment cmsComment, ModelMap modelMap) {
cmsComment.setCtime(System.currentTimeMillis());
@@ -93,6 +99,7 @@ public class CmsCommentController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "删除评论", notes = "批量删除评论")
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
public String delete(@PathVariable("ids") String ids, ModelMap modelMap) {
int count = cmsCommentService.deleteByPrimaryKeys(ids);
@@ -106,6 +113,7 @@ public class CmsCommentController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改评论", notes = "根据id修改评论页")
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
public String update(@PathVariable("id") int id, ModelMap modelMap) {
CmsComment comment = cmsCommentService.selectByPrimaryKey(id);
@@ -120,6 +128,7 @@ public class CmsCommentController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改评论", notes = "根据id修改评论提交接口")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
public String update(@PathVariable("id") int id, CmsComment cmsComment, ModelMap modelMap) {
int count = cmsCommentService.updateByPrimaryKeySelective(cmsComment);
diff --git a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsTagController.java b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsTagController.java
index 9b86b0b3..7dbd32b1 100644
--- a/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsTagController.java
+++ b/zheng-cms/zheng-cms-admin/src/main/java/com/zheng/cms/admin/controller/manage/CmsTagController.java
@@ -4,6 +4,8 @@ import com.zheng.cms.admin.controller.BaseController;
import com.zheng.cms.dao.model.CmsTag;
import com.zheng.cms.dao.model.CmsTagExample;
import com.zheng.cms.rpc.api.CmsTagService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +22,7 @@ import java.util.List;
*/
@Controller
@RequestMapping("/manage/tag")
+@Api(value = "标签控制器")
public class CmsTagController extends BaseController {
private final static Logger _log = LoggerFactory.getLogger(CmsTagController.class);
@@ -27,7 +30,12 @@ public class CmsTagController extends BaseController {
@Autowired
private CmsTagService cmsTagService;
- @RequestMapping("/index")
+ /**
+ * 首页
+ * @return
+ */
+ @ApiOperation(value = "评论首页", notes = "获取评论列表首页")
+ @RequestMapping(value = "/index", method = RequestMethod.GET)
public String index() {
return "/manage/tag/index";
}
@@ -40,7 +48,8 @@ public class CmsTagController extends BaseController {
* @param order
* @return
*/
- @RequestMapping("/list")
+ @ApiOperation(value = "评论列表", notes = "获取评论列表并分页")
+ @RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(
@RequestParam(required = false, defaultValue = "0", value = "offset") int offset,
@@ -66,6 +75,7 @@ public class CmsTagController extends BaseController {
* 新增get
* @return
*/
+ @ApiOperation(value = "新增标签", notes = "新增标签页")
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String add() {
return "/manage/tag/add";
@@ -77,6 +87,7 @@ public class CmsTagController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "新增标签", notes = "新增标签提交接口")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String add(CmsTag cmsTag, ModelMap modelMap) {
long time = System.currentTimeMillis();
@@ -94,6 +105,7 @@ public class CmsTagController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "删除标签", notes = "批量删除标签")
@RequestMapping(value = "/delete/{ids}",method = RequestMethod.GET)
public String delete(@PathVariable("ids") String ids, ModelMap modelMap) {
int count = cmsTagService.deleteByPrimaryKeys(ids);
@@ -107,6 +119,7 @@ public class CmsTagController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改标签", notes = "根据id修改标签页")
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
public String update(@PathVariable("id") int id, ModelMap modelMap) {
CmsTag tag = cmsTagService.selectByPrimaryKey(id);
@@ -121,6 +134,7 @@ public class CmsTagController extends BaseController {
* @param modelMap
* @return
*/
+ @ApiOperation(value = "修改标签", notes = "根据id修改标签提交接口")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
public String update(@PathVariable("id") int id, CmsTag cmsTag, ModelMap modelMap) {
int count = cmsTagService.updateByPrimaryKeySelective(cmsTag);
diff --git a/zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/user/list.jsp b/zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/user/list.jsp
deleted file mode 100644
index 271fec28..00000000
--- a/zheng-cms/zheng-cms-admin/src/main/webapp/WEB-INF/jsp/user/list.jsp
+++ /dev/null
@@ -1,17 +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"%>
-