feat(X-Pack): DE启动时自动检测apisix配置并初始化

This commit is contained in:
fit2cloud-chenyw 2024-06-25 15:34:41 +08:00
parent 3810f30b79
commit 465607c641
3 changed files with 37 additions and 22 deletions

View File

@ -148,23 +148,6 @@
<artifactId>flexmark-all</artifactId>
<version>${flexmark.version}</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-permissions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-sync</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.dataease</groupId>
<artifactId>xpack-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>

@ -1 +1 @@
Subproject commit 05e2378fc74d5029527436d5965cf1d706223cd7
Subproject commit 68a35e78970ba610a3d596695b7e8017b6e31721

View File

@ -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<String, String> 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格式的字符串
*