|
@@ -3,8 +3,11 @@ package ${package.Controller};
|
3
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
4
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
|
-import ${package.Parent}.common.ResponseBean;
|
7
|
|
-import ${package.Parent}.common.BaseController;
|
|
6
|
+import ${superControllerClassPackage};
|
|
7
|
+import ${cfg.ResponseClassPackage};
|
|
8
|
+import io.swagger.annotations.Api;
|
|
9
|
+import io.swagger.annotations.ApiOperation;
|
|
10
|
+import io.swagger.annotations.ApiParam;
|
8
|
11
|
import org.slf4j.Logger;
|
9
|
12
|
import org.slf4j.LoggerFactory;
|
10
|
13
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -13,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
13
|
16
|
import org.springframework.web.bind.annotation.RequestMapping;
|
14
|
17
|
import org.springframework.web.bind.annotation.RequestMethod;
|
15
|
18
|
import org.springframework.web.bind.annotation.RequestParam;
|
16
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
17
|
19
|
import ${package.Service}.${table.serviceName};
|
18
|
20
|
import ${package.Entity}.${table.entityName};
|
19
|
21
|
<#if restControllerStyle>
|
|
@@ -21,9 +23,6 @@ import org.springframework.web.bind.annotation.RestController;
|
21
|
23
|
<#else>
|
22
|
24
|
import org.springframework.stereotype.Controller;
|
23
|
25
|
</#if>
|
24
|
|
-<#if superControllerClassPackage??>
|
25
|
|
-import ${superControllerClassPackage};
|
26
|
|
-</#if>
|
27
|
26
|
|
28
|
27
|
/**
|
29
|
28
|
* <p>
|
|
@@ -63,8 +62,8 @@ public class ${table.controllerName} {
|
63
|
62
|
* @return
|
64
|
63
|
*/
|
65
|
64
|
@RequestMapping(value="/${table.entityPath}",method= RequestMethod.GET)
|
66
|
|
- @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
67
|
|
- public ResponseBean ${table.entityPath}List(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
65
|
+ @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ${cfg.ResponseClass}.class)
|
|
66
|
+ public ${cfg.ResponseClass} ${table.entityPath}List(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
68
|
67
|
@ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
69
|
68
|
|
70
|
69
|
IPage<${entity}> pg = new Page<>(pageNum, pageSize);
|
|
@@ -81,13 +80,13 @@ public class ${table.controllerName} {
|
81
|
80
|
* @return
|
82
|
81
|
*/
|
83
|
82
|
@RequestMapping(value="/${table.entityPath}",method= RequestMethod.POST)
|
84
|
|
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
85
|
|
- public ResponseBean ${table.entityPath}Add(@ApiParam("保存内容") @RequestBody ${entity} ${table.entityPath}) throws Exception{
|
|
83
|
+ @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ${cfg.ResponseClass}.class)
|
|
84
|
+ public ${cfg.ResponseClass} ${table.entityPath}Add(@ApiParam("保存内容") @RequestBody ${entity} ${table.entityPath}) throws Exception{
|
86
|
85
|
|
87
|
86
|
if (i${entity}Service.save(${table.entityPath})){
|
88
|
|
- return ResponseBean.success(${table.entityPath});
|
|
87
|
+ return ${cfg.ResponseClass}.success(${table.entityPath});
|
89
|
88
|
}else {
|
90
|
|
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
89
|
+ return ${cfg.ResponseClass}.error("保存失败, 请重试", ${cfg.ResponseClass}.ERROR_UNAVAILABLE);
|
91
|
90
|
}
|
92
|
91
|
}
|
93
|
92
|
|
|
@@ -96,12 +95,12 @@ public class ${table.controllerName} {
|
96
|
95
|
* @param id 实体ID
|
97
|
96
|
*/
|
98
|
97
|
@RequestMapping(value="/${table.entityPath}/{id}", method= RequestMethod.DELETE)
|
99
|
|
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
100
|
|
- public ResponseBean ${table.entityPath}Delete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
98
|
+ @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ${cfg.ResponseClass}.class)
|
|
99
|
+ public ${cfg.ResponseClass} ${table.entityPath}Delete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
101
|
100
|
if(i${entity}Service.removeById(id)){
|
102
|
|
- return ResponseBean.success("success");
|
|
101
|
+ return ${cfg.ResponseClass}.success("success");
|
103
|
102
|
}else {
|
104
|
|
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
103
|
+ return ${cfg.ResponseClass}.error("删除失败, 请重试", ${cfg.ResponseClass}.ERROR_UNAVAILABLE);
|
105
|
104
|
}
|
106
|
105
|
}
|
107
|
106
|
|
|
@@ -112,14 +111,14 @@ public class ${table.controllerName} {
|
112
|
111
|
* @return
|
113
|
112
|
*/
|
114
|
113
|
@RequestMapping(value="/${table.entityPath}/{id}",method= RequestMethod.PUT)
|
115
|
|
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
116
|
|
- public ResponseBean ${table.entityPath}Update(@ApiParam("对象ID") @PathVariable Integer id,
|
|
114
|
+ @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ${cfg.ResponseClass}.class)
|
|
115
|
+ public ${cfg.ResponseClass} ${table.entityPath}Update(@ApiParam("对象ID") @PathVariable Integer id,
|
117
|
116
|
@ApiParam("更新内容") @RequestBody ${entity} ${table.entityPath}) throws Exception{
|
118
|
117
|
|
119
|
118
|
if (i${entity}Service.updateById(${table.entityPath})){
|
120
|
|
- return ResponseBean.success(i${entity}Service.getById(id));
|
|
119
|
+ return ${cfg.ResponseClass}.success(i${entity}Service.getById(id));
|
121
|
120
|
}else {
|
122
|
|
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
121
|
+ return ${cfg.ResponseClass}.error("修改失败, 请重试", ${cfg.ResponseClass}.ERROR_UNAVAILABLE);
|
123
|
122
|
}
|
124
|
123
|
}
|
125
|
124
|
|
|
@@ -128,9 +127,9 @@ public class ${table.controllerName} {
|
128
|
127
|
* @param id 实体ID
|
129
|
128
|
*/
|
130
|
129
|
@RequestMapping(value="/${table.entityPath}/{id}",method= RequestMethod.GET)
|
131
|
|
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
132
|
|
- public ResponseBean ${table.entityPath}Get(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
133
|
|
- return ResponseBean.success(i${entity}Service.getById(id));
|
|
130
|
+ @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ${cfg.ResponseClass}.class)
|
|
131
|
+ public ${cfg.ResponseClass} ${table.entityPath}Get(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
132
|
+ return ${cfg.ResponseClass}.success(i${entity}Service.getById(id));
|
134
|
133
|
}
|
135
|
134
|
}
|
136
|
135
|
</#if>
|