whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/service/WeatherService.java
@@ -49,7 +49,7 @@
        //根据传过来的省市区,定位到区码cityId
        Integer cityId = getId2(city);
        if(cityId==0){
            model.setMsg("暂不支持当前城市天气查询");
            model.setII(0,"暂不支持当前城市天气查询");
        }else {
            //首先从ApplicationContext中获取,如果不存在,则请求第三方接口,同时将值存入
            ServletContext application = ActionUtil.getApplication();
@@ -198,8 +198,10 @@
    public Integer getId2(WeatherCity city){
        WeatherCity weatherCity = weatherCityMapper.getWeatherCity2(city);
        //当前区不存在,则查询上一级市的
        if (weatherCity==null){
            WeatherCity weatherCity1 = weatherCityMapper.getWeatherCity(city);
            city.setDistrict(city.getCity().replace("市",""));
            WeatherCity weatherCity1 = weatherCityMapper.getWeatherCity2(city);
            if (weatherCity1==null){
                return 0;
            }else {