Browse Source

【通用】新增对中文名字的打码规则;【五大图层】综合治理图层列表对中文名字打码

master
wangxianzhang 3 years ago
parent
commit
e725886b42
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/MaskResponse.java
  2. 24
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java
  3. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/annotation/MaskResponse.java

@ -15,6 +15,7 @@ public @interface MaskResponse {
*/
String MASK_TYPE_ID_CARD = "ID_CARD";
String MASK_TYPE_MOBILE = "MOBILE";
String MASK_TYPE_CHINESE_NAME = "CHINESE_NAME";
///**
// * 默认的一些字段,如果没有手动指定,就会使用默认的。如果手动指定了,就不再使用默认的

24
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/processor/MaskProcessor.java

@ -133,11 +133,35 @@ public class MaskProcessor {
return maskIdCard(originString);
} else if (MaskResponse.MASK_TYPE_MOBILE.equals(maskType)) {
return maskMobile(originString);
} else if (MaskResponse.MASK_TYPE_CHINESE_NAME.equals(maskType)) {
return maskChineseName(originString);
} else {
return originString;
}
}
/**
* 对中文人名进行打码
* @param originString
* @return
*/
private String maskChineseName(String originString) {
if (StringUtils.isBlank(originString)) {
// 空串,或者只有一个字的,不打码,直接返回
return originString;
}
int length = originString.length();
// 2个字以上的,首位字母明文,中间*
// 中文不能用\\w,要用[\u4e00-\u9fa5]
if (length == 2) {
return originString.replaceAll("^([\\u4e00-\\u9fa5]).*$", "$1*");
} else {
String maskStr = StrUtil.repeat("*", length - 2);
return originString.replaceAll("^([\\u4e00-\\u9fa5]).*([\\u4e00-\\u9fa5])$", "$1" + maskStr + "$2");
}
}
/**
* 唯一整件号打码可能是身份证号或者是护照号
* 将明文字符串打码变为掩码保留前6后面打码

3
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -1365,7 +1365,8 @@ public class IcResiUserController implements ResultDataResolver {
* @return
*/
@PostMapping("listresi-zhzl")
@MaskResponse(fieldNames = {"MOBILE", "ID_CARD"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD})
@MaskResponse(fieldNames = {"MOBILE", "ID_CARD", "NAME"},
fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD, MaskResponse.MASK_TYPE_CHINESE_NAME})
public Result<PageData<Map<String, Object>>> listResiZhzl(@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO) {
pageFormDTO.setCustomerId(tokenDto.getCustomerId());
pageFormDTO.setStaffId(tokenDto.getUserId());

Loading…
Cancel
Save