diff --git a/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java b/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java index c7af2857..720fff87 100644 --- a/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/BaiduUtils.java @@ -22,13 +22,16 @@ public class BaiduUtils { */ public static JSONObject ipLocation(String ip) { System.out.println(ip); - if (ip != null) { - JSONObject response = HttpsUtils.doGet("https://api.map.baidu.com/location/ip?ak=X4sSdXsohVOMb1tNiLZloD9ows5FaNjq&ip=" + ip); - return response; - } else { + try { + if (ip != null) { + JSONObject response = HttpsUtils.doGet("https://api.map.baidu.com/location/ip?ak=X4sSdXsohVOMb1tNiLZloD9ows5FaNjq&ip=" + ip); + return response; + } else { + return null; + } + } catch (Exception e) { return null; } } - }