From 465607c641fffef6c95319f13c559453ccf83297 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 25 Jun 2024 15:34:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(X-Pack):=20DE=E5=90=AF=E5=8A=A8=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A3=80=E6=B5=8Bapisix=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=B9=B6=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-backend/pom.xml | 17 -------- de-xpack | 2 +- .../io/dataease/utils/HttpClientUtil.java | 40 +++++++++++++++++-- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/core/core-backend/pom.xml b/core/core-backend/pom.xml index 1b5596c1d3..f648cd5038 100644 --- a/core/core-backend/pom.xml +++ b/core/core-backend/pom.xml @@ -148,23 +148,6 @@ flexmark-all ${flexmark.version} - - - io.dataease - xpack-permissions - ${project.version} - - - io.dataease - xpack-sync - ${project.version} - - - io.dataease - xpack-base - ${project.version} - - diff --git a/de-xpack b/de-xpack index 05e2378fc7..68a35e7897 160000 --- a/de-xpack +++ b/de-xpack @@ -1 +1 @@ -Subproject commit 05e2378fc74d5029527436d5965cf1d706223cd7 +Subproject commit 68a35e78970ba610a3d596695b7e8017b6e31721 diff --git a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java index 00814e3e86..cdc2abc6c4 100755 --- a/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java +++ b/sdk/common/src/main/java/io/dataease/utils/HttpClientUtil.java @@ -8,10 +8,7 @@ import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.entity.EntityBuilder; import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.*; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.HttpClientConnectionManager; @@ -225,6 +222,41 @@ public class HttpClientUtil { } } + public static String put(String url, String json, HttpClientConfig config) { + CloseableHttpClient httpClient = null; + try { + httpClient = buildHttpClient(url); + HttpPut httpPut = new HttpPut(url); + if (config == null) { + config = new HttpClientConfig(); + } + httpPut.setConfig(config.buildRequestConfig()); + Map header = config.getHeader(); + for (String key : header.keySet()) { + httpPut.addHeader(key, header.get(key)); + } + EntityBuilder entityBuilder = EntityBuilder.create(); + entityBuilder.setText(json); + entityBuilder.setContentType(ContentType.APPLICATION_JSON); + HttpEntity requestEntity = entityBuilder.build(); + httpPut.setEntity(requestEntity); + + HttpResponse response = httpClient.execute(httpPut); + return getResponseStr(response, config); + } catch (Exception e) { + logger.error("HttpClient查询失败", e); + throw new DEException(SYSTEM_INNER_ERROR.code(), "HttpClient查询失败: " + e.getMessage()); + } finally { + try { + if (httpClient != null) { + httpClient.close(); + } + } catch (Exception e) { + logger.error("HttpClient关闭连接失败", e); + } + } + } + /** * Post请求,请求内容必须为JSON格式的字符串 *