|
|
@@ -1,15 +1,18 @@
|
|
|
package com.fs.qwApi.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.exception.base.BaseException;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.qw.domain.QwCompany;
|
|
|
import com.fs.qw.param.QwUpdateContactWayParam;
|
|
|
import com.fs.qw.service.IQwCompanyService;
|
|
|
+import com.fs.qwApi.Params.QwApiParam;
|
|
|
import com.fs.qwApi.Result.*;
|
|
|
import com.fs.qwApi.config.QwApiConfig;
|
|
|
import com.fs.qwApi.domain.*;
|
|
|
@@ -31,7 +34,14 @@ import org.apache.http.entity.mime.MultipartEntityBuilder;
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.core.io.FileSystemResource;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
@@ -46,7 +56,6 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Service
|
|
|
public class QwApiServiceImpl implements QwApiService {
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
IQwCompanyService iQwCompanyService;
|
|
|
// @Autowired
|
|
|
@@ -68,7 +77,6 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwGroupChatListResult groupChatList(ArrayList<String> ownerFilterList, String cursor, String corpId) {
|
|
|
-
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
|
|
|
JSONObject ownerFilter=new JSONObject();
|
|
|
@@ -293,7 +301,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwGetGroupmsgListV2Result getGroupmsgListV2(QwGetGroupmsgListV2Param param,String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.getGroupmsgListV2, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getGroupmsgListV2, param,corpId,false);
|
|
|
QwGetGroupmsgListV2Result qwGetGroupmsgListV2Result = JSON.parseObject(json, QwGetGroupmsgListV2Result.class);
|
|
|
return qwGetGroupmsgListV2Result;
|
|
|
}
|
|
|
@@ -304,7 +312,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwGetGroupmsgTaskResult getGroupmsgTask(QwGetGroupMsgTask task,String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.getGroupmsgTask, task,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getGroupmsgTask, task,corpId,false);
|
|
|
QwGetGroupmsgTaskResult qwGetGroupmsgTaskResult = JSON.parseObject(json, QwGetGroupmsgTaskResult.class);
|
|
|
return qwGetGroupmsgTaskResult;
|
|
|
|
|
|
@@ -315,7 +323,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwGroupmsgSendResult getGroupmsgSendResult(QwGetGroupmsgSendParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getGroupmsgSendResult, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getGroupmsgSendResult, param,corpId,false);
|
|
|
QwGroupmsgSendResult qwGroupmsgSendResult = JSON.parseObject(json, QwGroupmsgSendResult.class);
|
|
|
return qwGroupmsgSendResult;
|
|
|
}
|
|
|
@@ -626,6 +634,24 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
// }
|
|
|
|
|
|
public QwUploadImgResult uploadimgs(String url, String corpId) throws IOException {
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ QwApiParam param = new QwApiParam();
|
|
|
+ param.setUrl(url);
|
|
|
+ param.setCorpId(corpId);
|
|
|
+ ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/uploadImg", param, QwApiResult.class);
|
|
|
+ QwApiResult result = response.getBody();
|
|
|
+ if (result == null) {
|
|
|
+ log.error("返回错误,返回数据为空!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("请求结果:{}", JSON.toJSONString(result));
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ log.error("接口请求错误:{}", result.getMsg());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return JSON.parseObject(result.getData(), QwUploadImgResult.class);
|
|
|
+ }
|
|
|
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
// CompanyConfig companyConfig = companyConfigService.selectCompanyConfigByKey(corpId, "sys:qw:config");
|
|
|
@@ -636,8 +662,6 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
// String open_corpid = qwCompanyConfig.getOpen_corpid();
|
|
|
// String openSecret = qwCompanyConfig.getOpen_Secret();
|
|
|
|
|
|
- QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
-
|
|
|
|
|
|
String openSecret = qwCompany.getOpenSecret();
|
|
|
|
|
|
@@ -684,6 +708,35 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwUploadResult upload(File file, String type,String corpId) throws IOException {
|
|
|
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ QwApiParam param = new QwApiParam();
|
|
|
+ param.setFile(file);
|
|
|
+ param.setCorpId(corpId);
|
|
|
+ MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
|
|
|
+ body.add("file", new FileSystemResource(file));
|
|
|
+ body.add("corpId", corpId);
|
|
|
+ body.add("type", type);
|
|
|
+ // 设置请求头
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
|
|
+ // 创建请求实体
|
|
|
+ org.springframework.http.HttpEntity<MultiValueMap<String, Object>> requestEntity = new org.springframework.http.HttpEntity<>(body, headers);
|
|
|
+ ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/uploadFile", requestEntity, QwApiResult.class);
|
|
|
+ QwApiResult result = response.getBody();
|
|
|
+ if (result == null) {
|
|
|
+ log.error("返回错误,返回数据为空!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("请求结果:{}", JSON.toJSONString(result));
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ log.error("接口请求错误:{}", result.getMsg());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return JSON.parseObject(result.getData(), QwUploadResult.class);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
// CompanyConfig companyConfig = companyConfigService.selectCompanyConfigByKey(corpId, "sys:qw:config");
|
|
|
// QWCompanyConfig qwCompanyConfig = JSON.parseObject(companyConfig.getConfigValue(), QWCompanyConfig.class);
|
|
|
@@ -694,8 +747,6 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
// String open_corpid = qwCompanyConfig.getOpen_corpid();
|
|
|
// String openSecret = qwCompanyConfig.getOpen_Secret();
|
|
|
|
|
|
- QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
-
|
|
|
String openSecret = qwCompany.getOpenSecret();
|
|
|
|
|
|
String token = getToken(corpId, openSecret);
|
|
|
@@ -808,7 +859,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwAddContactWayResult addContactWay(QwAddContactWayParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.addContactWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.addContactWay, param,corpId, false);
|
|
|
QwAddContactWayResult qwAddContactWayResult = JSON.parseObject(json, QwAddContactWayResult.class);
|
|
|
return qwAddContactWayResult;
|
|
|
|
|
|
@@ -818,7 +869,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwGetContactWayResult getContactWay(QwGetContactWayParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.getContactWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getContactWay, param,corpId, false);
|
|
|
QwGetContactWayResult qwGetContactWayResult = JSON.parseObject(json, QwGetContactWayResult.class);
|
|
|
return qwGetContactWayResult;
|
|
|
}
|
|
|
@@ -827,7 +878,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwListContactWayReslut listContactWay(QwListContactWayParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.listContactWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.listContactWay, param,corpId, false);
|
|
|
QwListContactWayReslut qwListContactWayReslut = JSON.parseObject(json, QwListContactWayReslut.class);
|
|
|
return qwListContactWayReslut;
|
|
|
|
|
|
@@ -836,7 +887,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
/** 更新企业已配置的「联系我」方式 */
|
|
|
@Override
|
|
|
public QwResult updateContactWay(QwUpdateContactWayParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.updateContactWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.updateContactWay, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
|
|
|
@@ -846,14 +897,14 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwResult delContactWay(QwGetContactWayParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.delContactWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.delContactWay, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwAddContactWayResult addJoinWay(QwAddJoinWayParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.addJoinWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.addJoinWay, param,corpId, false);
|
|
|
QwAddContactWayResult qwAddContactWayResult = JSON.parseObject(json, QwAddContactWayResult.class);
|
|
|
return qwAddContactWayResult;
|
|
|
}
|
|
|
@@ -862,7 +913,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QeGetJoinWayResult getJoinWay(QwGetContactWayParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.getJoinWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getJoinWay, param,corpId, false);
|
|
|
QeGetJoinWayResult qeGetJoinWayResult = JSON.parseObject(json, QeGetJoinWayResult.class);
|
|
|
return qeGetJoinWayResult;
|
|
|
}
|
|
|
@@ -870,7 +921,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
/** 更新客户群进群方式配置 */
|
|
|
@Override
|
|
|
public QwResult updateJoinWay(QwAddJoinWayParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.updateJoinWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.updateJoinWay, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
|
|
|
@@ -880,7 +931,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwResult delJoinWay(QwGetContactWayParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.delJoinWay, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.delJoinWay, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
|
|
|
@@ -889,20 +940,20 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
/** 获取客户群统计数据 */
|
|
|
@Override
|
|
|
public QwUserBehaviorDataResult getUserBehaviorData(QwUserBehaviorDataParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getUserBehaviorData, param, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getUserBehaviorData, param, corpId, false);
|
|
|
return JSON.parseObject(json, QwUserBehaviorDataResult.class);
|
|
|
}
|
|
|
|
|
|
/** 获取群聊统计数据 */
|
|
|
@Override
|
|
|
public QwGroupChatStatisticResult getGroupChatStatistic(QwGroupChatStatisticParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.groupChatStatistic, param, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.groupChatStatistic, param, corpId, false);
|
|
|
return JSON.parseObject(json, QwGroupChatStatisticResult.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwGroupChatStatisticResult getGroupChatStatisticByOwner(QwGroupChatStatisticParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.groupChatStatisticByOwner, param, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.groupChatStatisticByOwner, param, corpId, false);
|
|
|
return JSON.parseObject(json, QwGroupChatStatisticResult.class);
|
|
|
}
|
|
|
|
|
|
@@ -914,7 +965,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
|
|
|
@Override
|
|
|
public QwOpenidResult externalcontactToOpenid(QwOpenidByExternalcontactParams param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.externalContactConvertToOpenid, param, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.externalContactConvertToOpenid, param, corpId, false);
|
|
|
return JSON.parseObject(json, QwOpenidResult.class);
|
|
|
}
|
|
|
|
|
|
@@ -1085,6 +1136,29 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public String getServerQwUserName(String corpId,String Secret, String userid) {
|
|
|
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ QwApiParam param = new QwApiParam();
|
|
|
+ param.setUrl(QwApiConfig.getServerQwUserName);
|
|
|
+ param.setCorpId(corpId);
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("userid", userid);
|
|
|
+ param.setParam(map);
|
|
|
+ ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/post", param, QwApiResult.class);
|
|
|
+ QwApiResult result = response.getBody();
|
|
|
+ if (result == null) {
|
|
|
+ log.error("返回错误,返回数据为空!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("请求结果:{}", JSON.toJSONString(result));
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ log.error("接口请求错误:{}", result.getMsg());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result.getData());
|
|
|
+ return jsonObject.getString("name");
|
|
|
+ }
|
|
|
+
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
String name = "";
|
|
|
try {
|
|
|
@@ -1111,7 +1185,10 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwJsapiTicketResult getQwUserid(String code,String corpId,String appSecret) {
|
|
|
-
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ return JSON.parseObject(sendGet(QwApiConfig.getuserinfo, MapUtil.builder("code",code).build(), corpId), QwJsapiTicketResult.class);
|
|
|
+ }
|
|
|
QwJsapiTicketResult qwResult=new QwJsapiTicketResult();
|
|
|
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
@@ -1147,6 +1224,14 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(bookCorpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ qwResult = JSON.parseObject(sendGet(QwApiConfig.getJsapiTicket, new HashMap<>(), bookCorpId), QwJsapiTicketResult.class);
|
|
|
+ qwResult.setCorpId(bookCorpId);
|
|
|
+ redisCache.setCacheObject("ticket:corpId"+":"+bookCorpId,qwResult.getTicket(),1,TimeUnit.HOURS);
|
|
|
+ return qwResult;
|
|
|
+ }
|
|
|
+
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
try {
|
|
|
URIBuilder builder = new URIBuilder(QwApiConfig.getJsapiTicket);
|
|
|
@@ -1184,6 +1269,14 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ qwResult = JSON.parseObject(sendGet(QwApiConfig.jsapiTicket, MapUtil.builder("type", "agent_config").build(), corpId), QwJsapiTicketResult.class);
|
|
|
+ qwResult.setCorpId(corpId);
|
|
|
+ redisCache.setCacheObject("ticketApp:corpId"+":"+corpId,qwResult.getTicket(),1,TimeUnit.HOURS);
|
|
|
+ return qwResult;
|
|
|
+ }
|
|
|
+
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
try {
|
|
|
URIBuilder builder = new URIBuilder(QwApiConfig.jsapiTicket);
|
|
|
@@ -1268,7 +1361,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwAddMomentTaskResult addMomentTask(QwAddMomentTask qwAddMomentTask, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.addMomentTask, qwAddMomentTask, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.addMomentTask, qwAddMomentTask, corpId, false);
|
|
|
QwAddMomentTaskResult qwAddMomentTaskResult = JSON.parseObject(json, QwAddMomentTaskResult.class);
|
|
|
return qwAddMomentTaskResult;
|
|
|
}
|
|
|
@@ -1277,14 +1370,16 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwGetMomentTaskResult getMomentTaskResult(String jobid, String corpId) {
|
|
|
-
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ return JSON.parseObject(sendGet(QwApiConfig.getMomentTaskResult, MapUtil.builder("jobid", jobid).build(), corpId), QwGetMomentTaskResult.class);
|
|
|
+ }
|
|
|
// CompanyConfig companyConfig = companyConfigService.selectCompanyConfigByKey(corpId, "sys:qw:config");
|
|
|
// QWCompanyConfig qwCompanyConfig = JSON.parseObject(companyConfig.getConfigValue(), QWCompanyConfig.class);
|
|
|
// String corpId = qwCompanyConfig.getCorpId();
|
|
|
// String appSecret = qwCompanyConfig.getAppSecret();
|
|
|
// String corpId = qwCompanyConfig.getOpen_corpid();
|
|
|
// String appSecret = qwCompanyConfig.getOpen_Secret();
|
|
|
- QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
|
|
|
String appSecret = qwCompany.getOpenSecret();
|
|
|
|
|
|
@@ -1312,7 +1407,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwResult cancelMomentTask(QwCancelMomentTask qwCancelMomentTask, String corpId) {
|
|
|
- String result = sendPost(QwApiConfig.cancelMomentTask, qwCancelMomentTask, corpId);
|
|
|
+ String result = sendPost(QwApiConfig.cancelMomentTask, qwCancelMomentTask, corpId, false);
|
|
|
|
|
|
return JSON.parseObject(result, QwResult.class);
|
|
|
}
|
|
|
@@ -1322,7 +1417,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwGetMomentTaskGResult getMomentTaskGResult(QwGetMomentTask qwGetMomentTask, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getMomentTask, qwGetMomentTask, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getMomentTask, qwGetMomentTask, corpId, false);
|
|
|
return JSON.parseObject(json, QwGetMomentTaskGResult.class);
|
|
|
}
|
|
|
|
|
|
@@ -1331,7 +1426,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwGetMomentCustomerListResult getMomentCustomerList(QwGetMomentCustomerListParam customerListParam, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getMomentCustomerList, customerListParam, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getMomentCustomerList, customerListParam, corpId, false);
|
|
|
return JSON.parseObject(json, QwGetMomentCustomerListResult.class);
|
|
|
}
|
|
|
|
|
|
@@ -1340,7 +1435,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwGetMomentCustomerListResult getMomentSendResult(QwGetMomentSendResultParam qwGetMomentSendResultParam, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getMomentSendResult, qwGetMomentSendResultParam, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getMomentSendResult, qwGetMomentSendResultParam, corpId, false);
|
|
|
return JSON.parseObject(json, QwGetMomentCustomerListResult.class);
|
|
|
}
|
|
|
|
|
|
@@ -1349,7 +1444,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
*/
|
|
|
@Override
|
|
|
public QwGetMomentCommentsParamResult getMomentComments(QwGetMomentCommentsParam qwGetMomentCommentsParam, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getMomentComments, qwGetMomentCommentsParam, corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getMomentComments, qwGetMomentCommentsParam, corpId, false);
|
|
|
return JSON.parseObject(json, QwGetMomentCommentsParamResult.class);
|
|
|
}
|
|
|
|
|
|
@@ -1365,7 +1460,29 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
- public String sendPost(String url, Object param, String corpId) {
|
|
|
+ public String sendPost(String url, Object body, String corpId, boolean bookSecret) {
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ log.info("获取请求打印---------------------》{}",qwCompany);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ QwApiParam param = new QwApiParam();
|
|
|
+ param.setUrl(url);
|
|
|
+ param.setCorpId(corpId);
|
|
|
+ param.setBody(JSON.parseObject(JSON.toJSONString(body)));
|
|
|
+ param.setBookSecret(bookSecret);
|
|
|
+ ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/post", param, QwApiResult.class);
|
|
|
+ QwApiResult result = response.getBody();
|
|
|
+ log.info("打印结果---------------------》{}",result);
|
|
|
+ if (result == null) {
|
|
|
+ log.error("返回错误,返回数据为空!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("请求结果:{}", JSON.toJSONString(result));
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ log.error("接口请求错误:{}", result.getMsg());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return result.getData();
|
|
|
+ }
|
|
|
int maxRetries = 3; // 最大重试次数
|
|
|
int retryCount = 0; // 当前重试次数
|
|
|
// 1. 获取配置信息(可放在循环外,但要确保每次都能获取到最新的token)
|
|
|
@@ -1378,7 +1495,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
builder.setParameter("access_token", getToken(corpId, appSecret));
|
|
|
URI uri = builder.build();
|
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
|
- httpPost.setEntity(new StringEntity(JSON.toJSONString(param), StandardCharsets.UTF_8));
|
|
|
+ httpPost.setEntity(new StringEntity(JSON.toJSONString(body), StandardCharsets.UTF_8));
|
|
|
HttpResponse response = httpClient.execute(httpPost);
|
|
|
// 3. 解析结果
|
|
|
String reJson = EntityUtils.toString(response.getEntity());
|
|
|
@@ -1423,20 +1540,30 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
// return null;
|
|
|
// }
|
|
|
|
|
|
- public String sendBookPost(String url,Object param,String corpId){
|
|
|
-
|
|
|
-// CompanyConfig companyConfig = companyConfigService.selectCompanyConfigByKey(corpId, "sys:qw:config");
|
|
|
-// QWCompanyConfig qwCompanyConfig = JSON.parseObject(companyConfig.getConfigValue(), QWCompanyConfig.class);
|
|
|
-//获取通讯录的
|
|
|
-// String corpId = qwCompanyConfig.getCorpId();
|
|
|
-// String bookSecret = qwCompanyConfig.getBookSecret();
|
|
|
-// String corpId = qwCompanyConfig.getOpen_corpid();
|
|
|
-// String bookSecret = qwCompanyConfig.getOpen_Secret();
|
|
|
-
|
|
|
+ public String sendBookPost(String url,QwOpenidByUserParams body,String corpId){
|
|
|
QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
-
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ QwApiParam param = new QwApiParam();
|
|
|
+ param.setUrl(url);
|
|
|
+ param.setCorpId(corpId);
|
|
|
+ param.setBookSecret(true);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("userid", body.getUserid());
|
|
|
+ param.setBody(map);
|
|
|
+ ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/post", param, QwApiResult.class);
|
|
|
+ QwApiResult result = response.getBody();
|
|
|
+ if (result == null) {
|
|
|
+ log.error("返回错误,返回数据为空!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("请求结果:{}", JSON.toJSONString(result));
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ log.error("接口请求错误:{}", result.getMsg());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return result.getData();
|
|
|
+ }
|
|
|
String bookSecret = qwCompany.getServerBookSecret();
|
|
|
-
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
try {
|
|
|
URIBuilder builder = new URIBuilder(url);
|
|
|
@@ -1444,7 +1571,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
builder.setParameter("access_token", getToken(corpId,bookSecret));
|
|
|
URI uri = builder.build();
|
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
|
- httpPost.setEntity( new StringEntity(JSON.toJSONString(param),StandardCharsets.UTF_8));
|
|
|
+ httpPost.setEntity( new StringEntity(JSON.toJSONString(body),StandardCharsets.UTF_8));
|
|
|
HttpResponse response = httpClient.execute(httpPost);
|
|
|
String reJson = EntityUtils.toString(response.getEntity());
|
|
|
return reJson;
|
|
|
@@ -1501,8 +1628,30 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
|
|
|
@Override
|
|
|
public QwUserIdResult getUserList(String corpId) {
|
|
|
- HttpClient httpClient = HttpClients.createDefault();
|
|
|
QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("limit", 10000);
|
|
|
+ String res = sendPost(QwApiConfig.getUserListUrl, map, corpId, true);
|
|
|
+// QwApiParam param = new QwApiParam();
|
|
|
+// param.setUrl(QwApiConfig.getUserListUrl);
|
|
|
+// param.setCorpId(corpId);
|
|
|
+// param.setBookSecret(true);
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+// map.put("limit", 10000);
|
|
|
+// param.setBody(map);
|
|
|
+// ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/post", param, QwApiResult.class);
|
|
|
+// QwApiResult result = response.getBody();
|
|
|
+// if (result == null) {
|
|
|
+// throw new BaseException("返回错误,返回数据为空!");
|
|
|
+// }
|
|
|
+// log.info("请求结果:{}", JSON.toJSONString(result));
|
|
|
+// if (result.getCode() != 200) {
|
|
|
+// throw new BaseException("接口请求错误:{}", result.getMsg());
|
|
|
+// }
|
|
|
+ return JSON.parseObject(res, QwUserIdResult.class);
|
|
|
+ }
|
|
|
+ HttpClient httpClient = HttpClients.createDefault();
|
|
|
String bookSecret = qwCompany.getServerBookSecret();
|
|
|
try {
|
|
|
URIBuilder builder = new URIBuilder(QwApiConfig.getUserListUrl);
|
|
|
@@ -1534,7 +1683,9 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
// String bookSecret = qwCompanyConfig.getOpen_Secret();
|
|
|
//
|
|
|
QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
-
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ return JSON.parseObject(sendGet(QwApiConfig.getDepartmentList, new HashMap<>(), corpId), QwDeptResult.class);
|
|
|
+ }
|
|
|
String bookSecret = qwCompany.getOpenSecret();
|
|
|
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
@@ -1563,7 +1714,9 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
// String corpId = qwCompanyConfig.getOpen_corpid();
|
|
|
// String appSecret = qwCompanyConfig.getOpen_Secret();
|
|
|
QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
-
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ return JSON.parseObject(sendGet(QwApiConfig.externalcontactListUrl, MapUtil.builder("userid", userId).build(), corpId), QwExternalContactListResult.class);
|
|
|
+ }
|
|
|
String appSecret = qwCompany.getOpenSecret();
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
try {
|
|
|
@@ -1585,6 +1738,10 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
|
|
|
@Override
|
|
|
public QwExternalContactResult getExternalcontact(String userId,String corpId) {
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ return JSON.parseObject(sendGet(QwApiConfig.externalcontactUrl, MapUtil.builder("external_userid", userId).build(), corpId), QwExternalContactResult.class);
|
|
|
+ }
|
|
|
String appSecret = getAppSecret(corpId);
|
|
|
|
|
|
String token = getToken(corpId, appSecret);
|
|
|
@@ -1605,30 +1762,48 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public String sendGet(String url, Map<String, String> map,String corpId) {
|
|
|
+ String appSecret = getAppSecret(corpId);
|
|
|
+ String token = getToken(corpId, appSecret);
|
|
|
+ HttpClient httpClient = HttpClients.createDefault();
|
|
|
+ try {
|
|
|
+ URIBuilder builder = new URIBuilder(url);
|
|
|
+ builder.setParameter("access_token", token);
|
|
|
+ map.forEach(builder::setParameter);
|
|
|
+ URI uri = builder.build();
|
|
|
+ HttpGet httpGet = new HttpGet(uri);
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ return EntityUtils.toString(response.getEntity());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public QwExternalContactAllListResult getAllExternalcontactList(QwExternalListParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.externalcontactAllLlistUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.externalcontactAllLlistUrl, param,corpId, false);
|
|
|
QwExternalContactAllListResult qwResult = JSON.parseObject(json, QwExternalContactAllListResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwExternalContactRemarkResult externalcontactRemark(QwExternalContactRemarkParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.externalcontactRemarkUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.externalcontactRemarkUrl, param,corpId, false);
|
|
|
QwExternalContactRemarkResult qwResult = JSON.parseObject(json, QwExternalContactRemarkResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwTagResult getTag(QwTagParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getTagUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getTagUrl, param,corpId, false);
|
|
|
QwTagResult qwResult = JSON.parseObject(json, QwTagResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
@Override
|
|
|
public QwResult sendWelcomeMsg(SendWelcomeMsgParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.sendWelcomeMsg,param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.sendWelcomeMsg,param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
@@ -1693,7 +1868,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwUseridResult getuseridBymobile(QwUseridBymobileParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.getuseridBymobile, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getuseridBymobile, param,corpId, false);
|
|
|
QwUseridResult qwResult = JSON.parseObject(json, QwUseridResult.class);
|
|
|
|
|
|
return qwResult;
|
|
|
@@ -1702,7 +1877,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwUseridResult getuseridByEmail(QwUseridByEmailParam param, String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.getuseridByEmail, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getuseridByEmail, param,corpId, false);
|
|
|
QwUseridResult qwResult = JSON.parseObject(json, QwUseridResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
@@ -1711,7 +1886,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwAddTagResult addTag(QwAddTagParam param,String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.addTagUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.addTagUrl, param,corpId, false);
|
|
|
QwAddTagResult qwResult = JSON.parseObject(json, QwAddTagResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
@@ -1719,7 +1894,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwResult editTag(QwEditTagParam param,String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.editTagUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.editTagUrl, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
@@ -1727,91 +1902,91 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
@Override
|
|
|
public QwResult delTag(QwTagParam param,String corpId) {
|
|
|
|
|
|
- String json = sendPost(QwApiConfig.delTagUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.delTagUrl, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwTransferCustomerResult transferCustomer(QwTransferCustomerParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.transferCustomerUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.transferCustomerUrl, param,corpId, false);
|
|
|
QwTransferCustomerResult qwResult = JSON.parseObject(json, QwTransferCustomerResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwGetTransferResult getTransfer(QwGetTransferParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getTransferUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getTransferUrl, param,corpId, false);
|
|
|
QwGetTransferResult qwResult = JSON.parseObject(json, QwGetTransferResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwGroupChatTransferResult groupChatTransfer(QwGroupChatTransferParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.groupChatTransferUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.groupChatTransferUrl, param,corpId, false);
|
|
|
QwGroupChatTransferResult qwResult = JSON.parseObject(json, QwGroupChatTransferResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwUnassignedListResult getUnassignedList(QwUnassignedListParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getUnassignedListUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getUnassignedListUrl, param,corpId, false);
|
|
|
QwUnassignedListResult qwResult = JSON.parseObject(json, QwUnassignedListResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwTransferCustomerResignedResult resignedTransferCustomer(QwTransferCustomerResignedParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.resignedTransferCustomerUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.resignedTransferCustomerUrl, param,corpId, false);
|
|
|
QwTransferCustomerResignedResult qwResult = JSON.parseObject(json, QwTransferCustomerResignedResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwGetTransferResult getResignedTransfer(QwGetTransferParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.getResignedTransferUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.getResignedTransferUrl, param,corpId, false);
|
|
|
QwGetTransferResult qwResult = JSON.parseObject(json, QwGetTransferResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwGroupChatTransferResult resignedGroupChatTransfer(QwGroupChatTransferParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.resignedGroupChatTransferUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.resignedGroupChatTransferUrl, param,corpId, false);
|
|
|
QwGroupChatTransferResult qwResult = JSON.parseObject(json, QwGroupChatTransferResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwResult editUserTag(QwEditUserTagParam param,String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.editUserTagUrl, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.editUserTagUrl, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwSendMsgResult sendMsg(QwSendMsgParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.sendMsg, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.sendMsg, param,corpId, false);
|
|
|
QwSendMsgResult qwResult = JSON.parseObject(json, QwSendMsgResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwLinkListResult linkList(QwParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.linkList, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.linkList, param,corpId, false);
|
|
|
QwLinkListResult qwResult = JSON.parseObject(json, QwLinkListResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwLinkGetResult linkGet(QwLinkGetParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.linkGet, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.linkGet, param,corpId, false);
|
|
|
QwLinkGetResult qwResult = JSON.parseObject(json, QwLinkGetResult.class);
|
|
|
return qwResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public QwLinkCreateResult linkCreate(QwLinkCreateParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.linkCreate, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.linkCreate, param,corpId, false);
|
|
|
QwLinkCreateResult qwResult = JSON.parseObject(json, QwLinkCreateResult.class);
|
|
|
if(qwResult.getErrcode() != 0) throw new BaseException("创建获客链接错误:" + qwResult.getErrmsg());
|
|
|
return qwResult;
|
|
|
@@ -1819,7 +1994,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
|
|
|
@Override
|
|
|
public QwResult linkUpdate(QwLinkCreateParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.linkUpdate, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.linkUpdate, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
if(qwResult.getErrcode() != 0) throw new BaseException("修改获客链接错误:" + qwResult.getErrmsg());
|
|
|
return qwResult;
|
|
|
@@ -1827,7 +2002,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
|
|
|
@Override
|
|
|
public QwResult linkDelete(QwLinkGetParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.linkDelete, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.linkDelete, param,corpId, false);
|
|
|
QwResult qwResult = JSON.parseObject(json, QwResult.class);
|
|
|
if(qwResult.getErrcode() != 0) throw new BaseException("删除获客链接错误:" + qwResult.getErrmsg());
|
|
|
return qwResult;
|
|
|
@@ -1835,7 +2010,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
|
|
|
@Override
|
|
|
public QwLinkCustomerResult linkCustomer(QwLinkCustomerParam param, String corpId) {
|
|
|
- String json = sendPost(QwApiConfig.linkCustomer, param,corpId);
|
|
|
+ String json = sendPost(QwApiConfig.linkCustomer, param,corpId, false);
|
|
|
QwLinkCustomerResult qwResult = JSON.parseObject(json, QwLinkCustomerResult.class);
|
|
|
if(qwResult.getErrcode() != 0) throw new BaseException("获客链接错误:" + qwResult.getErrmsg());
|
|
|
return qwResult;
|
|
|
@@ -1845,6 +2020,26 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
* 封装的post请求
|
|
|
*/
|
|
|
public String templateResultPost(JSONObject object, String url,String corpId){
|
|
|
+ QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+ if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
|
|
|
+ QwApiParam param = new QwApiParam();
|
|
|
+ param.setUrl(url);
|
|
|
+ param.setCorpId(corpId);
|
|
|
+ param.setBody(JSON.parseObject(JSON.toJSONString(object)));
|
|
|
+ ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/post", param, QwApiResult.class);
|
|
|
+ QwApiResult result = response.getBody();
|
|
|
+ if (result == null) {
|
|
|
+ log.error("返回错误,返回数据为空!");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("请求结果:{}", JSON.toJSONString(result));
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ log.error("接口请求错误:{}", result.getMsg());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return result.getData();
|
|
|
+ }
|
|
|
+
|
|
|
HttpClient httpClient = HttpClients.createDefault();
|
|
|
URIBuilder builder = null;
|
|
|
try {
|
|
|
@@ -1855,7 +2050,7 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
//// String appSecret = qwCompanyConfig.getAppSecret();
|
|
|
// String corpId = qwCompanyConfig.getOpen_corpid();
|
|
|
// String appSecret = qwCompanyConfig.getOpen_Secret();
|
|
|
- QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
+// QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
|
|
|
|
|
|
String appSecret = qwCompany.getOpenSecret();
|
|
|
|
|
|
@@ -1879,4 +2074,22 @@ public class QwApiServiceImpl implements QwApiService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 公用方法3:JSON 字符串 转为泛型 Map(非 String 类型值场景,扩展用)
|
|
|
+ * @param jsonStr JSON 字符串
|
|
|
+ * @param typeReference 泛型类型引用
|
|
|
+ * @param <T> Map 泛型类型
|
|
|
+ * @return 转换后的泛型 Map,入参无效则返回 null
|
|
|
+ */
|
|
|
+ public static <T extends Map<?, ?>> T jsonStrToGenericMap(String jsonStr, TypeReference<T> typeReference) {
|
|
|
+ if (jsonStr == null || jsonStr.trim().isEmpty() || typeReference == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return JSONObject.parseObject(jsonStr, typeReference);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("JSON 字符串转泛型 Map 失败:" + e.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|