فهرست منبع

建科统一身份认证平台接入

S0025136190 5 ماه پیش
والد
کامیت
195b7bbab1
1فایلهای تغییر یافته به همراه17 افزوده شده و 12 حذف شده
  1. 17 12
      takai-system/src/main/java/com/takai/system/service/impl/JkApiServiceImpl.java

+ 17 - 12
takai-system/src/main/java/com/takai/system/service/impl/JkApiServiceImpl.java

@@ -218,12 +218,13 @@ public class JkApiServiceImpl implements IJkApiService {
             // 执行请求并获取响应
             try {
                 Response response = client.newCall(request).execute();
-                logger.info("获取建科"+objectName+"返回:" + response.body().string());
+                String responseBody = response.body().string();
+                logger.info("获取建科"+objectName+"返回:" + responseBody);
 
                 if (!response.isSuccessful()) {
-                    throw new IOException("获取建科"+objectName+"信息失败 " + response.body().string());
+                    throw new IOException("获取建科"+objectName+"信息失败 " + responseBody);
                 }
-                JSONObject jsonObject =JSON.parseObject(response.body().string());
+                JSONObject jsonObject =JSON.parseObject(responseBody);
                 logger.info("获取建科"+objectName+"返回信息:" + jsonObject.toJSONString());
                 //“0”为成功其余均为失败
                 String code = jsonObject.getString("code");
@@ -254,7 +255,7 @@ public class JkApiServiceImpl implements IJkApiService {
             if(!"".equals(ids)) {
                 ids += ",";
             }
-            ids += json.getString("app_account__id");
+            ids += json.getString("request_log__id");
         }
         Request request = buildCallbackRequest(ids);
         int i = 0;
@@ -264,14 +265,15 @@ public class JkApiServiceImpl implements IJkApiService {
                     Thread.sleep(i*1000);
                 }
                 Response response = client.newCall(request).execute();
-                logger.info("回调建科用户接口返回:" + response.body().string());
+                String responseBody = response.body().string();
+                logger.info("回调建科用户接口返回:" + responseBody);
 
                 if (!response.isSuccessful()) {
-                    logger.error("回调建科用户接口失败 " + response.body().string());
+                    logger.error("回调建科用户接口失败 " + responseBody);
                     i++;
                     continue;
                 }
-                JSONObject jsonObject =JSON.parseObject(response.body().string());
+                JSONObject jsonObject =JSON.parseObject(responseBody);
                 //“0”为成功其余均为失败
                 String code = jsonObject.getString("code");
                 if (CODE_SUCCESS.equals(code)) {
@@ -291,20 +293,23 @@ public class JkApiServiceImpl implements IJkApiService {
         try {
             Request request = buildTokenRequest(code);
             Response response = client.newCall(request).execute();
+            String responseBody = response.body().string();
+            logger.info("获取建科token返回信息:" + responseBody);
             if (!response.isSuccessful()) {
-                throw new IOException("获取建科token信息失败 " + response.toString());
+                throw new IOException("获取建科token信息失败 " + responseBody);
             }
-            JSONObject jsonObject =JSON.parseObject(response.body().string());
-            logger.info("获取建科token返回信息:" + jsonObject.toJSONString());
+            JSONObject jsonObject =JSON.parseObject(responseBody);
+
             token = jsonObject.getString("access_token");
             if(!StringUtils.isEmpty(token)) {
                 //token 换取用户信息
                 Request pReq = buildProfileRequest(token);
                 Response pResp = client.newCall(request).execute();
+                String pRespBody = pResp.body().string();
                 if (!pResp.isSuccessful()) {
-                    throw new IOException("token换取建科用户信息失败 " + pResp.toString());
+                    throw new IOException("token换取建科用户信息失败 " + pRespBody);
                 }
-                userJson =JSON.parseObject(pResp.body().string());
+                userJson =JSON.parseObject(pRespBody);
                 logger.info("获取建科用户返回信息:" + userJson.toJSONString());
             }
         } catch (IOException e) {