|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.yunzhi.demo.common.BaseController;
|
7
|
7
|
import com.yunzhi.demo.common.ResponseBean;
|
|
8
|
+import com.yunzhi.demo.common.StringUtils;
|
8
|
9
|
import com.yunzhi.demo.vo.SortParams;
|
9
|
10
|
import io.swagger.annotations.Api;
|
10
|
11
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -80,22 +81,6 @@ public class TaTopicController extends BaseController {
|
80
|
81
|
return ResponseBean.success(result);
|
81
|
82
|
}
|
82
|
83
|
|
83
|
|
- /**
|
84
|
|
- * 保存对象
|
85
|
|
- * @param taTopic 实体对象
|
86
|
|
- * @return
|
87
|
|
- */
|
88
|
|
- @RequestMapping(value="/taTopic",method= RequestMethod.POST)
|
89
|
|
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
90
|
|
- public ResponseBean taTopicAdd(@ApiParam("保存内容") @RequestBody TaTopic taTopic) throws Exception{
|
91
|
|
-
|
92
|
|
- if (iTaTopicService.save(taTopic)){
|
93
|
|
- return ResponseBean.success(taTopic);
|
94
|
|
- }else {
|
95
|
|
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
96
|
|
- }
|
97
|
|
- }
|
98
|
|
-
|
99
|
84
|
/**
|
100
|
85
|
* 保存对象
|
101
|
86
|
* @param taTopic 实体对象
|
|
@@ -105,6 +90,14 @@ public class TaTopicController extends BaseController {
|
105
|
90
|
@ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
106
|
91
|
public ResponseBean topicAdd(@ApiParam("保存内容") @RequestBody TaTopic taTopic) throws Exception{
|
107
|
92
|
|
|
93
|
+ QueryWrapper<TaTopic> queryWrapper = new QueryWrapper<TaTopic>()
|
|
94
|
+ .orderByDesc("sort_no")
|
|
95
|
+ .last("limit 1");
|
|
96
|
+
|
|
97
|
+ TaTopic max = iTaTopicService.getOne(queryWrapper);
|
|
98
|
+ int sortNo = max == null ? 0 : max.getSortNo() + 1;
|
|
99
|
+ taTopic.setSortNo(sortNo);
|
|
100
|
+
|
108
|
101
|
if (iTaTopicService.save(taTopic)){
|
109
|
102
|
return ResponseBean.success(taTopic);
|
110
|
103
|
}else {
|
|
@@ -112,20 +105,6 @@ public class TaTopicController extends BaseController {
|
112
|
105
|
}
|
113
|
106
|
}
|
114
|
107
|
|
115
|
|
- /**
|
116
|
|
- * 根据id删除对象
|
117
|
|
- * @param id 实体ID
|
118
|
|
- */
|
119
|
|
- @RequestMapping(value="/taTopic/{id}", method= RequestMethod.DELETE)
|
120
|
|
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
121
|
|
- public ResponseBean taTopicDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
122
|
|
- if(iTaTopicService.removeById(id)){
|
123
|
|
- return ResponseBean.success("success");
|
124
|
|
- }else {
|
125
|
|
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
126
|
|
- }
|
127
|
|
- }
|
128
|
|
-
|
129
|
108
|
/**
|
130
|
109
|
* 根据id删除对象
|
131
|
110
|
* @param id 实体ID
|
|
@@ -140,24 +119,6 @@ public class TaTopicController extends BaseController {
|
140
|
119
|
}
|
141
|
120
|
}
|
142
|
121
|
|
143
|
|
- /**
|
144
|
|
- * 修改对象
|
145
|
|
- * @param id 实体ID
|
146
|
|
- * @param taTopic 实体对象
|
147
|
|
- * @return
|
148
|
|
- */
|
149
|
|
- @RequestMapping(value="/taTopic/{id}",method= RequestMethod.PUT)
|
150
|
|
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
151
|
|
- public ResponseBean taTopicUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
152
|
|
- @ApiParam("更新内容") @RequestBody TaTopic taTopic) throws Exception{
|
153
|
|
-
|
154
|
|
- if (iTaTopicService.updateById(taTopic)){
|
155
|
|
- return ResponseBean.success(iTaTopicService.getById(id));
|
156
|
|
- }else {
|
157
|
|
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
158
|
|
- }
|
159
|
|
- }
|
160
|
|
-
|
161
|
122
|
/**
|
162
|
123
|
* 修改对象
|
163
|
124
|
* @param id 实体ID
|
|
@@ -176,16 +137,6 @@ public class TaTopicController extends BaseController {
|
176
|
137
|
}
|
177
|
138
|
}
|
178
|
139
|
|
179
|
|
- /**
|
180
|
|
- * 根据id查询对象
|
181
|
|
- * @param id 实体ID
|
182
|
|
- */
|
183
|
|
- @RequestMapping(value="/taTopic/{id}",method= RequestMethod.GET)
|
184
|
|
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
185
|
|
- public ResponseBean taTopicGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
186
|
|
- return ResponseBean.success(iTaTopicService.getById(id));
|
187
|
|
- }
|
188
|
|
-
|
189
|
140
|
/**
|
190
|
141
|
* 根据id查询对象
|
191
|
142
|
* @param id 实体ID
|
|
@@ -200,7 +151,7 @@ public class TaTopicController extends BaseController {
|
200
|
151
|
@RequestMapping(value="/admin/sort/topic",method= RequestMethod.PUT)
|
201
|
152
|
@ApiOperation(value="排序", notes = "排序", httpMethod = "PUT", response = ResponseBean.class)
|
202
|
153
|
public ResponseBean topicSort(@ApiParam("排序") @RequestBody SortParams sortParams) throws Exception {
|
203
|
|
- if (null == sortParams.getFrom() || null == sortParams.getTo()) {
|
|
154
|
+ if (StringUtils.isEmpty(sortParams.getFrom()) || StringUtils.isEmpty(sortParams.getTo())) {
|
204
|
155
|
return ResponseBean.success("success");
|
205
|
156
|
}
|
206
|
157
|
|