mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-10 20:04:06 +08:00
fixed: idCard数据Mask兼容性错误
This commit is contained in:
parent
1831c7e25c
commit
5005e76b81
@ -67,13 +67,15 @@ public class BackendBus {
|
||||
}
|
||||
|
||||
public static String valueHidden(String permissionSlug, String type, String value) {
|
||||
if (BCtx.isNull()) { // 非后管环境返回原值
|
||||
if (BCtx.isNull() || value == null) { // 非后管环境直接返回 || 值为null不需要处理
|
||||
return value;
|
||||
}
|
||||
|
||||
HashMap<String, Boolean> permissions = BCtx.getAdminPer();
|
||||
if (permissions.get(permissionSlug) != null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (BackendConstant.PRIVACY_FIELD_TYPE_EMAIL.equals(type)) {
|
||||
return PrivacyUtil.hideEmail(value);
|
||||
} else if (BackendConstant.PRIVACY_FIELD_TYPE_PHONE.equals(type)) {
|
||||
|
@ -69,9 +69,7 @@ public class UserController {
|
||||
List<Department> departments =
|
||||
departmentService.listByIds(userService.getDepIdsByUserId(user.getId()));
|
||||
|
||||
if (user.getIdCard() != null && user.getIdCard().length() > 0) {
|
||||
user.setIdCard(PrivacyUtil.hideIDCard(user.getIdCard()));
|
||||
}
|
||||
user.setIdCard(PrivacyUtil.hideIDCard(user.getIdCard()));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("user", user);
|
||||
|
@ -15,22 +15,26 @@
|
||||
*/
|
||||
package xyz.playedu.api.util;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
*
|
||||
* @create 2023/3/3 10:51
|
||||
*/
|
||||
public class PrivacyUtil {
|
||||
|
||||
public static String hidePhone(String phone) {
|
||||
if (phone == null) {
|
||||
return null;
|
||||
}
|
||||
return phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
|
||||
}
|
||||
|
||||
public static String hideEmail(String email) {
|
||||
if (email == null) {
|
||||
return null;
|
||||
}
|
||||
return email.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)", "$1****$3$4");
|
||||
}
|
||||
|
||||
public static String hideIDCard(String idCard) {
|
||||
if (idCard == null) {
|
||||
return null;
|
||||
}
|
||||
return idCard.replaceAll("(\\d{4})\\d{10}(\\w{4})", "$1*****$2");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user