获取ip地址开关
This commit is contained in:
@ -2,6 +2,7 @@ package com.ruoyi.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.framework.config.RuoYiConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -21,12 +22,15 @@ public class AddressUtils
|
||||
String address = "";
|
||||
try
|
||||
{
|
||||
address = HttpUtils.sendPost(IP_URL, "ip=" + ip);
|
||||
JSONObject json = JSONObject.parseObject(address);
|
||||
JSONObject object = json.getObject("data", JSONObject.class);
|
||||
String region = object.getString("region");
|
||||
String city = object.getString("city");
|
||||
address = region + " " + city;
|
||||
if (RuoYiConfig.isAddressEnabled())
|
||||
{
|
||||
address = HttpUtils.sendPost(IP_URL, "ip=" + ip);
|
||||
JSONObject json = JSONObject.parseObject(address);
|
||||
JSONObject object = json.getObject("data", JSONObject.class);
|
||||
String region = object.getString("region");
|
||||
String city = object.getString("city");
|
||||
address = region + " " + city;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user