From 7d9c6787a4bfe2cd50d3250e08a5d337f8fe933d Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期二, 18 三月 2025 18:49:17 +0800
Subject: [PATCH] handleHttp

---
 iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java b/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java
index 2c06c3c..b97e900 100644
--- a/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java
+++ b/iailab-plat-sdk/src/main/java/com/iailab/sdk/auth/client/IailabClient.java
@@ -198,6 +198,33 @@
         return authTokenDTO;
     }
 
+    public CommonResult<JSONObject> handleHttp(String method, String url, Map<String, Object> params) {
+        JSONObject data = new JSONObject();
+        String resp = null;
+        try {
+            String upperMethod = method.toUpperCase();
+            if ("GET".equals(upperMethod)) {
+                resp = IailabHttpUtils.doGet(url, params, CHARSET);
+            } else if ("POST".equals(upperMethod)) {
+                ObjectMapper objectMapper = new ObjectMapper();
+                resp = IailabHttpUtils.doPost(url, objectMapper.writeValueAsString(params), CHARSET);
+            }
+            if (StringUtils.isEmpty(resp)) {
+                return CommonResult.error(GlobalErrorCodeConstants.EMPTY_RESP);
+            }
+            JSONObject jsonObject = JSON.parseObject(resp);
+            Integer respCode = jsonObject.getInteger(RESP_CODE);
+            if (!GlobalErrorCodeConstants.SUCCESS.getCode().equals(respCode)) {
+                CommonResult.error(respCode, jsonObject.getString(RESP_MSG));
+            }
+            data = jsonObject.getJSONObject(RESP_DATA);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            return CommonResult.error(GlobalErrorCodeConstants.UNKNOWN.getCode(), ex.getMessage());
+        }
+        return CommonResult.success(data);
+    }
+
     /**
      * 查询多个测点当前值
      *

--
Gitblit v1.9.3