1、预报天气星期类型转换
This commit is contained in:
parent
41566f33bf
commit
2789140740
|
|
@ -18,42 +18,22 @@
|
|||
<table style="text-align: center" v-loading="loading">
|
||||
<td v-for="(cast,index) in forecastWeatherData.casts" width="100px">
|
||||
<tr v-if="index===0">
|
||||
今天
|
||||
今天({{cast.week}})
|
||||
</tr>
|
||||
<tr v-if="index===1">
|
||||
明天
|
||||
明天({{cast.week}})
|
||||
</tr>
|
||||
<tr v-if="index===2">
|
||||
后天
|
||||
后天({{cast.week}})
|
||||
</tr>
|
||||
<tr v-if="index===3">
|
||||
大后天
|
||||
大后天({{cast.week}})
|
||||
</tr>
|
||||
<tr>{{cast.dayweather}}</tr>
|
||||
<tr>
|
||||
{{cast.nighttemp+"℃~"+cast.daytemp+"℃"}}
|
||||
</tr>
|
||||
<tr v-if="cast.week==='1'">
|
||||
星期一
|
||||
</tr>
|
||||
<tr v-if="cast.week==='2'">
|
||||
星期二
|
||||
</tr>
|
||||
<tr v-if="cast.week==='3'">
|
||||
星期三
|
||||
</tr>
|
||||
<tr v-if="cast.week==='4'">
|
||||
星期四
|
||||
</tr>
|
||||
<tr v-if="cast.week==='5'">
|
||||
星期五
|
||||
</tr>
|
||||
<tr v-if="cast.week==='6'">
|
||||
星期六
|
||||
</tr>
|
||||
<tr v-if="cast.week==='7'">
|
||||
星期日
|
||||
</tr>
|
||||
|
||||
</td>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.R;
|
|||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.security.annotation.RequiresLogin;
|
||||
import com.xjs.weather.domain.ForecastWeather;
|
||||
import com.xjs.weather.domain.NowWeather;
|
||||
import com.xjs.weather.service.WeatherService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -45,11 +46,12 @@ public class WeatherController {
|
|||
@Log(title = "获取预报天气")
|
||||
@RequiresLogin
|
||||
public AjaxResult getForecastWeatherApiData() {
|
||||
return AjaxResult.success(weatherService.cacheForecastWeather());
|
||||
ForecastWeather forecastWeather = weatherService.cacheForecastWeather();
|
||||
this.weekConvert(forecastWeather);
|
||||
return AjaxResult.success(forecastWeather);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("getWeatherForRPC")
|
||||
@ApiOperation("远程调用获取天气信息ForRPC")
|
||||
public R getWeatherForRPC() {
|
||||
|
|
@ -57,4 +59,40 @@ public class WeatherController {
|
|||
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;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue