From b20110d70fed2f6e53dd8beb5f50661bf0d0877c Mon Sep 17 00:00:00 2001 From: "java_cuibaocheng@163.com" Date: Fri, 17 Nov 2023 15:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=8F=A3=E5=9F=BA=E6=9C=AC=E4=BF=A1?= =?UTF-8?q?=E6=81=AF-=20=E4=BF=AE=E6=94=B9=E8=84=B1=E6=95=8FBug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PopulationInfoServiceImpl.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) 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("姓名错误");