sjy #24
@ -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);
|
||||||
|
@ -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对象,提取所需的天气信息
|
||||||
|
Loading…
Reference in New Issue
Block a user