Преглед на файлове

bug
修复,走代理调用

xw преди 3 дни
родител
ревизия
533021d21a
променени са 1 файла, в които са добавени 33 реда и са изтрити 8 реда
  1. 33 8
      fs-service/src/main/java/com/fs/qwApi/service/impl/QwApiServiceImpl.java

+ 33 - 8
fs-service/src/main/java/com/fs/qwApi/service/impl/QwApiServiceImpl.java

@@ -1187,7 +1187,7 @@ public class QwApiServiceImpl implements QwApiService {
     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);
+            return JSON.parseObject(sendGet(QwApiConfig.getuserinfo, MapUtil.builder("code",code).build(), corpId,false), QwJsapiTicketResult.class);
         }
         QwJsapiTicketResult qwResult=new QwJsapiTicketResult();
 
@@ -1226,7 +1226,7 @@ public class QwApiServiceImpl implements QwApiService {
 
         QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(bookCorpId);
         if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
-            qwResult = JSON.parseObject(sendGet(QwApiConfig.getJsapiTicket, new HashMap<>(), bookCorpId), QwJsapiTicketResult.class);
+            qwResult = JSON.parseObject(sendGet(QwApiConfig.getJsapiTicket, new HashMap<>(), bookCorpId,false), QwJsapiTicketResult.class);
             qwResult.setCorpId(bookCorpId);
             redisCache.setCacheObject("ticket:corpId"+":"+bookCorpId,qwResult.getTicket(),1,TimeUnit.HOURS);
             return qwResult;
@@ -1271,7 +1271,7 @@ public class QwApiServiceImpl implements QwApiService {
 
         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 = JSON.parseObject(sendGet(QwApiConfig.jsapiTicket, MapUtil.builder("type", "agent_config").build(), corpId,false), QwJsapiTicketResult.class);
             qwResult.setCorpId(corpId);
             redisCache.setCacheObject("ticketApp:corpId"+":"+corpId,qwResult.getTicket(),1,TimeUnit.HOURS);
             return qwResult;
@@ -1372,7 +1372,7 @@ public class QwApiServiceImpl implements QwApiService {
     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);
+            return JSON.parseObject(sendGet(QwApiConfig.getMomentTaskResult, MapUtil.builder("jobid", jobid).build(), corpId,false), QwGetMomentTaskResult.class);
         }
 //        CompanyConfig companyConfig = companyConfigService.selectCompanyConfigByKey(corpId, "sys:qw:config");
 //        QWCompanyConfig qwCompanyConfig = JSON.parseObject(companyConfig.getConfigValue(), QWCompanyConfig.class);
@@ -1684,7 +1684,7 @@ public class QwApiServiceImpl implements QwApiService {
 //
         QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
         if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
-            return JSON.parseObject(sendGet(QwApiConfig.getDepartmentList, new HashMap<>(), corpId), QwDeptResult.class);
+            return JSON.parseObject(sendGet(QwApiConfig.getDepartmentList, new HashMap<>(), corpId, false), QwDeptResult.class);
         }
         String bookSecret = qwCompany.getOpenSecret();
 
@@ -1715,7 +1715,9 @@ public class QwApiServiceImpl implements QwApiService {
 //        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);
+            // 使用代理方式调用,使用应用Secret
+            String result = sendGet(QwApiConfig.externalcontactListUrl, MapUtil.builder("userid", userId).build(), corpId, false);
+            return JSON.parseObject(result, QwExternalContactListResult.class);
         }
         String appSecret = qwCompany.getOpenSecret();
         HttpClient httpClient = HttpClients.createDefault();
@@ -1740,7 +1742,9 @@ public class QwApiServiceImpl implements QwApiService {
     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);
+            // 使用代理方式调用,使用应用Secret
+            String result = sendGet(QwApiConfig.externalcontactUrl, MapUtil.builder("external_userid", userId).build(), corpId, false);
+            return JSON.parseObject(result, QwExternalContactResult.class);
         }
         String appSecret = getAppSecret(corpId);
 
@@ -1762,7 +1766,28 @@ public class QwApiServiceImpl implements QwApiService {
         return null;
     }
 
-    public String sendGet(String url, Map<String, String> map,String corpId) {
+    public String sendGet(String url, Map<String, String> map,String corpId,boolean bookSecret) {
+        QwCompany qwCompany = iQwCompanyService.selectQwCompanyByCorpId(corpId);
+        if(StringUtils.isNotEmpty(qwCompany.getQwApiUrl())){
+            QwApiParam param = new QwApiParam();
+            param.setUrl(url);
+            param.setCorpId(corpId);
+            param.setParam(map);
+            param.setBookSecret(bookSecret);
+            ResponseEntity<QwApiResult> response = new RestTemplate().postForEntity(qwCompany.getQwApiUrl() + "/get", 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 appSecret = getAppSecret(corpId);
         String token = getToken(corpId, appSecret);
         HttpClient httpClient = HttpClients.createDefault();