From b07cf2fcd97f18b39246ff376adf67f1bfbbec0f Mon Sep 17 00:00:00 2001
From: Wang YiHang <3060234389@qq.com>
Date: Thu, 5 Sep 2024 20:02:08 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=88=97=E8=A1=A8=E5=87=BA?=
=?UTF-8?q?=E6=9D=A5=E4=BA=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/workspace.xml | 11 +++++++++--
.../com/muyu/market/config/SimpleWeatherConfig.java | 6 ++----
.../java/com/muyu/market/config/ThirdPartyConfig.java | 7 ++-----
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c3e01ba..0717e5c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -182,7 +182,7 @@
-
+
1724047244829
@@ -415,7 +415,14 @@
1725536412572
-
+
+ 1725537357138
+
+
+
+ 1725537357138
+
+
diff --git a/cloud-market-common/src/main/java/com/muyu/market/config/SimpleWeatherConfig.java b/cloud-market-common/src/main/java/com/muyu/market/config/SimpleWeatherConfig.java
index 3750707..9a67685 100644
--- a/cloud-market-common/src/main/java/com/muyu/market/config/SimpleWeatherConfig.java
+++ b/cloud-market-common/src/main/java/com/muyu/market/config/SimpleWeatherConfig.java
@@ -31,7 +31,7 @@ public class SimpleWeatherConfig {
params.put("city", cityName);
params.put("key", API_KEY);
String queryParams = urlencode(params);
- String msg = null;
+
String response = doGet(API_URL, queryParams);
try {
JSONObject jsonObject = JSONObject.fromObject(response);
@@ -49,15 +49,13 @@ public class SimpleWeatherConfig {
System.out.printf("风向:%s%n", realtime.getString("direct"));
System.out.printf("风力:%s%n", realtime.getString("power"));
System.out.printf("空气质量:%s%n", realtime.getString("aqi"));
-
- msg = String.valueOf(realtime);
} else {
System.out.println("调用接口失败:" + jsonObject.getString("reason"));
}
} catch (Exception e) {
e.printStackTrace();
}
- return msg;
+ return response;
}
/**
diff --git a/cloud-market-common/src/main/java/com/muyu/market/config/ThirdPartyConfig.java b/cloud-market-common/src/main/java/com/muyu/market/config/ThirdPartyConfig.java
index 9ea644b..38f64a8 100644
--- a/cloud-market-common/src/main/java/com/muyu/market/config/ThirdPartyConfig.java
+++ b/cloud-market-common/src/main/java/com/muyu/market/config/ThirdPartyConfig.java
@@ -1,7 +1,5 @@
package com.muyu.market.config;
-import net.sf.json.JSONObject;
-
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
@@ -33,10 +31,9 @@ public class ThirdPartyConfig {
}
in.close();
connection.disconnect();
- JSONObject jsonObject = JSONObject.fromObject(response);
- JSONObject result = jsonObject.getJSONObject("result");
+
// 返回HTTP 200 OK状态码和响应体
- return String.valueOf(result);
+ return response.toString();
}