正在显示
1 个修改的文件
包含
13 行增加
和
9 行删除
| @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; | @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; | ||
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | import com.ruoyi.common.utils.StringUtils; | 6 | import com.ruoyi.common.utils.StringUtils; |
| 7 | import com.ruoyi.common.utils.http.HttpUtils; | 7 | import com.ruoyi.common.utils.http.HttpUtils; |
| 8 | +import com.ruoyi.framework.config.RuoYiConfig; | ||
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| 10 | * 获取地址类 | 11 | * 获取地址类 |
| @@ -25,17 +26,20 @@ public class AddressUtils | @@ -25,17 +26,20 @@ public class AddressUtils | ||
| 25 | { | 26 | { |
| 26 | return "内网IP"; | 27 | return "内网IP"; |
| 27 | } | 28 | } |
| 28 | - String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip); | ||
| 29 | - if (StringUtils.isEmpty(rspStr)) | 29 | + if (RuoYiConfig.isAddressEnabled()) |
| 30 | { | 30 | { |
| 31 | - log.error("获取地理位置异常 {}", ip); | ||
| 32 | - return address; | 31 | + String rspStr = HttpUtils.sendPost(IP_URL, "ip=" + ip); |
| 32 | + if (StringUtils.isEmpty(rspStr)) | ||
| 33 | + { | ||
| 34 | + log.error("获取地理位置异常 {}", ip); | ||
| 35 | + return address; | ||
| 36 | + } | ||
| 37 | + JSONObject obj = JSONObject.parseObject(rspStr); | ||
| 38 | + JSONObject data = obj.getObject("data", JSONObject.class); | ||
| 39 | + String region = data.getString("region"); | ||
| 40 | + String city = data.getString("city"); | ||
| 41 | + address = region + " " + city; | ||
| 33 | } | 42 | } |
| 34 | - JSONObject obj = JSONObject.parseObject(rspStr); | ||
| 35 | - JSONObject data = obj.getObject("data", JSONObject.class); | ||
| 36 | - String region = data.getString("region"); | ||
| 37 | - String city = data.getString("city"); | ||
| 38 | - address = region + " " + city; | ||
| 39 | return address; | 43 | return address; |
| 40 | } | 44 | } |
| 41 | } | 45 | } |
-
请 注册 或 登录 后发表评论