优化默认返回

master
RuoYi 7 years ago committed by Limy
parent 6207d21af7
commit 2248b0b9b6

@ -86,12 +86,6 @@
<optional>true</optional> <!-- 表示依赖不会传递 --> <optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency> </dependency>
<!-- thymeleaf网页解析 -->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
<!-- Mysql驱动包 --> <!-- Mysql驱动包 -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>

@ -19,22 +19,20 @@ public class AddressUtils
public static String getRealAddressByIP(String ip) public static String getRealAddressByIP(String ip)
{ {
String address = ""; String address = "XX XX";
try if (RuoYiConfig.isAddressEnabled())
{ {
if (RuoYiConfig.isAddressEnabled()) String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip);
if (StringUtils.isEmpty(rspStr))
{ {
address = HttpUtils.sendPost(IP_URL, "ip=" + ip); log.error("获取地理位置异常 {}", ip);
JSONObject json = JSONObject.parseObject(address); return address;
JSONObject object = json.getObject("data", JSONObject.class);
String region = object.getString("region");
String city = object.getString("city");
address = region + " " + city;
} }
} JSONObject obj = JSONObject.parseObject(rspStr);
catch (Exception e) JSONObject data = obj.getObject("data", JSONObject.class);
{ String region = data.getString("region");
log.error("获取地理位置异常:", e); String city = data.getString("city");
address = region + " " + city;
} }
return address; return address;
} }

Loading…
Cancel
Save