|
@@ -4,7 +4,9 @@ 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
|
6
|
import com.yunzhi.training.common.BaseController;
|
|
7
|
+import com.yunzhi.training.common.Constants;
|
7
|
8
|
import com.yunzhi.training.common.ResponseBean;
|
|
9
|
+import com.yunzhi.training.common.StringUtils;
|
8
|
10
|
import io.swagger.annotations.Api;
|
9
|
11
|
import io.swagger.annotations.ApiOperation;
|
10
|
12
|
import io.swagger.annotations.ApiParam;
|
|
@@ -46,17 +48,24 @@ public class TaAttachmentController extends BaseController {
|
46
|
48
|
* @param pageSize
|
47
|
49
|
* @return
|
48
|
50
|
*/
|
49
|
|
- @RequestMapping(value="/taAttachment",method= RequestMethod.GET)
|
|
51
|
+ @RequestMapping(value="/{client}/attachment",method= RequestMethod.GET)
|
50
|
52
|
@ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
51
|
|
- public ResponseBean taAttachmentList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
52
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
|
53
|
+ public ResponseBean taAttachmentList(@ApiParam(value = "客户端",allowableValues = "admin,wx") @PathVariable String client,
|
|
54
|
+ @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
55
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
56
|
+ @ApiParam("附件类型") @RequestParam(value ="attchType", defaultValue = "image") String attchType,
|
|
57
|
+ @ApiParam("所属包组") @RequestParam(value ="packId", required = false) String packId) throws Exception{
|
53
|
58
|
|
54
|
|
- IPage<TaAttachment> pg = new Page<>(pageNum, pageSize);
|
55
|
|
- QueryWrapper<TaAttachment> queryWrapper = new QueryWrapper<>();
|
56
|
|
- queryWrapper.orderByDesc("create_date");
|
|
59
|
+ IPage<TaAttachment> pg = new Page<>(pageNum, pageSize);
|
|
60
|
+ QueryWrapper<TaAttachment> queryWrapper = new QueryWrapper<>();
|
|
61
|
+ queryWrapper.eq(!StringUtils.isEmpty(attchType), "attch_type", attchType);
|
|
62
|
+ queryWrapper.eq(!StringUtils.isEmpty(packId), "pack_id", packId);
|
|
63
|
+ queryWrapper.gt("state", Constants.STATUS_DELETED);
|
|
64
|
+ queryWrapper.eq("wx".equals(client), "state", Constants.STATUS_NORMAL);
|
|
65
|
+ queryWrapper.orderByDesc("create_date");
|
57
|
66
|
|
58
|
|
- IPage<TaAttachment> result = iTaAttachmentService.page(pg, queryWrapper);
|
59
|
|
- return ResponseBean.success(result);
|
|
67
|
+ IPage<TaAttachment> result = iTaAttachmentService.page(pg, queryWrapper);
|
|
68
|
+ return ResponseBean.success(result);
|
60
|
69
|
}
|
61
|
70
|
|
62
|
71
|
/**
|
|
@@ -64,10 +73,22 @@ public class TaAttachmentController extends BaseController {
|
64
|
73
|
* @param taAttachment 实体对象
|
65
|
74
|
* @return
|
66
|
75
|
*/
|
67
|
|
- @RequestMapping(value="/taAttachment",method= RequestMethod.POST)
|
|
76
|
+ @RequestMapping(value="/admin/attachment",method= RequestMethod.POST)
|
68
|
77
|
@ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
69
|
78
|
public ResponseBean taAttachmentAdd(@ApiParam("保存内容") @RequestBody TaAttachment taAttachment) throws Exception{
|
70
|
79
|
|
|
80
|
+ if (StringUtils.isEmpty(taAttachment.getUrl())) {
|
|
81
|
+ return ResponseBean.error("请设置附件地址", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
82
|
+ }
|
|
83
|
+ if (StringUtils.isEmpty(taAttachment.getPackId())) {
|
|
84
|
+ return ResponseBean.error("请设置附件包组", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
85
|
+ }
|
|
86
|
+ if (StringUtils.isEmpty(taAttachment.getAttchType())) {
|
|
87
|
+ taAttachment.setAttchType("image");
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ taAttachment.setAttchId(null);
|
|
91
|
+
|
71
|
92
|
if (iTaAttachmentService.save(taAttachment)){
|
72
|
93
|
return ResponseBean.success(taAttachment);
|
73
|
94
|
}else {
|
|
@@ -79,10 +100,10 @@ public class TaAttachmentController extends BaseController {
|
79
|
100
|
* 根据id删除对象
|
80
|
101
|
* @param id 实体ID
|
81
|
102
|
*/
|
82
|
|
- @RequestMapping(value="/taAttachment/{id}", method= RequestMethod.DELETE)
|
|
103
|
+ @RequestMapping(value="/admin/attachment/{id}", method= RequestMethod.DELETE)
|
83
|
104
|
@ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
84
|
|
- public ResponseBean taAttachmentDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
85
|
|
- if(iTaAttachmentService.removeById(id)){
|
|
105
|
+ public ResponseBean taAttachmentDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
|
106
|
+ if(iTaAttachmentService.removeLogicById(id)){
|
86
|
107
|
return ResponseBean.success("success");
|
87
|
108
|
}else {
|
88
|
109
|
return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
@@ -95,10 +116,21 @@ public class TaAttachmentController extends BaseController {
|
95
|
116
|
* @param taAttachment 实体对象
|
96
|
117
|
* @return
|
97
|
118
|
*/
|
98
|
|
- @RequestMapping(value="/taAttachment/{id}",method= RequestMethod.PUT)
|
|
119
|
+ @RequestMapping(value="/admin/attachment/{id}",method= RequestMethod.PUT)
|
99
|
120
|
@ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
100
|
|
- public ResponseBean taAttachmentUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
121
|
+ public ResponseBean taAttachmentUpdate(@ApiParam("对象ID") @PathVariable String id,
|
101
|
122
|
@ApiParam("更新内容") @RequestBody TaAttachment taAttachment) throws Exception{
|
|
123
|
+ if (StringUtils.isEmpty(taAttachment.getUrl())) {
|
|
124
|
+ return ResponseBean.error("请设置附件地址", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
125
|
+ }
|
|
126
|
+ if (StringUtils.isEmpty(taAttachment.getPackId())) {
|
|
127
|
+ return ResponseBean.error("请设置附件包组", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
128
|
+ }
|
|
129
|
+ if (StringUtils.isEmpty(taAttachment.getAttchType())) {
|
|
130
|
+ taAttachment.setAttchType("image");
|
|
131
|
+ }
|
|
132
|
+
|
|
133
|
+ taAttachment.setAttchId(id);
|
102
|
134
|
|
103
|
135
|
if (iTaAttachmentService.updateById(taAttachment)){
|
104
|
136
|
return ResponseBean.success(iTaAttachmentService.getById(id));
|
|
@@ -107,13 +139,13 @@ public class TaAttachmentController extends BaseController {
|
107
|
139
|
}
|
108
|
140
|
}
|
109
|
141
|
|
110
|
|
- /**
|
111
|
|
- * 根据id查询对象
|
112
|
|
- * @param id 实体ID
|
113
|
|
- */
|
114
|
|
- @RequestMapping(value="/taAttachment/{id}",method= RequestMethod.GET)
|
115
|
|
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
116
|
|
- public ResponseBean taAttachmentGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
117
|
|
- return ResponseBean.success(iTaAttachmentService.getById(id));
|
118
|
|
- }
|
|
142
|
+// /**
|
|
143
|
+// * 根据id查询对象
|
|
144
|
+// * @param id 实体ID
|
|
145
|
+// */
|
|
146
|
+// @RequestMapping(value="/taAttachment/{id}",method= RequestMethod.GET)
|
|
147
|
+// @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
148
|
+// public ResponseBean taAttachmentGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
149
|
+// return ResponseBean.success(iTaAttachmentService.getById(id));
|
|
150
|
+// }
|
119
|
151
|
}
|