WeCustomerController.java
7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package com.linkwechat.web.controller.wecom;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeCustomerTrajectoryService;
import com.linkwechat.wecom.service.IWeFlowerCustomerTagRelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 企业微信客户Controller
*
* @author ruoyi
* @date 2020-09-13
*/
@RestController
@RequestMapping("/wecom/customer")
public class WeCustomerController extends BaseController
{
@Autowired
@Lazy
private IWeCustomerService weCustomerService;
@Autowired
private IWeCustomerTrajectoryService iWeCustomerTrajectoryService;
/**
* 查询企业微信客户列表
*/
// @PreAuthorize("@ss.hasPermi('customerManage:customer:list')")
@GetMapping("/list")
public TableDataInfo list(WeCustomer weCustomer)
{
startPage();
List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer);
return getDataTable(list);
}
/**
* 根据员工ID获取客户
* @return
*/
// @PreAuthorize("@ss.hasPermi('customerManage:customer:list')")
@GetMapping("/getCustomersByUserId/{externalUserid}")
public AjaxResult getCustomersByUserId(@PathVariable String externalUserid){
return AjaxResult.success(weCustomerService.getCustomersByUserId(externalUserid));
}
/**
* 查询企业微信客户列表(重构版)
*/
// @PreAuthorize("@ss.hasPermi('customerManage:customer:list')")
@GetMapping("/findWeCustomerList")
@ApiOperation("查询企业微信客户列表(重构版)")
public TableDataInfo findWeCustomerList(WeCustomerList weCustomerList)
{
startPage();
List<WeCustomerList> list = weCustomerService.findWeCustomerList(weCustomerList);
return getDataTable(list);
}
// /**
// * 导出企业微信客户列表
// */
// // @PreAuthorize("@ss.hasPermi('wecom:customer:export')")
// @Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
// @GetMapping("/export")
// public AjaxResult export(WeCustomer weCustomer)
// {
// List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer);
// ExcelUtil<WeCustomer> util = new ExcelUtil<WeCustomer>(WeCustomer.class);
// return util.exportExcel(list, "customer");
// }
// /**
// * 获取企业微信客户详细信息
// */
// // @PreAuthorize("@ss.hasPermi('customerManage:customer:view')")
// @GetMapping(value = "/{externalUserId}")
// public AjaxResult getInfo(@PathVariable("externalUserId") String externalUserId)
// {
// return AjaxResult.success(weCustomerService.selectWeCustomerById(externalUserId));
// }
/**
* 修改企业微信客户(目前只更新生日)
*/
// @PreAuthorize("@ss.hasPermi('wecom:customer:edit')")
@Log(title = "企业微信客户", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody WeCustomer weCustomer)
{
weCustomerService.update(weCustomer,new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,weCustomer.getExternalUserid())
.eq(WeCustomer::getFirstUserId,weCustomer.getFirstUserId()));
return AjaxResult.success();
}
/**
* 客户同步接口
* @return
*/
// @PreAuthorize("@ss.hasPermi('customerManage:customer:sync')")
@Log(title = "企业微信客户同步接口", businessType = BusinessType.DELETE)
@GetMapping("/synchWeCustomer")
public AjaxResult synchWeCustomer() {
try {
weCustomerService.synchWeCustomer();
} catch (Exception e) {
e.printStackTrace();
}
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
/**
* 客户打标签
* @param weMakeCustomerTag
* @return
*/
// @PreAuthorize("@ss.hasPermi('customerManage/customer:makeTag')")
@Log(title = "客户打标签", businessType = BusinessType.UPDATE)
@PostMapping("/makeLabel")
public AjaxResult makeLabel(@RequestBody WeMakeCustomerTag weMakeCustomerTag){
weCustomerService.makeLabel(weMakeCustomerTag);
return AjaxResult.success();
}
/**
* 移除客户标签
* @return
*/
// @PreAuthorize("@ss.hasPermi('customerManage:customer:removeTag')")
@Log(title = "移除客户标签", businessType = BusinessType.DELETE)
@DeleteMapping("/removeLabel")
public AjaxResult removeLabel(@RequestBody WeMakeCustomerTag weMakeCustomerTag){
weCustomerService.makeLabel(weMakeCustomerTag);
return AjaxResult.success();
}
/*************************************************************************
******************************客户详情相关*********************************
*************************************************************************/
/**
* 客户详情基础数据
* @return
*/
@ApiOperation("客户详情基础数据")
@GetMapping(value = "/findCustomerDetailBaseInfo")
public AjaxResult findCustomerDetailBaseInfo(String externalUserid){
return AjaxResult.success(
weCustomerService.findWeCustomerDetail(externalUserid)
);
}
/**
* 获取客户轨迹信息
* @param trajectoryType
* @return
*/
@GetMapping(value = "/findTrajectory")
@ApiOperation("获取客户轨迹信息")
public TableDataInfo findTrajectory(String userId,Integer trajectoryType){
startPage();
LambdaQueryWrapper<WeCustomerTrajectory> ne = new LambdaQueryWrapper<WeCustomerTrajectory>()
.ne(WeCustomerTrajectory::getStatus, Constants.DELETE_CODE)
.eq(WeCustomerTrajectory::getUserId,userId);
if(trajectoryType != null){
ne.eq(WeCustomerTrajectory::getTrajectoryType, trajectoryType);
}
return getDataTable(
iWeCustomerTrajectoryService.list(ne)
);
}
/**
* 客户条件检索
* @param params 检索条件
* @return
*/
@ApiOperation(value = "客户条件检索",httpMethod = "POST")
@PostMapping(value = "/getCustomerByCondition")
public AjaxResult getCustomerByCondition(@RequestBody JSONObject params){
weCustomerService.getCustomerByCondition(params);
return AjaxResult.success("");
}
}