Browse Source

优化天气预警返回

develop
zhaoxianglong 4 months ago
parent
commit
936b7400e9
  1. 13
      zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

13
zc-business/src/main/java/com/zc/business/controller/WeatherForecastController.java

@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
@ -270,7 +271,8 @@ public class WeatherForecastController extends BaseController {
return AjaxResult.success(cacheObject);
}
} else {
return AjaxResult.error(jsonResult.getInteger("code"), UniversalEnum.REQUEST_FAILED.getValue());
JSONArray cacheObject = redisCache.getCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake);
return AjaxResult.success(cacheObject);
}
}
} catch (Exception ignored) {
@ -278,7 +280,8 @@ public class WeatherForecastController extends BaseController {
logger.error(String.valueOf(ignored));
}
return AjaxResult.error(UniversalEnum.REQUEST_FAILED.getValue());
JSONArray cacheObject = redisCache.getCacheObject(UniversalEnum.CURRENT_WEATHER_AND_FORECAST_INFORMATION_SINGLE_WORD.getValue() + numStake);
return AjaxResult.success(cacheObject);
}
public JSONArray processingWeatherData(JSONArray data) {
@ -433,7 +436,7 @@ public class WeatherForecastController extends BaseController {
JSONArray forecastList = jsonObject.getJSONArray("forecastList");
if (forecastList != null && forecastList.size() != UniversalEnum.ZERO.getNumber()) {
jsonObject.put("forecastList",processingWeatherData(forecastList));
jsonObject.put("forecastList", processingWeatherData(forecastList));
}
jsonArray.add(i, jsonObject);
@ -539,14 +542,14 @@ public class WeatherForecastController extends BaseController {
// return AjaxResult.success(redisCache.getCacheList("currentWeatherWarningInformationQuery"));
//}
} else {
return AjaxResult.error(jsonResult.getInteger("code"), UniversalEnum.REQUEST_FAILED.getValue());
return AjaxResult.success(new ArrayList<>());
}
}
} catch (Exception ignored) {
}
return AjaxResult.error(UniversalEnum.REQUEST_FAILED.getValue());
return AjaxResult.success(new ArrayList<>());
}

Loading…
Cancel
Save