From 71664eb43475dea77412ba903ad0fbca5d4fcfe5 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 7 Jan 2025 17:07:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E6=A1=8C=E9=9D=A2=E7=89=88?= =?UTF-8?q?=E3=80=91=E6=96=B0=E5=BB=BAapi=E6=95=B0=E6=8D=AE=E6=BA=90-?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E4=BD=93=E8=87=AA=E5=AE=9A=E4=B9=89=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/datasource/provider/ApiUtils.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java index a4451abf20..91bf84d8d8 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/ApiUtils.java @@ -375,8 +375,8 @@ public class ApiUtils { for (JsonNode jsonNode : rootNode) { if (jsonNode.has("name") && jsonNode.has("value")) { if (jsonNode.get("value") != null && StringUtils.isNotEmpty(jsonNode.get("value").asText())) { - if (jsonNode.get("nameType") != null && jsonNode.get("nameType").toString().equalsIgnoreCase("params")) { - String param = jsonNode.get("value").toString(); + if (jsonNode.get("nameType") != null && jsonNode.get("nameType").asText().equalsIgnoreCase("params")) { + String param = jsonNode.get("value").asText(); for (ApiDefinition definition : paramsList) { for (int i = 0; i < definition.getFields().size(); i++) { TableField field = definition.getFields().get(i); @@ -384,20 +384,20 @@ public class ApiUtils { String resultStr = execHttpRequest(false, definition, definition.getApiQueryTimeout() == null || apiDefinition.getApiQueryTimeout() <= 0 ? 10 : apiDefinition.getApiQueryTimeout(), null); List dataList = fetchResult(resultStr, definition); if (dataList.size() > 0) { - body.put(jsonNode.get("name").toString(), dataList.get(0)[i]); + body.put(jsonNode.get("name").asText(), dataList.get(0)[i]); } } } } - } else if (jsonNode.get("nameType") != null && jsonNode.get("nameType").toString().equalsIgnoreCase("custom")) { + } else if (jsonNode.get("nameType") != null && jsonNode.get("nameType").asText().equalsIgnoreCase("custom")) { List bodYparams = new ArrayList<>(); String regex = "\\$\\{(.*?)\\}"; Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(jsonNode.get("value").toString()); + Matcher matcher = pattern.matcher(jsonNode.get("value").asText()); while (matcher.find()) { bodYparams.add(matcher.group(1)); } - String result = jsonNode.get("value").toString(); + String result = jsonNode.get("value").asText(); for (String param : bodYparams) { for (ApiDefinition definition : paramsList) { for (int i = 0; i < definition.getFields().size(); i++) { @@ -412,9 +412,9 @@ public class ApiUtils { } } } - body.put(jsonNode.get("name").toString(), result); - } else if (jsonNode.get("nameType") != null && jsonNode.get("nameType").toString().equalsIgnoreCase("timeFun")) { - String timeFormat = jsonNode.get("value").toString(); + body.put(jsonNode.get("name").asText(), result); + } else if (jsonNode.get("nameType") != null && jsonNode.get("nameType").asText().equalsIgnoreCase("timeFun")) { + String timeFormat = jsonNode.get("value").asText(); Calendar calendar = Calendar.getInstance(); Date date = calendar.getTime(); if (StringUtils.isNotEmpty(timeFormat) && timeFormat.split(" ")[0].equalsIgnoreCase("currentDay")) {