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