获取应用信息.

This commit is contained in:
lijiahang
2024-06-17 19:12:58 +08:00
parent dfd2ec45f4
commit cfe1924f11
9 changed files with 218 additions and 10 deletions

View File

@@ -13,4 +13,8 @@ public interface CnConst {
String CN_ROLE = "角色";
String CN_UNKNOWN = "未知";
String CN_INTRANET_IP = "内网IP";
}

View File

@@ -17,10 +17,6 @@ public interface Const extends com.orion.lang.constant.Const, FieldConst, CnCons
int MD5_LEN = 32;
String UNKNOWN = "未知";
String INTRANET_IP = "内网IP";
Long ROOT_PARENT_ID = 0L;
Integer DEFAULT_SORT = 10;

View File

@@ -29,7 +29,7 @@ public class IpUtils {
*/
public static String getLocation(String ip) {
if (ip == null) {
return Const.UNKNOWN;
return Const.CN_UNKNOWN;
}
// 查询缓存
return CACHE.computeIfAbsent(ip, IpUtils::queryLocation);
@@ -43,21 +43,21 @@ public class IpUtils {
*/
private static String queryLocation(String ip) {
if (ip == null) {
return Const.UNKNOWN;
return Const.CN_UNKNOWN;
}
Region region;
try {
region = LocationRegions.getRegion(ip, 3);
} catch (Exception e) {
return Const.UNKNOWN;
return Const.CN_UNKNOWN;
}
if (region != null) {
String net = region.getNet();
String province = region.getProvince();
if (net.equals(Const.INTRANET_IP)) {
if (net.equals(Const.CN_INTRANET_IP)) {
return net;
}
if (province.equals(Const.UNKNOWN)) {
if (province.equals(Const.CN_UNKNOWN)) {
return province;
}
StringBuilder location = new StringBuilder()
@@ -69,7 +69,7 @@ public class IpUtils {
location.append(" (").append(net).append(')');
return location.toString();
}
return Const.UNKNOWN;
return Const.CN_UNKNOWN;
}
}

View File

@@ -0,0 +1,39 @@
package com.orion.visor.framework.common.utils;
import com.orion.lang.utils.Arrays1;
import com.orion.lang.utils.crypto.Caesars;
/**
* 混淆工具类
*
* @author Jiahang Li
* @version 1.0.0
* @since 2024/6/17 18:27
*/
public class Mixes {
private Mixes() {
}
/**
* 混淆
* <p>
* 此方法不可修改
*
* @param str str
* @return str
*/
public static String obfuscate(String str) {
char[] chars = str.toCharArray();
Arrays1.reverse(chars);
for (int i = 0; i < chars.length; i += 2) {
char temp = chars[i];
chars[i] = chars[i + 1];
chars[i + 1] = temp;
}
String res = new String(chars);
return new Caesars().encrypt(res);
}
}