|
@@ -1,5 +1,6 @@
|
1
|
1
|
package com.huiju.estateagents.sample.controller;
|
2
|
2
|
|
|
3
|
+import com.alibaba.fastjson.JSONObject;
|
3
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
5
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -18,16 +19,19 @@ import org.springframework.web.bind.annotation.RequestParam;
|
18
|
19
|
import org.springframework.web.bind.annotation.ResponseBody;
|
19
|
20
|
import org.springframework.web.bind.annotation.RestController;
|
20
|
21
|
|
|
22
|
+import javax.servlet.http.HttpServletRequest;
|
|
23
|
+import java.util.List;
|
|
24
|
+
|
21
|
25
|
/**
|
22
|
26
|
* <p>
|
23
|
|
- * 开屏通知 前端控制器
|
24
|
|
- * </p>
|
|
27
|
+ * 开屏通知 前端控制器
|
|
28
|
+ * </p>
|
25
|
29
|
*
|
26
|
30
|
* @author fxf
|
27
|
31
|
* @since 2020-03-18
|
28
|
32
|
*/
|
29
|
33
|
@RestController
|
30
|
|
-@RequestMapping("/")
|
|
34
|
+@RequestMapping("/api")
|
31
|
35
|
public class TaNoticeController extends BaseController {
|
32
|
36
|
|
33
|
37
|
private final Logger logger = LoggerFactory.getLogger(TaNoticeController.class);
|
|
@@ -37,26 +41,29 @@ public class TaNoticeController extends BaseController {
|
37
|
41
|
|
38
|
42
|
|
39
|
43
|
/**
|
40
|
|
- * 分页查询列表
|
|
44
|
+ * 条件查询通知列表
|
|
45
|
+ *
|
41
|
46
|
* @param pageNum
|
42
|
47
|
* @param pageSize
|
|
48
|
+ * @param title
|
|
49
|
+ * @param targetType
|
|
50
|
+ * @param targetName
|
|
51
|
+ * @param status
|
|
52
|
+ * @param type 类型
|
43
|
53
|
* @return
|
44
|
54
|
*/
|
45
|
|
- @RequestMapping(value="/taNotice",method= RequestMethod.GET)
|
46
|
|
- public ResponseBean taNoticeList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
47
|
|
- @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
55
|
+ @RequestMapping(value = "/admin/listNoticeByCondition", method = RequestMethod.GET)
|
|
56
|
+ public ResponseBean listNoticeByCondition(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
57
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
|
58
|
+ String title, String targetType, String targetName, Integer status,
|
|
59
|
+ String type) {
|
48
|
60
|
ResponseBean responseBean = new ResponseBean();
|
49
|
61
|
try {
|
50
|
|
- //使用分页插件
|
51
|
|
- IPage<TaNotice> pg = new Page<>(pageNum, pageSize);
|
52
|
|
- QueryWrapper<TaNotice> queryWrapper = new QueryWrapper<>();
|
53
|
|
- queryWrapper.orderByDesc("create_date");
|
54
|
|
-
|
55
|
|
- IPage<TaNotice> result = iTaNoticeService.page(pg, queryWrapper);
|
56
|
|
- responseBean.addSuccess(result);
|
57
|
|
- }catch (Exception e){
|
|
62
|
+ responseBean = iTaNoticeService.listNoticeByCondition(pageNum, pageSize, title, targetType, targetName, status, type);
|
|
63
|
+ logger.info("TaNoticeController.listNoticeByCondition 返回结果:" + JSONObject.toJSONString(responseBean));
|
|
64
|
+ } catch (Exception e) {
|
58
|
65
|
e.printStackTrace();
|
59
|
|
- logger.error("taNoticeList -=- {}",e.toString());
|
|
66
|
+ logger.error("taNoticeList -=- {}", e.toString());
|
60
|
67
|
responseBean.addError(e.getMessage());
|
61
|
68
|
}
|
62
|
69
|
return responseBean;
|
|
@@ -64,43 +71,42 @@ public class TaNoticeController extends BaseController {
|
64
|
71
|
|
65
|
72
|
/**
|
66
|
73
|
* 保存对象
|
|
74
|
+ *
|
67
|
75
|
* @param taNotice 实体对象
|
68
|
76
|
* @return
|
69
|
77
|
*/
|
70
|
|
- @RequestMapping(value="/taNotice",method= RequestMethod.POST)
|
71
|
|
- public ResponseBean taNoticeAdd(@RequestBody TaNotice taNotice){
|
|
78
|
+ @RequestMapping(value = "/admin/taNotice", method = RequestMethod.POST)
|
|
79
|
+ public ResponseBean taNoticeAdd(@RequestBody TaNotice taNotice) {
|
72
|
80
|
ResponseBean responseBean = new ResponseBean();
|
73
|
81
|
try {
|
74
|
|
- if (iTaNoticeService.save(taNotice)){
|
|
82
|
+ if (iTaNoticeService.save(taNotice)) {
|
75
|
83
|
responseBean.addSuccess(taNotice);
|
76
|
|
- }else {
|
|
84
|
+ } else {
|
77
|
85
|
responseBean.addError("fail");
|
78
|
86
|
}
|
79
|
|
- }catch (Exception e){
|
|
87
|
+ } catch (Exception e) {
|
80
|
88
|
e.printStackTrace();
|
81
|
|
- logger.error("taNoticeAdd -=- {}",e.toString());
|
|
89
|
+ logger.error("taNoticeAdd -=- {}", e.toString());
|
82
|
90
|
responseBean.addError(e.getMessage());
|
83
|
91
|
}
|
84
|
92
|
return responseBean;
|
85
|
93
|
}
|
86
|
94
|
|
87
|
95
|
/**
|
88
|
|
- * 根据id删除对象
|
89
|
|
- * @param id 实体ID
|
|
96
|
+ * 批量删除开屏通知
|
|
97
|
+ *
|
|
98
|
+ * @param taNoticeList
|
90
|
99
|
*/
|
91
|
100
|
@ResponseBody
|
92
|
|
- @RequestMapping(value="/taNotice/{id}", method= RequestMethod.DELETE)
|
93
|
|
- public ResponseBean taNoticeDelete(@PathVariable Integer id){
|
|
101
|
+ @RequestMapping(value = "/admin/taNotice/batchDelete/{id}", method = RequestMethod.DELETE)
|
|
102
|
+ public ResponseBean batchDelete(List<TaNotice> taNoticeList) {
|
94
|
103
|
ResponseBean responseBean = new ResponseBean();
|
95
|
104
|
try {
|
96
|
|
- if(iTaNoticeService.removeById(id)){
|
97
|
|
- responseBean.addSuccess("success");
|
98
|
|
- }else {
|
99
|
|
- responseBean.addError("fail");
|
100
|
|
- }
|
101
|
|
- }catch (Exception e){
|
|
105
|
+ responseBean = iTaNoticeService.batchDelete(taNoticeList);
|
|
106
|
+ logger.info("TaNoticeController.taNoticeDelete 返回结果:" + JSONObject.toJSONString(responseBean));
|
|
107
|
+ } catch (Exception e) {
|
102
|
108
|
e.printStackTrace();
|
103
|
|
- logger.error("taNoticeDelete -=- {}",e.toString());
|
|
109
|
+ logger.error("taNoticeDelete -=- {}", e.toString());
|
104
|
110
|
responseBean.addError(e.getMessage());
|
105
|
111
|
}
|
106
|
112
|
return responseBean;
|
|
@@ -108,23 +114,24 @@ public class TaNoticeController extends BaseController {
|
108
|
114
|
|
109
|
115
|
/**
|
110
|
116
|
* 修改对象
|
111
|
|
- * @param id 实体ID
|
|
117
|
+ *
|
|
118
|
+ * @param id 实体ID
|
112
|
119
|
* @param taNotice 实体对象
|
113
|
120
|
* @return
|
114
|
121
|
*/
|
115
|
|
- @RequestMapping(value="/taNotice/{id}",method= RequestMethod.PUT)
|
|
122
|
+ @RequestMapping(value = "/admin/taNotice/{id}", method = RequestMethod.PUT)
|
116
|
123
|
public ResponseBean taNoticeUpdate(@PathVariable Integer id,
|
117
|
|
- @RequestBody TaNotice taNotice){
|
|
124
|
+ @RequestBody TaNotice taNotice) {
|
118
|
125
|
ResponseBean responseBean = new ResponseBean();
|
119
|
126
|
try {
|
120
|
|
- if (iTaNoticeService.updateById(taNotice)){
|
|
127
|
+ if (iTaNoticeService.updateById(taNotice)) {
|
121
|
128
|
responseBean.addSuccess(taNotice);
|
122
|
|
- }else {
|
|
129
|
+ } else {
|
123
|
130
|
responseBean.addError("fail");
|
124
|
131
|
}
|
125
|
|
- }catch (Exception e){
|
|
132
|
+ } catch (Exception e) {
|
126
|
133
|
e.printStackTrace();
|
127
|
|
- logger.error("taNoticeUpdate -=- {}",e.toString());
|
|
134
|
+ logger.error("taNoticeUpdate -=- {}", e.toString());
|
128
|
135
|
responseBean.addError(e.getMessage());
|
129
|
136
|
}
|
130
|
137
|
return responseBean;
|
|
@@ -132,16 +139,17 @@ public class TaNoticeController extends BaseController {
|
132
|
139
|
|
133
|
140
|
/**
|
134
|
141
|
* 根据id查询对象
|
135
|
|
- * @param id 实体ID
|
|
142
|
+ *
|
|
143
|
+ * @param id 实体ID
|
136
|
144
|
*/
|
137
|
|
- @RequestMapping(value="/taNotice/{id}",method= RequestMethod.GET)
|
138
|
|
- public ResponseBean taNoticeGet(@PathVariable Integer id){
|
|
145
|
+ @RequestMapping(value = "/taNotice/{id}", method = RequestMethod.GET)
|
|
146
|
+ public ResponseBean taNoticeGet(@PathVariable Integer id) {
|
139
|
147
|
ResponseBean responseBean = new ResponseBean();
|
140
|
148
|
try {
|
141
|
149
|
responseBean.addSuccess(iTaNoticeService.getById(id));
|
142
|
|
- }catch (Exception e){
|
|
150
|
+ } catch (Exception e) {
|
143
|
151
|
e.printStackTrace();
|
144
|
|
- logger.error("taNoticeDelete -=- {}",e.toString());
|
|
152
|
+ logger.error("taNoticeDelete -=- {}", e.toString());
|
145
|
153
|
responseBean.addError(e.getMessage());
|
146
|
154
|
}
|
147
|
155
|
return responseBean;
|