houzhongjian
2025-03-12 02340c7c45561d31119eb0de659bd1648667c235
iailab-plat-sdk/src/main/java/com/iailab/sdk/util/http/IailabHttpUtils.java
@@ -1,7 +1,7 @@
package com.iailab.sdk.util.http;
import com.iailab.sdk.auth.client.IailabAuthClient;
import com.iailab.sdk.auth.config.AuthProperties;
import com.iailab.sdk.auth.config.SdkAutoConfiguration;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -18,12 +18,6 @@
public class IailabHttpUtils {
    private static AuthProperties authProperties;
    public static void setAuthProperties(AuthProperties properties) {
        authProperties = properties;
    }
    /**
     *
     * @param url
@@ -31,7 +25,7 @@
     * @param charset
     * @return
     */
    public static String doGet(String url, Map<String, String> map, String charset) throws Exception {
    public static String doGet(String url, Map<String, Object> map, String charset) throws Exception {
        System.out.println("start doGet url: " + url);
        checkToken();
        org.apache.http.client.HttpClient httpClient = null;
@@ -48,7 +42,7 @@
                }
                map.forEach((k, v) -> {
                    try {
                        sb.append(k + "=" + URLEncoder.encode(v, charset) + "&");
                        sb.append(k + "=" + URLEncoder.encode(v.toString(), charset) + "&");
                    } catch (UnsupportedEncodingException e) {
                        e.printStackTrace();
                    }
@@ -61,8 +55,7 @@
            httpGet.addHeader("Accept", "application/json");
            httpGet.addHeader("Content-Type", "application/json;charset=UTF-8");
            httpGet.addHeader("Authorization", "Bearer " + IailabAuthClient.accessToken);
            httpGet.addHeader("Tenant-Id", String.valueOf(authProperties.getTenantId()));
            httpGet.addHeader("Tenant-Id", SdkAutoConfiguration.TENANT_ID.toString());
            HttpResponse response = httpClient.execute(httpGet);
            if (response != null) {
                HttpEntity resEntity = response.getEntity();
@@ -96,7 +89,7 @@
            httpPost.addHeader("Accept", "application/json");
            httpPost.addHeader("Content-Type", "application/json;charset=UTF-8");
            httpPost.addHeader("Authorization", "Bearer " + IailabAuthClient.accessToken);
            httpPost.addHeader("Tenant-Id", String.valueOf(authProperties.getTenantId()));
            httpPost.addHeader("Tenant-Id", SdkAutoConfiguration.TENANT_ID.toString());
            StringEntity stringEntity = new StringEntity(json);
            stringEntity.setContentEncoding("UTF-8");
            stringEntity.setContentType("application/json");