From a2c34b5ee4148d8bf03580b1a83d4f2c1b3a7d78 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Mon, 13 Feb 2023 13:52:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hai/common/utils/BaiduUtils.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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; } } - }