|
@@ -104,15 +104,16 @@ type AirInfo struct {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
type WeatherInfoResp struct {
|
|
type WeatherInfoResp struct {
|
|
|
- Location string `json:"location"`
|
|
|
|
|
- Text string `json:"text"`
|
|
|
|
|
- Code string `json:"code"`
|
|
|
|
|
- Temperature int `json:"temperature"`
|
|
|
|
|
- Humidity int `json:"humidity"`
|
|
|
|
|
- AQI int `json:"aqi"`
|
|
|
|
|
- PM25 int `json:"pm25"`
|
|
|
|
|
- PM10 int `json:"pm10"`
|
|
|
|
|
- Quality string `json:"quality"`
|
|
|
|
|
|
|
+ Location string `json:"location"`
|
|
|
|
|
+ Text string `json:"text"`
|
|
|
|
|
+ Code string `json:"code"`
|
|
|
|
|
+ Temperature int `json:"temperature"`
|
|
|
|
|
+ Humidity int `json:"humidity"`
|
|
|
|
|
+ AQI int `json:"aqi"`
|
|
|
|
|
+ PM25 int `json:"pm25"`
|
|
|
|
|
+ PM10 int `json:"pm10"`
|
|
|
|
|
+ Quality string `json:"quality"`
|
|
|
|
|
+ LastUpdate time.Time `json:"last_update"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func GetWeatherInfo(location, key string) (*WeatherInfoResp, error) {
|
|
func GetWeatherInfo(location, key string) (*WeatherInfoResp, error) {
|
|
@@ -126,6 +127,7 @@ func GetWeatherInfo(location, key string) (*WeatherInfoResp, error) {
|
|
|
result.Code = info.Results[0].Now.Code
|
|
result.Code = info.Results[0].Now.Code
|
|
|
result.Temperature, _ = strconv.Atoi(info.Results[0].Now.Temperature)
|
|
result.Temperature, _ = strconv.Atoi(info.Results[0].Now.Temperature)
|
|
|
result.Humidity, _ = strconv.Atoi(info.Results[0].Now.Humidity)
|
|
result.Humidity, _ = strconv.Atoi(info.Results[0].Now.Humidity)
|
|
|
|
|
+ result.LastUpdate = info.Results[0].LastUpdate
|
|
|
airInfo, err := GetAirInfoByLocation(location, key)
|
|
airInfo, err := GetAirInfoByLocation(location, key)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|