修改登录-添加先排除网格员
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.cms.util;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -138,18 +140,6 @@ public class StringUtil {
|
||||
.collect(Collectors.toList()); // 收集为List
|
||||
}
|
||||
|
||||
/**
|
||||
* 脱敏逻辑:前4位 + ***+ 后4位
|
||||
* @param idCard
|
||||
* @return
|
||||
*/
|
||||
public static String desensitizeIdCard(String idCard) {
|
||||
if (idCard == null || idCard.length() != 18) {
|
||||
return idCard; // 非标准身份证号不脱敏(或按规则处理)
|
||||
}
|
||||
return idCard.substring(0, 4) + "***" + idCard.substring(14);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附件地址
|
||||
* @return
|
||||
@@ -183,4 +173,44 @@ public class StringUtil {
|
||||
}
|
||||
return request.getHeader("X-Proxy-Server");
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号脱敏
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
public static String desensitizePhone(String phone) {
|
||||
if (StringUtils.isEmpty(phone) || phone.length() != 11) {
|
||||
return phone;
|
||||
}
|
||||
return phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
|
||||
}
|
||||
|
||||
/**
|
||||
* 脱敏逻辑:前4位 + ***+ 后4位
|
||||
* @param idCard
|
||||
* @return
|
||||
*/
|
||||
public static String desensitizeIdCard(String idCard) {
|
||||
if (StringUtils.isEmpty(idCard)) {
|
||||
return null;
|
||||
}
|
||||
// 处理18位身份证(支持末尾X/x)
|
||||
if (idCard.matches("\\d{17}[\\dXx]")) {
|
||||
return idCard.replaceAll("(\\d{6})\\d{8}([\\dXx]{4})", "$1********$2");
|
||||
}
|
||||
// 处理15位身份证
|
||||
else if (idCard.matches("\\d{15}")) {
|
||||
return idCard.replaceAll("(\\d{6})\\d{6}(\\d{3})", "$1******$2");
|
||||
}
|
||||
// 非标准格式(如16位、含特殊字符):返回部分脱敏(前4位+****+后2位),避免明文暴露
|
||||
else {
|
||||
int len = idCard.length();
|
||||
if (len >= 6) {
|
||||
return idCard.substring(0, 4) + "****" + idCard.substring(len - 2);
|
||||
}
|
||||
// 长度过短(<6位):直接返回***,避免明文
|
||||
return "***";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user