Browse Source

校验证件号

dev
jianjun 3 years ago
parent
commit
f628fc5b25
  1. 12
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java
  2. 2
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java
  3. 8
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  4. 10
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/PersonalCenterController.java
  5. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java
  6. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcTripReportFormDTO.java
  7. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java

12
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IdCardRegexUtils.java

@ -52,13 +52,23 @@ public class IdCardRegexUtils {
private String sex;
}
/**
* desc:校验输入的证件号是否合法
* @param input
* @return
*/
public static boolean validateIdCard(String input){
IdCardRegexUtils parse = IdCardRegexUtils.parse(input);
return parse != null;
}
/**
* 解析正则
* @param input
* @return
*/
public static IdCardRegexUtils parse(String input) {
if (input == null) {
if (input == null || input.trim().length() == 0) {
return null;
}

2
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/resi/ResiVolunteerAuthenticateFormDTO.java

@ -59,7 +59,7 @@ public class ResiVolunteerAuthenticateFormDTO implements Serializable {
/**
* 身份证号码
*/
@NotBlank(message = "身份证号码不能为空", groups = {AddUserShowGroup.class })
@NotBlank(message = "证号能为空", groups = {AddUserShowGroup.class })
private String idNum;
/**

8
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java

@ -22,6 +22,7 @@ import com.epmet.commons.tools.dto.form.mq.MqBaseFormDTO;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.SystemMessageType;
@ -38,6 +39,7 @@ import com.epmet.dto.result.resi.ResiVolunteerInfoResultDTO;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.send.SendMqMsgUtil;
import com.epmet.service.VolunteerInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -72,6 +74,12 @@ public class ResiVolunteerController {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO, ResiVolunteerAuthenticateFormDTO.AddUserShowGroup.class, ResiVolunteerAuthenticateFormDTO.AddUserInternalGroup.class);
if (StringUtils.isNotBlank(formDTO.getIdNum())){
boolean b = IdCardRegexUtils.validateIdCard(formDTO.getIdNum());
if (!b){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"请输入正确的证件号","请输入正确的证件号");
}
}
volunteerInfoService.authenticate(formDTO);
//发送志愿者人员消息变动

10
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/controller/PersonalCenterController.java

@ -1,7 +1,10 @@
package com.epmet.modules.mine.controller;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.IdCardRegexUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.EditInfoFormDTO;
@ -10,6 +13,7 @@ import com.epmet.dto.form.SendCodeFormDTO;
import com.epmet.modules.mine.service.PersonalCenterService;
import com.epmet.resi.mine.dto.result.InitInfoResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -55,6 +59,12 @@ public class PersonalCenterController {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setCustomerId(tokenDto.getCustomerId());
ValidatorUtils.validateEntity(formDTO,EditInfoFormDTO.AddUserShowGroup.class,EditInfoFormDTO.AddUserInternalGroup.class);
if (StringUtils.isNotBlank(formDTO.getIdNum())){
boolean b = IdCardRegexUtils.validateIdCard(formDTO.getIdNum());
if (!b){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"请输入正确的证件号","请输入正确的证件号");
}
}
personalCenterService.editInfo(tokenDto, formDTO);
return new Result();
}

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/EditInfoFormDTO.java

@ -47,7 +47,7 @@ public class EditInfoFormDTO implements Serializable {
private String name;
//@NotBlank(message = "身份证号不能为空")
@Length(max=18,message = "身份证号不能超过18位",groups = AddUserShowGroup.class)
@Length(max=18,message = "证号不能超过18位",groups = AddUserShowGroup.class)
//别的小程序不统一升级,没办法限制必填。
private String idNum;

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/IcTripReportFormDTO.java

@ -57,7 +57,7 @@ public class IcTripReportFormDTO implements Serializable {
/**
* 身份证号
*/
@NotBlank(message = "身份证号能为空", groups = {ResiUserRequired.class,PcAddRequired.class,PcUpdateRequired.class})
@NotBlank(message = "证号能为空", groups = {ResiUserRequired.class,PcAddRequired.class,PcUpdateRequired.class})
private String idCard;
/**

7
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java

@ -33,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
@ -159,6 +160,12 @@ public class IcTripReportRecordController implements ResultDataResolver {
formDTO.setUserId(tokenDto.getUserId());
formDTO.setUserType(IcResiUserConstant.USER_TYPE_RESI);
ValidatorUtils.validateEntity(formDTO,IcTripReportFormDTO.ResiUserRequired.class,IcTripReportFormDTO.ResiUserInternalGroup.class);
if (StringUtils.isNotBlank(formDTO.getIdCard())){
boolean b = IdCardRegexUtils.validateIdCard(formDTO.getIdCard());
if (!b){
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"请输入正确的证件号","请输入正确的证件号");
}
}
return new Result().ok(icTripReportRecordService.resiSave(formDTO));
}

Loading…
Cancel
Save