diff --git a/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java b/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java index d3f1f04..f014874 100644 --- a/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java +++ b/src/main/java/com/cm/population/service/populationinfo/impl/PopulationInfoServiceImpl.java @@ -100,6 +100,18 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul if (dto.getIdcardType().contains("身份证")) { String idCardNumber = IdCardVerifyUtil.desensitizeIdCardNumber(idcard); dto.setIdcard(idCardNumber); + }else{ + if (idcard.length() > 2) { + String xin = ""; + for(int i = 0; i < idcard.length() - 2; i++) { + xin = xin + "*"; + } + String newIdcard = idcard.substring(0, 1) + xin + idcard.substring(idcard.length()-1, idcard.length()); + dto.setIdcard(newIdcard); + }else{ + String newIdcard = idcard.substring(0, 1) + "*"; + dto.setIdcard(newIdcard); + } } if (!StringUtil.isEmpty(phone) && phone.length() == 11) { if(phone.startsWith("0")) { @@ -136,6 +148,18 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul if (dto.getIdcardType().contains("身份证")) { String idCardNumber = IdCardVerifyUtil.desensitizeIdCardNumber(idcard); dto.setIdcard(idCardNumber); + }else{ + if (idcard.length() > 2) { + String xin = ""; + for(int i = 0; i < idcard.length() - 2; i++) { + xin = xin + "*"; + } + String newIdcard = idcard.substring(0, 1) + xin + idcard.substring(idcard.length()-1, idcard.length()); + dto.setIdcard(newIdcard); + }else{ + String newIdcard = idcard.substring(0, 1) + "*"; + dto.setIdcard(newIdcard); + } } if (!StringUtil.isEmpty(phone) && phone.length() == 11) { if(phone.startsWith("0")) { @@ -256,6 +280,10 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul if(!IdCardVerifyUtil.isIDCard(populationInfoVO.getIdcard().trim())) { throw new SaveException("该证件号码错误"); } + }else{ + if (populationInfoVO.getIdcard().length() < 5 || populationInfoVO.getIdcard().length() > 30) { + throw new SaveException("该证件号码错误"); + } } if (populationInfoVO.getName().length() < 2 || populationInfoVO.getName().length() > 15) { throw new SaveException("姓名错误"); @@ -332,6 +360,10 @@ public class PopulationInfoServiceImpl extends AbstractService implements IPopul if(!IdCardVerifyUtil.isIDCard(populationInfoVO.getIdcard().trim())) { throw new SaveException("该证件号码错误"); } + }else{ + if (populationInfoVO.getIdcard().length() < 5 || populationInfoVO.getIdcard().length() > 30) { + throw new SaveException("该证件号码错误"); + } } if (populationInfoVO.getName().length() < 2 || populationInfoVO.getName().length() > 15) { throw new SaveException("姓名错误");