提交修改
This commit is contained in:
parent
4e928d78a7
commit
1c12a86063
@ -4121,8 +4121,8 @@ public class IDCardValidatorUtils {
|
||||
|
||||
public static IdCardAddressModel getAddrInfo(String idCard){
|
||||
String p = idCard.substring(0, 2);
|
||||
String a = idCard.substring(6, 13);
|
||||
|
||||
String a = idCard.substring(6, 14);
|
||||
String birthday = a ;
|
||||
if(a.length()==8){
|
||||
birthday = a.substring(0,4) + "-" + a.substring(4,6) + "-" + a.substring(6,8);
|
||||
@ -4164,11 +4164,65 @@ public class IDCardValidatorUtils {
|
||||
}
|
||||
|
||||
|
||||
public static String maskRealName(String realName) {
|
||||
if(StringUtils.isBlank(realName)){
|
||||
return "";
|
||||
}
|
||||
if(realName.length() == 1 ){
|
||||
return realName + "**";
|
||||
}
|
||||
|
||||
int length = realName.length();
|
||||
StringBuffer sb = new StringBuffer(realName.substring(0,1));
|
||||
for(int i = 0 ;i < length -1 ;i ++){
|
||||
sb.append("*");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static String maskIdCard(String idcard) {
|
||||
int length = idcard.length();
|
||||
if(StringUtils.isBlank(idcard)){
|
||||
return "";
|
||||
}
|
||||
if(idcard.length()<=6){
|
||||
return "******";
|
||||
}
|
||||
|
||||
|
||||
StringBuffer sb = new StringBuffer(idcard.substring(0,6));
|
||||
for(int i = 0 ;i < length -7 ;i ++){
|
||||
sb.append("*");
|
||||
}
|
||||
sb.append(idcard.substring(length-1,length));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String a = "19920925";
|
||||
String b = a.substring(0,4) + "-" + a.substring(4,6) + "-" + a.substring(6,8);
|
||||
System.out.println(a.length());
|
||||
System.out.println(b);
|
||||
String idCard = "360311199303080027";
|
||||
|
||||
|
||||
String a = idCard.substring(6, 14);
|
||||
String birthday = a ;
|
||||
|
||||
if(a.length()==8){
|
||||
birthday = a.substring(0,4) + "-" + a.substring(4,6) + "-" + a.substring(6,8);
|
||||
}
|
||||
|
||||
System.out.println(birthday);
|
||||
|
||||
System.out.println(maskRealName("瞿"));
|
||||
System.out.println(maskIdCard("360311199303080027"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -84,8 +84,9 @@ public class IdCardOCRVerificationController {
|
||||
idCardOCRVerificationResp.setDesc(idCardOCRVerificationResponse.getDescription()); //其他情况
|
||||
}
|
||||
|
||||
idCardOCRVerificationResp.setIdCardNumber(apiIdentityCardRequest.getIdCardNumber());
|
||||
idCardOCRVerificationResp.setRealName(apiIdentityCardRequest.getRealName());
|
||||
idCardOCRVerificationResp.setIdCardNumber(IDCardValidatorUtils.maskIdCard(apiIdentityCardRequest.getIdCardNumber()));
|
||||
idCardOCRVerificationResp.setRealName(IDCardValidatorUtils.maskRealName(apiIdentityCardRequest.getRealName()));
|
||||
|
||||
return R.ok().setData(idCardOCRVerificationResp);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user