调整ip工具类
This commit is contained in:
@@ -2,7 +2,6 @@ package xtools.boot.core.utils;
|
|||||||
|
|
||||||
import xtools.base.config.BaseParams;
|
import xtools.base.config.BaseParams;
|
||||||
import xtools.core.StringUtils;
|
import xtools.core.StringUtils;
|
||||||
import xtools.core.encrypt.Md5Utils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -45,23 +44,4 @@ public class AddrUtils implements BaseParams {
|
|||||||
return LOCAL_IP_LIST.contains(ip);
|
return LOCAL_IP_LIST.contains(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据IP地址获取通用地址code
|
|
||||||
*
|
|
||||||
* @param country 国家
|
|
||||||
* @param province 省份
|
|
||||||
* @param city 城市
|
|
||||||
* @return 通用地址code
|
|
||||||
*/
|
|
||||||
public static String getCode(String country, String province, String city) {
|
|
||||||
String code = country;
|
|
||||||
if (StringUtils.isNotBlank(province)) {
|
|
||||||
code += CP_LINE + province;
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(city)) {
|
|
||||||
code += CP_LINE + city;
|
|
||||||
}
|
|
||||||
return Md5Utils.encryptToString(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package xtools.boot.ip.utils;
|
|||||||
import xtools.base.config.BaseParams;
|
import xtools.base.config.BaseParams;
|
||||||
import xtools.boot.api.exection.BizError;
|
import xtools.boot.api.exection.BizError;
|
||||||
import xtools.core.StringUtils;
|
import xtools.core.StringUtils;
|
||||||
|
import xtools.core.encrypt.Md5Utils;
|
||||||
import xtools.extend.IpLocalUtils;
|
import xtools.extend.IpLocalUtils;
|
||||||
import xtools.extend.dto.IpAddrDto;
|
import xtools.extend.dto.IpAddrDto;
|
||||||
|
|
||||||
@@ -80,4 +81,14 @@ public class IpUtils implements BaseParams {
|
|||||||
return joiner.toString();
|
return joiner.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取IP对应地址的编码
|
||||||
|
*
|
||||||
|
* @param addr 地址信息
|
||||||
|
* @return IP对应地址的编码
|
||||||
|
*/
|
||||||
|
public static String getCode(IpAddrDto addr) {
|
||||||
|
return Md5Utils.encryptToString(searchAddr(addr));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user