From 2db47563d765b0833c85f39063822a9c1974cdfb Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Mon, 24 Jun 2024 16:43:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=97=A7=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WeatherForecastController.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java index 516166b0..7b8942b0 100644 --- a/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java +++ b/zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java @@ -96,7 +96,13 @@ public class WeatherForecastController extends BaseController { JSONObject jsonResult = JSONObject.parseObject(response.body().string()); if (jsonResult.getInteger("code") == 200) { - return AjaxResult.success(jsonResult.getJSONArray("data")); + JSONArray data = jsonResult.getJSONArray("data"); + if (data.size() != 0) { + redisCache.setCacheList("currentWeatherAndForecastInformation", data); + return AjaxResult.success(data); + } else { + return AjaxResult.success(redisCache.getCacheList("currentWeatherAndForecastInformation")); + } } else { return AjaxResult.error(jsonResult.getInteger("code"), "请求失败"); } @@ -154,7 +160,13 @@ public class WeatherForecastController extends BaseController { JSONObject jsonResult = JSONObject.parseObject(response.body().string()); if (jsonResult.getInteger("code") == 200) { - return AjaxResult.success(jsonResult.getJSONArray("data")); + JSONArray data = jsonResult.getJSONArray("data"); + if (data.size() != 0) { + redisCache.setCacheList("currentWeatherWarningInformationQuery", data); + return AjaxResult.success(data); + } else { + return AjaxResult.success(redisCache.getCacheList("currentWeatherWarningInformationQuery")); + } } else { return AjaxResult.error(jsonResult.getInteger("code"), "请求失败"); }