parent
a527230820
commit
8c7c439c4e
|
@ -39,29 +39,32 @@ public class ApiService {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
String signature = generateSignature("appKey" + APP_KEY + "timestamp" + currentTimeMillis);
|
String signature = generateSignature("appKey" + APP_KEY + "timestamp" + currentTimeMillis);
|
||||||
logger.info("getBIPToken → 签名: {}", signature);
|
logger.info("getBIPToken → 签名: {}", signature);
|
||||||
try {
|
|
||||||
// 禁用 SSL 证书验证
|
// 禁用 SSL 证书验证
|
||||||
disableSSLCertificateChecking();
|
disableSSLCertificateChecking();
|
||||||
// 构建URL
|
// 构建URL
|
||||||
String urlString = domainName + API_ENDPOINT +
|
String urlString = domainName + API_ENDPOINT +
|
||||||
"?appKey=" + APP_KEY +
|
"?appKey=" + APP_KEY +
|
||||||
"×tamp=" + currentTimeMillis +
|
"×tamp=" + currentTimeMillis +
|
||||||
"&signature=" + signature;
|
"&signature=" + signature;
|
||||||
map.put("url", urlString);
|
map.put("url", urlString);
|
||||||
// return urlString;
|
// return urlString;
|
||||||
|
|
||||||
|
String token;
|
||||||
|
try {
|
||||||
// 发送请求
|
// 发送请求
|
||||||
Request request = buildRequest(urlString);
|
Request request = buildRequest(urlString);
|
||||||
logger.info("getBIPToken → 获取返回数据:{}", request);
|
logger.info("getBIPToken → 获取返回数据:{}", request);
|
||||||
Response response = client.newCall(request).execute();
|
Response response = client.newCall(request).execute();
|
||||||
String token = handleResponse(response);
|
token = handleResponse(response);
|
||||||
map.put("token", token);
|
|
||||||
// 处理响应
|
|
||||||
return map;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("getBIPToken → 请求失败: ", e);
|
logger.error("getBIPToken → 请求失败: ", e);
|
||||||
return null;
|
token = null;
|
||||||
}
|
}
|
||||||
|
map.put("token", token);
|
||||||
|
// 处理响应
|
||||||
|
return map;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Request buildRequest(String urlString) {
|
private static Request buildRequest(String urlString) {
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
|
||||||
apiEntity.setHeaders(headMap);
|
apiEntity.setHeaders(headMap);
|
||||||
Map<String, Object> paramsMap = new HashMap<>();
|
Map<String, Object> paramsMap = new HashMap<>();
|
||||||
Map<String, Object> resultMap = ApiService.getBIPToken(domainName);
|
Map<String, Object> resultMap = ApiService.getBIPToken(domainName);
|
||||||
paramsMap.put("access_token", resultMap != null ? resultMap.get("token") : "");
|
paramsMap.put("access_token", resultMap.get("token"));
|
||||||
apiEntity.setQueryParams(paramsMap);
|
apiEntity.setQueryParams(paramsMap);
|
||||||
apiEntity.setRequestBody(codeEdit.getText());
|
apiEntity.setRequestBody(codeEdit.getText());
|
||||||
JSONObject responseBody = ApiEntity.getResponseBody(apiEntity);
|
JSONObject responseBody = ApiEntity.getResponseBody(apiEntity);
|
||||||
|
|
|
@ -36,13 +36,13 @@ public class ApiTestBillPlugin extends AbstractBillPlugIn implements Plugin {
|
||||||
if ("shkd_token".equals(key)) {
|
if ("shkd_token".equals(key)) {
|
||||||
String url = this.getModel().getValue("shkd_url").toString();
|
String url = this.getModel().getValue("shkd_url").toString();
|
||||||
Map<String, Object> resultMap = ApiService.getBIPToken(url);
|
Map<String, Object> 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)) {
|
if ("shkd_geturl".equals(key)) {
|
||||||
String url = this.getModel().getValue("shkd_url").toString();
|
String url = this.getModel().getValue("shkd_url").toString();
|
||||||
Map<String, Object> resultMap = ApiService.getBIPToken(url);
|
Map<String, Object> 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)) {
|
if ("shkd_api".equals(key)) {
|
||||||
|
|
Loading…
Reference in New Issue