为了账号安全,请及时绑定邮箱和手机立即绑定

接口变了,复制我的这两个方法加进去就行了

WeatherUtilsImpl WeatherUtils {
    <> getValue(Object map, String path, Class<> clazz) {
        {
            OgnlContext context = OgnlContext();
            context.setRoot(map);
            value = () Ognl.(path, context, context.getRoot());
            value;
        } (Exception e) {
            RuntimeException(e);
        }
    }

    List<HourWeather> w24h(String appCode, String area) {
        List<HourWeather> resultList = ArrayList<HourWeather>();
        {
            OkHttpClient client = OkHttpClient();
            Request request = Request.Builder()
                    .get()
                    .url(+ area)
                    .header(, + appCode)
                    .build();
            Call call = client.newCall(request);
            Response response = call.execute();
            Gson gson = GsonBuilder()
                    .setFieldNamingPolicy(FieldNamingPolicy.)
                    .create();
            String resBody = response.body().string();
            Map result = gson.fromJson(resBody, TypeToken<Map>() {
            }.getType());
            List<Map<String, String>> hourList = .getValue(result, , ArrayList.);
            (hourList == || hourList.size() == ) {
                ArrayList<HourWeather>();
            }
            (Map<String, String> hour : hourList) {
                HourWeather hourWeather = HourWeather();
                hourWeather.setYear(hour.get().substring(, ));
                hourWeather.setMonth(hour.get().substring(, ));
                hourWeather.setDay(hour.get().substring(, ));
                hourWeather.setHour(hour.get().substring(, ));
                hourWeather.setWindDirection(hour.get());
                hourWeather.setWindPower(hour.get());
                hourWeather.setWeather(hour.get());
                hourWeather.setTemperature(hour.get());
                resultList.add(hourWeather);
            }

        } (Exception e) {
            RuntimeException(e);
        }
        resultList;

    }

    List<DayWeather> w3d(String appCode, String area) {
        ;
    }

    List<DayWeather> w7d(String appCode, String area) {
        ;
    }


正在回答

举报

0/150
提交
取消

接口变了,复制我的这两个方法加进去就行了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信