sjy #24

Merged
root merged 2 commits from sjy into master 2024-08-22 10:09:19 +08:00
2 changed files with 3 additions and 2 deletions
Showing only changes of commit 7da4af075c - Show all commits

View File

@ -36,7 +36,7 @@ public class WeatherApi {
*/ */
@GetMapping(value = "/getFutureWeather") @GetMapping(value = "/getFutureWeather")
public ResponseVO getFutureWeather(String cityCode) { public ResponseVO getFutureWeather(String cityCode) {
String weatherData = GoodWeatherUtil.getWeatherData(cityCode); String weatherData = GoodWeatherUtil.getFutureWeather(cityCode);
JSONObject dataOfJson = JSONObject.parseObject(weatherData); JSONObject dataOfJson = JSONObject.parseObject(weatherData);
JSONArray forecasts = dataOfJson.getJSONArray("forecasts"); JSONArray forecasts = dataOfJson.getJSONArray("forecasts");
return new ResponseVO(200,"",forecasts,0); return new ResponseVO(200,"",forecasts,0);

View File

@ -52,6 +52,7 @@ public class GoodWeatherUtil {
} }
/** /**
* 获取未来三天天气预报 * 获取未来三天天气预报
* @param cityCode * @param cityCode
@ -83,6 +84,7 @@ public class GoodWeatherUtil {
} }
/* /*
* 将JSON格式数据进行解析 返回一个weather对象 * 将JSON格式数据进行解析 返回一个weather对象
*/ */
@ -90,7 +92,6 @@ public class GoodWeatherUtil {
if ("500".equals(weatherInfobyJson)){ if ("500".equals(weatherInfobyJson)){
return null; return null;
} }
JSONObject dataOfJson = JSONObject.parseObject(weatherInfobyJson); JSONObject dataOfJson = JSONObject.parseObject(weatherInfobyJson);
System.out.println(dataOfJson); System.out.println(dataOfJson);
//创建WeatherInfo对象提取所需的天气信息 //创建WeatherInfo对象提取所需的天气信息