|
@@ -4,8 +4,15 @@ 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.example.civilizedcity.common.BaseController;
|
|
7
|
+import com.example.civilizedcity.common.Constants;
|
7
|
8
|
import com.example.civilizedcity.common.ResponseBean;
|
8
|
9
|
import java.util.List;
|
|
10
|
+
|
|
11
|
+import com.example.civilizedcity.common.StringUtils;
|
|
12
|
+import com.example.civilizedcity.entity.TaAttach;
|
|
13
|
+import com.example.civilizedcity.entity.TaIssue;
|
|
14
|
+import com.example.civilizedcity.entity.TaPerson;
|
|
15
|
+import com.example.civilizedcity.service.TaAttachService;
|
9
|
16
|
import io.swagger.annotations.Api;
|
10
|
17
|
import io.swagger.annotations.ApiOperation;
|
11
|
18
|
import io.swagger.annotations.ApiParam;
|
|
@@ -26,17 +33,23 @@ public class TaFeedbackController extends BaseController {
|
26
|
33
|
|
27
|
34
|
@Autowired
|
28
|
35
|
private TaFeedbackService taFeedbackService;
|
|
36
|
+
|
|
37
|
+ @Autowired
|
|
38
|
+ private TaAttachService taAttachService;
|
29
|
39
|
|
30
|
40
|
/**
|
31
|
41
|
* 通过ID查询单条数据
|
32
|
42
|
*
|
33
|
|
- * @param feedbackId 主键
|
|
43
|
+ * @param id 主键
|
34
|
44
|
* @return 实例对象
|
35
|
45
|
*/
|
36
|
46
|
@ApiOperation("通过ID查询单条数据")
|
37
|
47
|
@GetMapping("/taFeedback/{id}")
|
38
|
48
|
public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
|
39
|
|
- return ResponseBean.success(taFeedbackService.getById(id));
|
|
49
|
+ TaFeedback taFeedback = taFeedbackService.getById(id);
|
|
50
|
+ List<TaAttach> attachList = taAttachService.getListBy(Constants.ATTACH_SOURCE_FEEDBACK, taFeedback.getFeedbackId());
|
|
51
|
+ taFeedback.setAttachList(attachList);
|
|
52
|
+ return ResponseBean.success(taFeedback);
|
40
|
53
|
}
|
41
|
54
|
|
42
|
55
|
/**
|
|
@@ -49,12 +62,19 @@ public class TaFeedbackController extends BaseController {
|
49
|
62
|
@ApiOperation("分页查询")
|
50
|
63
|
@GetMapping("/taFeedback")
|
51
|
64
|
public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
52
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
|
|
65
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
66
|
+ @ApiParam("我的") @RequestParam(value ="isMine", defaultValue = "false") Boolean isMine,
|
|
67
|
+ @ApiParam("问题单状态") @RequestParam(value = "bizStatus", required = false) String bizStatus) throws Exception {
|
|
68
|
+
|
|
69
|
+ TaPerson taPerson = currentPerson();
|
|
70
|
+ if (null == taPerson && isMine) {
|
|
71
|
+ return ResponseBean.error("请在小程序中操作");
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ String personId = isMine ? taPerson.getPersonId() : null;
|
53
|
75
|
|
54
|
|
- IPage<TaFeedback> pg = new Page<>(pageNum, pageSize);
|
55
|
|
- // QueryWrapper<TaFeedback> queryWrapper = new QueryWrapper<>();
|
56
|
|
- // queryWrapper.orderByDesc("create_date");
|
57
|
|
- IPage<TaFeedback> result = taFeedbackService.page(pg);
|
|
76
|
+ IPage<TaIssue> pg = new Page<>(pageNum, pageSize);
|
|
77
|
+ IPage<TaIssue> result = taFeedbackService.getPageBy(pg, personId, bizStatus);
|
58
|
78
|
|
59
|
79
|
return ResponseBean.success(result);
|
60
|
80
|
}
|
|
@@ -68,23 +88,37 @@ public class TaFeedbackController extends BaseController {
|
68
|
88
|
@ApiOperation("新增数据")
|
69
|
89
|
@PostMapping("/taFeedback")
|
70
|
90
|
public ResponseBean add(@ApiParam("对象实体") @RequestBody TaFeedback taFeedback) throws Exception {
|
71
|
|
- taFeedbackService.save(taFeedback);
|
|
91
|
+
|
|
92
|
+ if (StringUtils.isEmpty(taFeedback.getContent())) {
|
|
93
|
+ return ResponseBean.error("请填写反馈内容");
|
|
94
|
+ }
|
|
95
|
+ if (StringUtils.isEmpty(taFeedback.getAddr())) {
|
|
96
|
+ return ResponseBean.error("请填写具体位置");
|
|
97
|
+ }
|
|
98
|
+
|
|
99
|
+ if (null == taFeedback.getAttachList() || taFeedback.getAttachList().size() == 0) {
|
|
100
|
+ return ResponseBean.error("请上传照片");
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ TaPerson taPerson = currentPerson();
|
|
104
|
+
|
|
105
|
+ taFeedbackService.createNew(taFeedback, taPerson);
|
72
|
106
|
return ResponseBean.success(taFeedback);
|
73
|
107
|
}
|
74
|
108
|
|
75
|
|
- /**
|
76
|
|
- * 更新数据
|
77
|
|
- *
|
78
|
|
- * @param taFeedback 实例对象
|
79
|
|
- * @return 实例对象
|
80
|
|
- */
|
81
|
|
- @ApiOperation("更新数据")
|
82
|
|
- @PutMapping("/taFeedback/{id}")
|
83
|
|
- public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaFeedback taFeedback,
|
84
|
|
- @ApiParam("对象ID") @PathVariable String id ) throws Exception {
|
85
|
|
- taFeedbackService.updateById(taFeedback);
|
86
|
|
- return ResponseBean.success(taFeedback);
|
87
|
|
- }
|
|
109
|
+// /**
|
|
110
|
+// * 更新数据
|
|
111
|
+// *
|
|
112
|
+// * @param taFeedback 实例对象
|
|
113
|
+// * @return 实例对象
|
|
114
|
+// */
|
|
115
|
+// @ApiOperation("更新数据")
|
|
116
|
+// @PutMapping("/taFeedback/{id}")
|
|
117
|
+// public ResponseBean edit(@ApiParam("对象实体") @RequestBody TaFeedback taFeedback,
|
|
118
|
+// @ApiParam("对象ID") @PathVariable String id ) throws Exception {
|
|
119
|
+// taFeedbackService.updateById(taFeedback);
|
|
120
|
+// return ResponseBean.success(taFeedback);
|
|
121
|
+// }
|
88
|
122
|
|
89
|
123
|
/**
|
90
|
124
|
* 通过主键删除数据
|
|
@@ -94,7 +128,21 @@ public class TaFeedbackController extends BaseController {
|
94
|
128
|
*/
|
95
|
129
|
@ApiOperation("通过主键删除数据")
|
96
|
130
|
@DeleteMapping("/taFeedback/{id}")
|
97
|
|
- public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
|
|
131
|
+ public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
|
|
132
|
+ TaPerson taPerson = currentPerson();
|
|
133
|
+ if (null == taPerson) {
|
|
134
|
+ return ResponseBean.error("请在小程序中操作");
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ TaFeedback taFeedback = taFeedbackService.getById(id);
|
|
138
|
+ if (null == taFeedback || taFeedback.getStatus() == Constants.STATUS_DELETE) {
|
|
139
|
+ return ResponseBean.error("未找到相关数据");
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ if (!taPerson.getPersonId().equals(taFeedback.getPersonId())) {
|
|
143
|
+ return ResponseBean.error("暂无权限");
|
|
144
|
+ }
|
|
145
|
+
|
98
|
146
|
taFeedbackService.removeLogicById(id);
|
99
|
147
|
return ResponseBean.success("success");
|
100
|
148
|
}
|