From de2d3696f975cf6e6df2e580bab305fa9859feea Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 26 十月 2023 17:55:36 +0800
Subject: [PATCH] 2023年10月26日17:55:33
---
app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java | 63 +++++++++++++++++++++++++++++--
1 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java b/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java
index fe8fa9b..a835302 100644
--- a/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java
+++ b/app/src/main/java/com/hdl/photovoltaic/internet/HttpClient.java
@@ -25,6 +25,7 @@
import com.hdl.photovoltaic.other.HdlLogLogic;
import com.hdl.photovoltaic.utils.HDLMD5Utils;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@@ -73,7 +74,7 @@
String requestUrl = HDLCloudUserApi.getRequestUrl(api);
Gson gson = new Gson();
- System.out.println("鍙戦��->" + requestUrl + "\r\n" + body);
+ System.out.println("http->鍙戦��->" + requestUrl + "\r\n" + body);
return HxHttp.builder()
.url(requestUrl)
.raw(body)
@@ -84,8 +85,8 @@
public void onResponse(String str) {
if (callBack != null) {
callBack.onSuccess(str);
-// System.out.println("鍥炲->" + requestUrl + "\r\n" + gson.fromJson(str, JsonObject.class).toString());
- System.out.println("鍥炲->" + requestUrl + "\r\n" + str);
+// System.out.println("http->鍥炲->" + requestUrl + "\r\n" + gson.fromJson(str, JsonObject.class).toString());
+ System.out.println("http->鍥炲->" + requestUrl + "\r\n" + str);
}
}
@@ -94,7 +95,49 @@
HDLExceptionSubmitUtils.submit(requestUrl, body, e);
if (callBack != null) {
callBack.onFailure(e);
- System.out.println("鍥炲->" + requestUrl + "\r\n" + "{code=" + e.getCode() + ",message=" + e.getMessage() + "}");
+ System.out.println("http->鍥炲->" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}");
+ }
+ }
+ });
+
+ }
+
+ /**
+ * 璇锋眰鏈嶅姟鍣�
+ * 搴曞眰鏂规硶,寮曠敤搴撶殑鏂规硶
+ *
+ * @param api 璇锋眰鎺ュ彛
+ * @param body 璇锋眰鍙傛暟(appKey,timestamp,sign杩欎笁涓弬鏁板唴閮ㄤ細鑷姩娣诲姞))
+ * @param callBack 鍥炶皟
+ * @return -
+ */
+ private Disposable requestFile(String api, File body, CloudCallBeak<String> callBack) {
+
+
+ String requestUrl = HDLCloudUserApi.getRequestUrl(api);
+ Gson gson = new Gson();
+ System.out.println("http->鍙戦��->" + requestUrl + "\r\n" + body);
+ return HxHttp.builder()
+ .url(requestUrl)
+ .file(body)
+ .build()
+ .post()
+ .subscribeWith(new HDLResponse<String>() {
+ @Override
+ public void onResponse(String str) {
+ if (callBack != null) {
+ callBack.onSuccess(str);
+// System.out.println("http->鍥炲->" + requestUrl + "\r\n" + gson.fromJson(str, JsonObject.class).toString());
+ System.out.println("http->鍥炲->" + requestUrl + "\r\n" + str);
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ HDLExceptionSubmitUtils.submit(requestUrl, body, e);
+ if (callBack != null) {
+ callBack.onFailure(e);
+ System.out.println("http->鍥炲->" + requestUrl + "\r\n" + "\"{code=\"" + e.getCode() + "," + "\"message=\"" + e.getMsg() + "}");
}
}
});
@@ -114,6 +157,18 @@
}
/**
+ * 璇锋眰鏈嶅姟鍣紙涓婁紶鏂囦欢锛�
+ *
+ * @param api 璇锋眰鎺ュ彛
+ * @param body 璇锋眰鍙傛暟(json)
+ * @param callBack 鍥炶皟
+ */
+ public Disposable requestHttpFile(String api, File body, CloudCallBeak<String> callBack) {
+ return requestFile(api, body, callBack);
+ }
+
+
+ /**
* 璇锋眰鏈嶅姟鍣ㄧ殑鏂规硶(宸插純鐢�)
*
* @param requestUrl 璇锋眰鎺ュ彛
--
Gitblit v1.8.0