增加controller的swagger描述

This commit is contained in:
shuzheng 2017-02-02 19:34:37 +08:00
parent 51e054b956
commit 4fd5cd16bb
8 changed files with 64 additions and 54 deletions

View File

@ -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";
}

View File

@ -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";
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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"%>
<c:set var="basePath" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>列表</title>
</head>
<body>
/manage/user/list
</body>
</html>

View File

@ -10,8 +10,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import static com.sun.xml.internal.ws.api.message.Packet.Status.Request;
/**
* 系统controller
* Created by shuzheng on 2016/12/18.
@ -29,7 +32,7 @@ public class SystemController {
@ApiOperation(value = "系统首页")
@RequiresPermissions("upms.system.read")
//@RequiresUser
@RequestMapping("/index")
@RequestMapping(value = "/index", method = RequestMethod.GET)
public String index() {
return "/manage/system/index";
}