修改人:邹江涛

修改内容:API映射公共单据
修改时间:2024/12/03
This commit is contained in:
zoujiangtao 2024-12-03 16:27:28 +08:00
parent a527230820
commit 8c7c439c4e
3 changed files with 20 additions and 17 deletions

View File

@ -39,29 +39,32 @@ public class ApiService {
Map<String, Object> 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 +
"&timestamp=" + currentTimeMillis +
"&signature=" + signature;
map.put("url", urlString);
// 禁用 SSL 证书验证
disableSSLCertificateChecking();
// 构建URL
String urlString = domainName + API_ENDPOINT +
"?appKey=" + APP_KEY +
"&timestamp=" + 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) {

View File

@ -173,7 +173,7 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
apiEntity.setHeaders(headMap);
Map<String, Object> paramsMap = new HashMap<>();
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.setRequestBody(codeEdit.getText());
JSONObject responseBody = ApiEntity.getResponseBody(apiEntity);

View File

@ -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<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)) {
String url = this.getModel().getValue("shkd_url").toString();
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)) {