Bläddra i källkod

增加获取企业微信服务商token、open_corpid 信息

zhouy 3 månader sedan
förälder
incheckning
b158bce7d5

+ 6 - 3
qywx-sdk/src/main/java/com/usoftchina/qywx/sdk/DevSDK.java

@@ -3,6 +3,8 @@ package com.usoftchina.qywx.sdk;
 import com.usoftchina.qywx.sdk.config.QywxProperties;
 import com.usoftchina.qywx.sdk.dto.GetOpenCorpIDResp;
 import com.usoftchina.qywx.sdk.dto.GetProviderTokenResp;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.http.ResponseEntity;
 import org.springframework.ui.ModelMap;
 
@@ -10,7 +12,7 @@ import org.springframework.ui.ModelMap;
  * 代开发应用相关应用功能
  * */
 public class DevSDK  extends BaseSdk {
-
+    private Logger logger = LoggerFactory.getLogger(getClass());
     private String providerCropId;
 
     private String providerSecret;
@@ -51,11 +53,12 @@ public class DevSDK  extends BaseSdk {
 
     //获取企业主体的明文corpid转换为服务商主体的密文corpid
     public GetOpenCorpIDResp getCorpid_to_openCorpid(String cropId, String providerToken) {
+        logger.info("corpid_to_opencorpid : provider_access_token{} corpid{}", providerToken ,cropId);
         ResponseEntity<GetOpenCorpIDResp> resp = restTemplate.postForEntity(
-                baseUrl + "/cgi-bin/service/corpid_to_opencorpid?provider_access_token={access_token}",
+                baseUrl + "/cgi-bin/service/corpid_to_opencorpid?provider_access_token={provider_access_token}",
                 new ModelMap("corpid", cropId),
                 GetOpenCorpIDResp.class,
-                new ModelMap("access_token", providerToken));
+                new ModelMap("provider_access_token", providerToken));
         assertOK(resp);
         return resp.getBody();
     }

+ 1 - 1
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/config/QywxConfig.java

@@ -58,7 +58,7 @@ public class QywxConfig {
 
     @Bean
     public DevSDK devSDK(){
-        return new DevSDK(qywxProperties());
+        return new DevSDK(qywxProperties() , providerConfig.getCorpID(), providerConfig.getProviderSecret());
     }
     @Autowired
     private ProviderConfig providerConfig;

+ 4 - 3
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/manage/service/QywxCallbackService.java

@@ -2,6 +2,7 @@ package com.usoftchina.uas.office.qywx.manage.service;
 
 import com.alibaba.fastjson.JSON;
 import com.usoftchina.qywx.sdk.DevSDK;
+import com.usoftchina.qywx.sdk.ScheduleSdk;
 import com.usoftchina.qywx.sdk.dto.GetProviderTokenResp;
 import com.usoftchina.qywx.sdk.util.QywxConst;
 import com.usoftchina.qywx.sdk.weixin.AesException;
@@ -76,13 +77,13 @@ public class QywxCallbackService extends AbstractService {
      *  获取服务商授权Token
      * */
     public String getProviderToken(){
-       String providerToken = String.valueOf(redisTemplate.opsForValue().get("QywxProviderToken"));
-       if(StringUtils.isEmpty(providerToken)){
+       Object providerToken = redisTemplate.opsForValue().get("QywxProviderToken");
+       if(ObjectUtils.isEmpty(providerToken)){
            GetProviderTokenResp resp = devSDK.getProviderToken();
            providerToken = resp.getProvider_access_token();
            redisTemplate.opsForValue().set(QywxConst.PROVIDER_TOKEN, providerToken , resp.getExpires_in(), TimeUnit.SECONDS);
        }
-       return providerToken;
+       return String.valueOf(providerToken);
     }
     /**
      * 获取企业cropID