From 4ba348b700fd7f461f754a283eaeeba3fc9ff36c Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期六, 25 二月 2023 16:16:33 +0800 Subject: [PATCH] 新增加司机端接口 --- driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/juhe/WeatherUtil.java | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/juhe/WeatherUtil.java b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/juhe/WeatherUtil.java index 3c19f2e..33c664c 100644 --- a/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/juhe/WeatherUtil.java +++ b/driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/util/juhe/WeatherUtil.java @@ -9,6 +9,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.List; + /** * 天气工具类 @@ -84,4 +86,34 @@ } return false; } + + + /** + * 获取支持城市列表 + * @return + */ + public static List<WeatherCityInfo> queryCityList(){ + String url = "http://apis.juhe.cn/simpleWeather/cityList?key=" + key; + HttpResult httpResult = null; + try { + httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); + } catch (Exception e) { + e.printStackTrace(); + } + if(httpResult.getCode() != 200){ + logger.debug("查询支持城市失败:" + httpResult.getData()); + return null; + } + String data = httpResult.getData(); + JSONObject jsonObject = JSON.parseObject(data); + Integer error_code = jsonObject.getInteger("error_code"); + if(0 != error_code){ + logger.debug("查询支持城失败:" + jsonObject.getString("reason")); + return null; + } + JSONArray result = jsonObject.getJSONArray("result"); + List<WeatherCityInfo> weatherCities = result.toJavaList(WeatherCityInfo.class); + return weatherCities; + } + } -- Gitblit v1.7.1