|
@@ -437,30 +437,25 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
Integer WXCompanyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", WXCompanyId));
|
|
|
- if (wxCorpInfo!=null && keyword!=null && keyword.trim().length()!=0 && departmentId == -1){
|
|
|
- if (wxCorpInfo.getSaasSyncContact()==1){
|
|
|
- String AccessUrl = "https://qyapi.weixin.qq.com/cgi-bin/service/get_provider_token";
|
|
|
- String url = "https://qyapi.weixin.qq.com/cgi-bin/service/contact/search?provider_access_token=ACCESS_TOKEN";
|
|
|
- HttpHeaders headers = new HttpHeaders();
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
- headers.setContentType(type);
|
|
|
- headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
- //获取服务商id
|
|
|
- JSONObject AccessRequestMap = new JSONObject();
|
|
|
- AccessRequestMap.put("corpid", corpId);
|
|
|
- AccessRequestMap.put("provider_secret", providerSecret);
|
|
|
- HttpEntity<JSONObject> AccessEntity = new HttpEntity<>(AccessRequestMap, headers);
|
|
|
- ResponseEntity<String> AccessResponseEntity = restTemplate.postForEntity(AccessUrl, AccessEntity, String.class);
|
|
|
- String providerToken ="";
|
|
|
- if (AccessResponseEntity.getStatusCode() == HttpStatus.OK){
|
|
|
- String AccessResp = AccessResponseEntity.getBody();
|
|
|
- JSONObject json = JSONObject.parseObject(AccessResp);
|
|
|
- providerToken = json.getString("provider_access_token");
|
|
|
- }else {
|
|
|
- httpRespMsg.setError("服务商token获取失败");
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
+ if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact()==1 && org.apache.commons.lang3.StringUtils.isNotBlank(keyword) && departmentId == -1){
|
|
|
+ String AccessUrl = "https://qyapi.weixin.qq.com/cgi-bin/service/get_provider_token";
|
|
|
+ String url = "https://qyapi.weixin.qq.com/cgi-bin/service/contact/search?provider_access_token=ACCESS_TOKEN";
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
|
|
|
+ headers.setContentType(type);
|
|
|
+ headers.add("Accept", MediaType.APPLICATION_JSON.toString());
|
|
|
+ //获取服务商id
|
|
|
+ JSONObject AccessRequestMap = new JSONObject();
|
|
|
+ AccessRequestMap.put("corpid", corpId);
|
|
|
+ AccessRequestMap.put("provider_secret", providerSecret);
|
|
|
+ HttpEntity<JSONObject> AccessEntity = new HttpEntity<>(AccessRequestMap, headers);
|
|
|
+ ResponseEntity<String> AccessResponseEntity = restTemplate.postForEntity(AccessUrl, AccessEntity, String.class);
|
|
|
+ String providerToken ="";
|
|
|
+ if (AccessResponseEntity.getStatusCode() == HttpStatus.OK){
|
|
|
+ String AccessResp = AccessResponseEntity.getBody();
|
|
|
+ JSONObject json = JSONObject.parseObject(AccessResp);
|
|
|
+ providerToken = json.getString("provider_access_token");
|
|
|
//搜索通讯录名单
|
|
|
url = url.replace("ACCESS_TOKEN", providerToken);
|
|
|
JSONObject requestMap = new JSONObject();
|
|
@@ -474,8 +469,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
|
|
|
if (ResponseEntity.getStatusCode() == HttpStatus.OK) {
|
|
|
String resp = ResponseEntity.getBody();
|
|
|
- JSONObject json = JSONObject.parseObject(resp);
|
|
|
- JSONObject queryResult = json.getJSONObject("query_result");
|
|
|
+ JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
+ JSONObject queryResult = respJson.getJSONObject("query_result");
|
|
|
if (!queryResult.isEmpty()){
|
|
|
JSONArray jsonArray = queryResult.getJSONObject("user").getJSONArray("open_userid");
|
|
|
if (jsonArray.size()!=0){
|
|
@@ -486,24 +481,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
data.put("total",0);
|
|
|
httpRespMsg.data=data;
|
|
|
return httpRespMsg;
|
|
|
- }else {
|
|
|
- HashMap<String, Object> data = new HashMap<>();
|
|
|
- ArrayList<Object> records = new ArrayList<>();
|
|
|
- data.put("records",records);
|
|
|
- data.put("total",0);
|
|
|
- httpRespMsg.data=data;
|
|
|
- return httpRespMsg;
|
|
|
}
|
|
|
- }else{
|
|
|
- HashMap<String, Object> data = new HashMap<>();
|
|
|
- ArrayList<Object> records = new ArrayList<>();
|
|
|
- data.put("records",records);
|
|
|
- data.put("total",0);
|
|
|
- httpRespMsg.data=data;
|
|
|
- return httpRespMsg;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ HashMap<String, Object> data = new HashMap<>();
|
|
|
+ ArrayList<Object> records = new ArrayList<>();
|
|
|
+ data.put("records",records);
|
|
|
+ data.put("total",0);
|
|
|
+ httpRespMsg.data=data;
|
|
|
+ return httpRespMsg;
|
|
|
}
|
|
|
try {
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|