Commit 46a1695292f0ad4f9618aed1faa551eb94468ae1
1 parent
b7107a4d
修复地址开关无效问题
Showing
1 changed file
with
13 additions
and
9 deletions
ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
| ... | ... | @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; |
| 5 | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | 6 | import com.ruoyi.common.utils.StringUtils; |
| 7 | 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 | 26 | { |
| 26 | 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 | 43 | return address; |
| 40 | 44 | } |
| 41 | 45 | } | ... | ... |