|
@@ -20,11 +20,15 @@ import org.springframework.web.bind.annotation.RequestParam;
|
20
|
20
|
import org.springframework.web.bind.annotation.ResponseBody;
|
21
|
21
|
import org.springframework.web.bind.annotation.RestController;
|
22
|
22
|
|
|
23
|
+import java.time.LocalDateTime;
|
|
24
|
+import java.util.ArrayList;
|
|
25
|
+import java.util.List;
|
|
26
|
+
|
23
|
27
|
|
24
|
28
|
/**
|
25
|
29
|
* <p>
|
26
|
|
- * 联系人表 前端控制器
|
27
|
|
- * </p>
|
|
30
|
+ * 联系人表 前端控制器
|
|
31
|
+ * </p>
|
28
|
32
|
*
|
29
|
33
|
* @author fxf
|
30
|
34
|
* @since 2020-03-18
|
|
@@ -40,26 +44,37 @@ public class TaContactController extends BaseController {
|
40
|
44
|
|
41
|
45
|
|
42
|
46
|
/**
|
43
|
|
- * 分页查询列表
|
|
47
|
+ * 条件查询联系人列表
|
|
48
|
+ *
|
44
|
49
|
* @param pageNum
|
45
|
50
|
* @param pageSize
|
|
51
|
+ * @param contactName
|
|
52
|
+ * @param telephone
|
|
53
|
+ * @param phone
|
|
54
|
+ * @param job
|
46
|
55
|
* @return
|
47
|
56
|
*/
|
48
|
|
- @RequestMapping(value="/taContact",method= RequestMethod.GET)
|
49
|
|
- public ResponseBean taContactList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
50
|
|
- @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
57
|
+ @RequestMapping(value = "/channel/listContactByCondition", method = RequestMethod.GET)
|
|
58
|
+ public ResponseBean listContactByCondition(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
59
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
|
60
|
+ String contactName, String telephone, String phone, String job) {
|
51
|
61
|
ResponseBean responseBean = new ResponseBean();
|
52
|
62
|
try {
|
53
|
63
|
//使用分页插件
|
54
|
|
- IPage<TaContact> pg = new Page<>(pageNum, pageSize);
|
|
64
|
+ IPage<TaContact> pg = new Page<>(pageNum, pageSize);
|
55
|
65
|
QueryWrapper<TaContact> queryWrapper = new QueryWrapper<>();
|
56
|
|
- queryWrapper.orderByDesc("create_date");
|
|
66
|
+ queryWrapper.like(!StringUtils.isEmpty(contactName),"contact_name", contactName);
|
|
67
|
+ queryWrapper.like(!StringUtils.isEmpty(telephone),"telephone", telephone);
|
|
68
|
+ queryWrapper.like(!StringUtils.isEmpty(phone),"phone", phone);
|
|
69
|
+ queryWrapper.like(!StringUtils.isEmpty(job),"job", job);
|
|
70
|
+ queryWrapper.ne("status", CommConstant.STATUS_DELETE);
|
|
71
|
+ queryWrapper.orderByDesc("order_no", "create_date");
|
57
|
72
|
|
58
|
73
|
IPage<TaContact> result = iTaContactService.page(pg, queryWrapper);
|
59
|
74
|
responseBean.addSuccess(result);
|
60
|
|
- }catch (Exception e){
|
|
75
|
+ } catch (Exception e) {
|
61
|
76
|
e.printStackTrace();
|
62
|
|
- logger.error("taContactList -=- {}",e.toString());
|
|
77
|
+ logger.error("taContactList -=- {}", e.toString());
|
63
|
78
|
responseBean.addError(e.getMessage());
|
64
|
79
|
}
|
65
|
80
|
return responseBean;
|
|
@@ -67,43 +82,51 @@ public class TaContactController extends BaseController {
|
67
|
82
|
|
68
|
83
|
/**
|
69
|
84
|
* 保存对象
|
|
85
|
+ *
|
70
|
86
|
* @param taContact 实体对象
|
71
|
87
|
* @return
|
72
|
88
|
*/
|
73
|
|
- @RequestMapping(value="/taContact",method= RequestMethod.POST)
|
74
|
|
- public ResponseBean taContactAdd(@RequestBody TaContact taContact){
|
|
89
|
+ @RequestMapping(value = "/channel/taContact", method = RequestMethod.POST)
|
|
90
|
+ public ResponseBean taContactAdd(@RequestBody TaContact taContact) {
|
75
|
91
|
ResponseBean responseBean = new ResponseBean();
|
76
|
92
|
try {
|
77
|
|
- if (iTaContactService.save(taContact)){
|
|
93
|
+ taContact.setCreateDate(LocalDateTime.now());
|
|
94
|
+ taContact.setStatus(CommConstant.STATUS_NORMAL);
|
|
95
|
+ if (iTaContactService.save(taContact)) {
|
78
|
96
|
responseBean.addSuccess(taContact);
|
79
|
|
- }else {
|
|
97
|
+ } else {
|
80
|
98
|
responseBean.addError("fail");
|
81
|
99
|
}
|
82
|
|
- }catch (Exception e){
|
|
100
|
+ } catch (Exception e) {
|
83
|
101
|
e.printStackTrace();
|
84
|
|
- logger.error("taContactAdd -=- {}",e.toString());
|
|
102
|
+ logger.error("taContactAdd -=- {}", e.toString());
|
85
|
103
|
responseBean.addError(e.getMessage());
|
86
|
104
|
}
|
87
|
105
|
return responseBean;
|
88
|
106
|
}
|
89
|
107
|
|
90
|
108
|
/**
|
91
|
|
- * 根据id删除对象
|
92
|
|
- * @param id 实体ID
|
|
109
|
+ * 批量删除
|
|
110
|
+ *
|
93
|
111
|
*/
|
94
|
112
|
@ResponseBody
|
95
|
|
- @RequestMapping(value="/taContact/{id}", method= RequestMethod.DELETE)
|
96
|
|
- public ResponseBean taContactDelete(@PathVariable Integer id){
|
|
113
|
+ @RequestMapping(value = "/channel/taContact/batchDelete", method = RequestMethod.PUT)
|
|
114
|
+ public ResponseBean batchDelete(@RequestBody List<TaContact> taContactList) {
|
97
|
115
|
ResponseBean responseBean = new ResponseBean();
|
98
|
116
|
try {
|
99
|
|
- if(iTaContactService.removeById(id)){
|
100
|
|
- responseBean.addSuccess("success");
|
101
|
|
- }else {
|
102
|
|
- responseBean.addError("fail");
|
|
117
|
+ List<TaContact> updateList = new ArrayList<>();
|
|
118
|
+ TaContact newContact;
|
|
119
|
+ for (TaContact taContact : taContactList) {
|
|
120
|
+ newContact = new TaContact();
|
|
121
|
+ newContact.setContactId(taContact.getContactId());
|
|
122
|
+ newContact.setStatus(CommConstant.STATUS_DELETE);
|
|
123
|
+ updateList.add(newContact);
|
103
|
124
|
}
|
104
|
|
- }catch (Exception e){
|
|
125
|
+
|
|
126
|
+ responseBean.addSuccess(iTaContactService.updateBatchById(updateList));
|
|
127
|
+ } catch (Exception e) {
|
105
|
128
|
e.printStackTrace();
|
106
|
|
- logger.error("taContactDelete -=- {}",e.toString());
|
|
129
|
+ logger.error("taContactDelete -=- {}", e.toString());
|
107
|
130
|
responseBean.addError(e.getMessage());
|
108
|
131
|
}
|
109
|
132
|
return responseBean;
|
|
@@ -111,23 +134,24 @@ public class TaContactController extends BaseController {
|
111
|
134
|
|
112
|
135
|
/**
|
113
|
136
|
* 修改对象
|
114
|
|
- * @param id 实体ID
|
|
137
|
+ *
|
|
138
|
+ * @param id 实体ID
|
115
|
139
|
* @param taContact 实体对象
|
116
|
140
|
* @return
|
117
|
141
|
*/
|
118
|
|
- @RequestMapping(value="/taContact/{id}",method= RequestMethod.PUT)
|
|
142
|
+ @RequestMapping(value = "/channel/taContact/{id}", method = RequestMethod.PUT)
|
119
|
143
|
public ResponseBean taContactUpdate(@PathVariable Integer id,
|
120
|
|
- @RequestBody TaContact taContact){
|
|
144
|
+ @RequestBody TaContact taContact) {
|
121
|
145
|
ResponseBean responseBean = new ResponseBean();
|
122
|
146
|
try {
|
123
|
|
- if (iTaContactService.updateById(taContact)){
|
|
147
|
+ if (iTaContactService.updateById(taContact)) {
|
124
|
148
|
responseBean.addSuccess(taContact);
|
125
|
|
- }else {
|
|
149
|
+ } else {
|
126
|
150
|
responseBean.addError("fail");
|
127
|
151
|
}
|
128
|
|
- }catch (Exception e){
|
|
152
|
+ } catch (Exception e) {
|
129
|
153
|
e.printStackTrace();
|
130
|
|
- logger.error("taContactUpdate -=- {}",e.toString());
|
|
154
|
+ logger.error("taContactUpdate -=- {}", e.toString());
|
131
|
155
|
responseBean.addError(e.getMessage());
|
132
|
156
|
}
|
133
|
157
|
return responseBean;
|
|
@@ -135,16 +159,17 @@ public class TaContactController extends BaseController {
|
135
|
159
|
|
136
|
160
|
/**
|
137
|
161
|
* 根据id查询对象
|
138
|
|
- * @param id 实体ID
|
|
162
|
+ *
|
|
163
|
+ * @param id 实体ID
|
139
|
164
|
*/
|
140
|
|
- @RequestMapping(value="/taContact/{id}",method= RequestMethod.GET)
|
141
|
|
- public ResponseBean taContactGet(@PathVariable Integer id){
|
|
165
|
+ @RequestMapping(value = "/channel/taContact/{id}", method = RequestMethod.GET)
|
|
166
|
+ public ResponseBean taContactGet(@PathVariable Integer id) {
|
142
|
167
|
ResponseBean responseBean = new ResponseBean();
|
143
|
168
|
try {
|
144
|
169
|
responseBean.addSuccess(iTaContactService.getById(id));
|
145
|
|
- }catch (Exception e){
|
|
170
|
+ } catch (Exception e) {
|
146
|
171
|
e.printStackTrace();
|
147
|
|
- logger.error("taContactDelete -=- {}",e.toString());
|
|
172
|
+ logger.error("taContactDelete -=- {}", e.toString());
|
148
|
173
|
responseBean.addError(e.getMessage());
|
149
|
174
|
}
|
150
|
175
|
return responseBean;
|