获取ip地址开关

This commit is contained in:
RuoYi
2018-08-10 14:36:31 +08:00
parent d7dc50a157
commit 07ffcbf6eb
28 changed files with 27 additions and 55 deletions

View File

@ -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)
{