diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java index e5ed3eb..49d8394 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java @@ -39,29 +39,32 @@ public class ApiService { Map map = new HashMap<>(); String signature = generateSignature("appKey" + APP_KEY + "timestamp" + currentTimeMillis); logger.info("getBIPToken → 签名: {}", signature); - try { - // 禁用 SSL 证书验证 - disableSSLCertificateChecking(); - // 构建URL - String urlString = domainName + API_ENDPOINT + - "?appKey=" + APP_KEY + - "×tamp=" + currentTimeMillis + - "&signature=" + signature; - map.put("url", urlString); + + // 禁用 SSL 证书验证 + disableSSLCertificateChecking(); + // 构建URL + String urlString = domainName + API_ENDPOINT + + "?appKey=" + APP_KEY + + "×tamp=" + currentTimeMillis + + "&signature=" + signature; + map.put("url", urlString); // return urlString; + String token; + try { // 发送请求 Request request = buildRequest(urlString); logger.info("getBIPToken → 获取返回数据:{}", request); Response response = client.newCall(request).execute(); - String token = handleResponse(response); - map.put("token", token); - // 处理响应 - return map; + token = handleResponse(response); } catch (Exception e) { logger.error("getBIPToken → 请求失败: ", e); - return null; + token = null; } + map.put("token", token); + // 处理响应 + return map; + } private static Request buildRequest(String urlString) { diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java index 2bbf83b..8056840 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java @@ -173,7 +173,7 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { apiEntity.setHeaders(headMap); Map paramsMap = new HashMap<>(); Map resultMap = ApiService.getBIPToken(domainName); - paramsMap.put("access_token", resultMap != null ? resultMap.get("token") : ""); + paramsMap.put("access_token", resultMap.get("token")); apiEntity.setQueryParams(paramsMap); apiEntity.setRequestBody(codeEdit.getText()); JSONObject responseBody = ApiEntity.getResponseBody(apiEntity); diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiTestBillPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiTestBillPlugin.java index 6eeb973..decec33 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiTestBillPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiTestBillPlugin.java @@ -36,13 +36,13 @@ public class ApiTestBillPlugin extends AbstractBillPlugIn implements Plugin { if ("shkd_token".equals(key)) { String url = this.getModel().getValue("shkd_url").toString(); Map resultMap = ApiService.getBIPToken(url); - this.getView().showTipNotification(resultMap != null ? resultMap.get("token").toString() : "数据为空"); + this.getView().showTipNotification(resultMap.get("token") == null ? "获取token为空" :resultMap.get("token").toString()); } if ("shkd_geturl".equals(key)) { String url = this.getModel().getValue("shkd_url").toString(); Map resultMap = ApiService.getBIPToken(url); - this.getView().showTipNotification(resultMap != null ? resultMap.get("url").toString() : "数据为空"); + this.getView().showTipNotification(resultMap.get("url").toString()); } if ("shkd_api".equals(key)) {