|
@@ -49,25 +49,6 @@ public class TdSchoolController extends BaseController {
|
49
|
49
|
return ResponseBean.success(iTdSchoolService.list(queryWrapper));
|
50
|
50
|
}
|
51
|
51
|
|
52
|
|
-
|
53
|
|
- * 分页查询列表
|
54
|
|
- * @param pageNum
|
55
|
|
- * @param pageSize
|
56
|
|
- * @return
|
57
|
|
- */
|
58
|
|
- @RequestMapping(value="/tdSchool",method= RequestMethod.GET)
|
59
|
|
- @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
60
|
|
- public ResponseBean tdSchoolList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
61
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
62
|
|
-
|
63
|
|
- IPage<TdSchool> pg = new Page<>(pageNum, pageSize);
|
64
|
|
- QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<>();
|
65
|
|
- queryWrapper.orderByDesc("create_date");
|
66
|
|
-
|
67
|
|
- IPage<TdSchool> result = iTdSchoolService.page(pg, queryWrapper);
|
68
|
|
- return ResponseBean.success(result);
|
69
|
|
- }
|
70
|
|
-
|
71
|
52
|
|
72
|
53
|
* 分页查询列表
|
73
|
54
|
* @param pageNum
|
|
@@ -77,7 +58,7 @@ public class TdSchoolController extends BaseController {
|
77
|
58
|
@RequestMapping(value="/admin/school",method= RequestMethod.GET)
|
78
|
59
|
@ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
79
|
60
|
public ResponseBean schoolList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
80
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
61
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
81
|
62
|
@ApiParam("名称") @RequestParam(value = "name", required = false) String name,
|
82
|
63
|
@ApiParam("状态") @RequestParam(value = "status", required = false) String status) throws Exception{
|
83
|
64
|
|
|
@@ -85,6 +66,7 @@ public class TdSchoolController extends BaseController {
|
85
|
66
|
QueryWrapper<TdSchool> queryWrapper = new QueryWrapper<TdSchool>()
|
86
|
67
|
.like(!StringUtils.isEmpty(name), "name", name)
|
87
|
68
|
.eq(null != status, "status", status)
|
|
69
|
+ .gt("status", Constants.STATUS_DELETED)
|
88
|
70
|
.orderByDesc("create_date");
|
89
|
71
|
|
90
|
72
|
IPage<TdSchool> result = iTdSchoolService.page(pg, queryWrapper);
|
|
@@ -96,25 +78,18 @@ public class TdSchoolController extends BaseController {
|
96
|
78
|
* @param tdSchool 实体对象
|
97
|
79
|
* @return
|
98
|
80
|
*/
|
99
|
|
- @RequestMapping(value="/tdSchool",method= RequestMethod.POST)
|
|
81
|
+ @RequestMapping(value="/admin/school",method= RequestMethod.POST)
|
100
|
82
|
@ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
101
|
|
- public ResponseBean tdSchoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
|
|
83
|
+ public ResponseBean schoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
|
102
|
84
|
|
103
|
|
- if (iTdSchoolService.save(tdSchool)){
|
104
|
|
- return ResponseBean.success(tdSchool);
|
105
|
|
- }else {
|
106
|
|
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
85
|
+ if (StringUtils.isEmpty(tdSchool.getName())) {
|
|
86
|
+ throw new Exception("学校名称不能为空");
|
107
|
87
|
}
|
108
|
|
- }
|
109
|
88
|
|
110
|
|
-
|
111
|
|
- * 保存对象
|
112
|
|
- * @param tdSchool 实体对象
|
113
|
|
- * @return
|
114
|
|
- */
|
115
|
|
- @RequestMapping(value="/admin/school",method= RequestMethod.POST)
|
116
|
|
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
117
|
|
- public ResponseBean schoolAdd(@ApiParam("保存内容") @RequestBody TdSchool tdSchool) throws Exception{
|
|
89
|
+ TdSchool exitSchool = iTdSchoolService.getByName(tdSchool.getName());
|
|
90
|
+ if (null != exitSchool) {
|
|
91
|
+ throw new Exception("学校名称已经存在");
|
|
92
|
+ }
|
118
|
93
|
|
119
|
94
|
if (iTdSchoolService.save(tdSchool)){
|
120
|
95
|
return ResponseBean.success(tdSchool);
|
|
@@ -123,20 +98,6 @@ public class TdSchoolController extends BaseController {
|
123
|
98
|
}
|
124
|
99
|
}
|
125
|
100
|
|
126
|
|
-
|
127
|
|
- * 根据id删除对象
|
128
|
|
- * @param id 实体ID
|
129
|
|
- */
|
130
|
|
- @RequestMapping(value="/tdSchool/{id}", method= RequestMethod.DELETE)
|
131
|
|
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
132
|
|
- public ResponseBean tdSchoolDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
133
|
|
- if(iTdSchoolService.removeById(id)){
|
134
|
|
- return ResponseBean.success("success");
|
135
|
|
- }else {
|
136
|
|
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
137
|
|
- }
|
138
|
|
- }
|
139
|
|
-
|
140
|
101
|
|
141
|
102
|
* 根据id删除对象
|
142
|
103
|
* @param id 实体ID
|
|
@@ -144,28 +105,17 @@ public class TdSchoolController extends BaseController {
|
144
|
105
|
@RequestMapping(value="/admin/school/{id}", method= RequestMethod.DELETE)
|
145
|
106
|
@ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
146
|
107
|
public ResponseBean schoolDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
147
|
|
- if(iTdSchoolService.removeById(id)){
|
|
108
|
+ TdSchool origin = iTdSchoolService.getById(id);
|
|
109
|
+ if (null == origin || Constants.STATUS_DELETED.equals(origin.getStatus())) {
|
148
|
110
|
return ResponseBean.success("success");
|
149
|
|
- }else {
|
150
|
|
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
151
|
111
|
}
|
152
|
|
- }
|
153
|
112
|
|
154
|
|
-
|
155
|
|
- * 修改对象
|
156
|
|
- * @param id 实体ID
|
157
|
|
- * @param tdSchool 实体对象
|
158
|
|
- * @return
|
159
|
|
- */
|
160
|
|
- @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.PUT)
|
161
|
|
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
162
|
|
- public ResponseBean tdSchoolUpdate(@ApiParam("对象ID") @PathVariable String id,
|
163
|
|
- @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
|
|
113
|
+ origin.setStatus(Constants.STATUS_DELETED);
|
164
|
114
|
|
165
|
|
- if (iTdSchoolService.updateById(tdSchool)){
|
166
|
|
- return ResponseBean.success(iTdSchoolService.getById(id));
|
|
115
|
+ if(iTdSchoolService.updateById(origin)){
|
|
116
|
+ return ResponseBean.success("success");
|
167
|
117
|
}else {
|
168
|
|
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
118
|
+ return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
169
|
119
|
}
|
170
|
120
|
}
|
171
|
121
|
|
|
@@ -178,7 +128,24 @@ public class TdSchoolController extends BaseController {
|
178
|
128
|
@RequestMapping(value="/admin/school/{id}",method= RequestMethod.PUT)
|
179
|
129
|
@ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
180
|
130
|
public ResponseBean schoolUpdate(@ApiParam("对象ID") @PathVariable String id,
|
181
|
|
- @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
|
|
131
|
+ @ApiParam("更新内容") @RequestBody TdSchool tdSchool) throws Exception{
|
|
132
|
+ TdSchool origin = iTdSchoolService.getById(id);
|
|
133
|
+ if (null == origin || Constants.STATUS_DELETED.equals(origin.getStatus())) {
|
|
134
|
+ throw new Exception("没有找到对应的学校信息");
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ if (!id.equals(tdSchool.getSchoolId())) {
|
|
138
|
+ throw new Exception("校验学校信息失败");
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ if (StringUtils.isEmpty(tdSchool.getName())) {
|
|
142
|
+ throw new Exception("学校名称不能为空");
|
|
143
|
+ }
|
|
144
|
+
|
|
145
|
+ TdSchool exitSchool = iTdSchoolService.getByName(tdSchool.getName());
|
|
146
|
+ if (null != exitSchool && !id.equals(exitSchool.getSchoolId())) {
|
|
147
|
+ throw new Exception("学校名称已经存在");
|
|
148
|
+ }
|
182
|
149
|
|
183
|
150
|
if (iTdSchoolService.updateById(tdSchool)){
|
184
|
151
|
return ResponseBean.success(iTdSchoolService.getById(id));
|
|
@@ -191,19 +158,14 @@ public class TdSchoolController extends BaseController {
|
191
|
158
|
* 根据id查询对象
|
192
|
159
|
* @param id 实体ID
|
193
|
160
|
*/
|
194
|
|
- @RequestMapping(value="/tdSchool/{id}",method= RequestMethod.GET)
|
|
161
|
+ @RequestMapping(value="/admin/school/{id}",method= RequestMethod.GET)
|
195
|
162
|
@ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
196
|
163
|
public ResponseBean tdSchoolGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
197
|
|
- return ResponseBean.success(iTdSchoolService.getById(id));
|
198
|
|
- }
|
|
164
|
+ TdSchool tdSchool = iTdSchoolService.getById(id);
|
|
165
|
+ if (null == tdSchool || Constants.STATUS_DELETED.equals(tdSchool.getStatus())) {
|
|
166
|
+ throw new Exception("学校信息不存在");
|
|
167
|
+ }
|
199
|
168
|
|
200
|
|
-
|
201
|
|
- * 根据id查询对象
|
202
|
|
- * @param id 实体ID
|
203
|
|
- */
|
204
|
|
- @RequestMapping(value="/admin/school/{id}",method= RequestMethod.GET)
|
205
|
|
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
206
|
|
- public ResponseBean schoolGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
207
|
|
- return ResponseBean.success(iTdSchoolService.getById(id));
|
|
169
|
+ return ResponseBean.success(tdSchool);
|
208
|
170
|
}
|
209
|
171
|
}
|