|
|
@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.R;
|
|
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
|
|
import com.ruoyi.common.security.annotation.RequiresLogin;
|
|
|
|
import com.ruoyi.common.security.annotation.RequiresLogin;
|
|
|
|
|
|
|
|
import com.xjs.weather.domain.ForecastWeather;
|
|
|
|
import com.xjs.weather.domain.NowWeather;
|
|
|
|
import com.xjs.weather.domain.NowWeather;
|
|
|
|
import com.xjs.weather.service.WeatherService;
|
|
|
|
import com.xjs.weather.service.WeatherService;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
@ -45,11 +46,12 @@ public class WeatherController {
|
|
|
|
@Log(title = "获取预报天气")
|
|
|
|
@Log(title = "获取预报天气")
|
|
|
|
@RequiresLogin
|
|
|
|
@RequiresLogin
|
|
|
|
public AjaxResult getForecastWeatherApiData() {
|
|
|
|
public AjaxResult getForecastWeatherApiData() {
|
|
|
|
return AjaxResult.success(weatherService.cacheForecastWeather());
|
|
|
|
ForecastWeather forecastWeather = weatherService.cacheForecastWeather();
|
|
|
|
|
|
|
|
this.weekConvert(forecastWeather);
|
|
|
|
|
|
|
|
return AjaxResult.success(forecastWeather);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("getWeatherForRPC")
|
|
|
|
@GetMapping("getWeatherForRPC")
|
|
|
|
@ApiOperation("远程调用获取天气信息ForRPC")
|
|
|
|
@ApiOperation("远程调用获取天气信息ForRPC")
|
|
|
|
public R getWeatherForRPC() {
|
|
|
|
public R getWeatherForRPC() {
|
|
|
@ -57,4 +59,40 @@ public class WeatherController {
|
|
|
|
return Objects.nonNull(nowWeather.getCity()) ? R.ok() : R.fail();
|
|
|
|
return Objects.nonNull(nowWeather.getCity()) ? R.ok() : R.fail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* week类型转换
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return ForecastWeather
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void weekConvert(ForecastWeather forecastWeather) {
|
|
|
|
|
|
|
|
forecastWeather.getCasts().forEach(cast -> {
|
|
|
|
|
|
|
|
switch (cast.getWeek()) {
|
|
|
|
|
|
|
|
case "1":
|
|
|
|
|
|
|
|
cast.setWeek("周一");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "2":
|
|
|
|
|
|
|
|
cast.setWeek("周二");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "3":
|
|
|
|
|
|
|
|
cast.setWeek("周三");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "4":
|
|
|
|
|
|
|
|
cast.setWeek("周四");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "5":
|
|
|
|
|
|
|
|
cast.setWeek("周五");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "6":
|
|
|
|
|
|
|
|
cast.setWeek("周六");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "7":
|
|
|
|
|
|
|
|
cast.setWeek("周日");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|