|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.yunzhi.demo.common.BaseController;
|
7
|
7
|
import com.yunzhi.demo.common.Constants;
|
8
|
8
|
import com.yunzhi.demo.common.ResponseBean;
|
|
9
|
+import com.yunzhi.demo.common.StringUtils;
|
9
|
10
|
import io.swagger.annotations.Api;
|
10
|
11
|
import io.swagger.annotations.ApiOperation;
|
11
|
12
|
import io.swagger.annotations.ApiParam;
|
|
@@ -70,9 +71,12 @@ public class TdPostTypeController extends BaseController {
|
70
|
71
|
* @param tdPostType 实体对象
|
71
|
72
|
* @return
|
72
|
73
|
*/
|
73
|
|
- @RequestMapping(value="/tdPostType",method= RequestMethod.POST)
|
|
74
|
+ @RequestMapping(value="/admin/post-type",method= RequestMethod.POST)
|
74
|
75
|
@ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
75
|
76
|
public ResponseBean tdPostTypeAdd(@ApiParam("保存内容") @RequestBody TdPostType tdPostType) throws Exception{
|
|
77
|
+ if (StringUtils.isEmpty(tdPostType.getName())) {
|
|
78
|
+ return ResponseBean.error("类型名称不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
79
|
+ }
|
76
|
80
|
|
77
|
81
|
if (iTdPostTypeService.save(tdPostType)){
|
78
|
82
|
return ResponseBean.success(tdPostType);
|
|
@@ -85,10 +89,17 @@ public class TdPostTypeController extends BaseController {
|
85
|
89
|
* 根据id删除对象
|
86
|
90
|
* @param id 实体ID
|
87
|
91
|
*/
|
88
|
|
- @RequestMapping(value="/tdPostType/{id}", method= RequestMethod.DELETE)
|
|
92
|
+ @RequestMapping(value="/post-type/{id}", method= RequestMethod.DELETE)
|
89
|
93
|
@ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
90
|
|
- public ResponseBean tdPostTypeDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
91
|
|
- if(iTdPostTypeService.removeById(id)){
|
|
94
|
+ public ResponseBean tdPostTypeDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
|
95
|
+ TdPostType tdPostType = iTdPostTypeService.getById(id);
|
|
96
|
+ if (null == tdPostType || Constants.STATUS_DELETED.equals(tdPostType.getStatus())) {
|
|
97
|
+ return ResponseBean.success("success");
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ tdPostType.setStatus(Constants.STATUS_DELETED);
|
|
101
|
+
|
|
102
|
+ if(iTdPostTypeService.updateById(tdPostType)){
|
92
|
103
|
return ResponseBean.success("success");
|
93
|
104
|
}else {
|
94
|
105
|
return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
@@ -101,10 +112,13 @@ public class TdPostTypeController extends BaseController {
|
101
|
112
|
* @param tdPostType 实体对象
|
102
|
113
|
* @return
|
103
|
114
|
*/
|
104
|
|
- @RequestMapping(value="/tdPostType/{id}",method= RequestMethod.PUT)
|
|
115
|
+ @RequestMapping(value="/post-type/{id}",method= RequestMethod.PUT)
|
105
|
116
|
@ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
106
|
|
- public ResponseBean tdPostTypeUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
107
|
|
- @ApiParam("更新内容") @RequestBody TdPostType tdPostType) throws Exception{
|
|
117
|
+ public ResponseBean tdPostTypeUpdate(@ApiParam("对象ID") @PathVariable String id,
|
|
118
|
+ @ApiParam("更新内容") @RequestBody TdPostType tdPostType) throws Exception {
|
|
119
|
+ if (StringUtils.isEmpty(tdPostType.getName())) {
|
|
120
|
+ return ResponseBean.error("类型名称不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
121
|
+ }
|
108
|
122
|
|
109
|
123
|
if (iTdPostTypeService.updateById(tdPostType)){
|
110
|
124
|
return ResponseBean.success(iTdPostTypeService.getById(id));
|
|
@@ -117,9 +131,14 @@ public class TdPostTypeController extends BaseController {
|
117
|
131
|
* 根据id查询对象
|
118
|
132
|
* @param id 实体ID
|
119
|
133
|
*/
|
120
|
|
- @RequestMapping(value="/tdPostType/{id}",method= RequestMethod.GET)
|
|
134
|
+ @RequestMapping(value="/post-type/{id}",method= RequestMethod.GET)
|
121
|
135
|
@ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
122
|
136
|
public ResponseBean tdPostTypeGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
123
|
|
- return ResponseBean.success(iTdPostTypeService.getById(id));
|
|
137
|
+ TdPostType tdPostType = iTdPostTypeService.getById(id);
|
|
138
|
+ if (null == tdPostType || Constants.STATUS_DELETED.equals(tdPostType.getStatus())) {
|
|
139
|
+ return ResponseBean.error("没有找到对应的信息", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ return ResponseBean.success(tdPostType);
|
124
|
143
|
}
|
125
|
144
|
}
|