xiongzhu 3 年之前
父節點
當前提交
a989d08d46
共有 1 個文件被更改,包括 5 次插入6 次删除
  1. 5 6
      src/main/java/com/izouma/nineth/service/IdentityAuthService.java

+ 5 - 6
src/main/java/com/izouma/nineth/service/IdentityAuthService.java

@@ -156,8 +156,8 @@ public class IdentityAuthService {
 
     public static void validate(String name, String phone, String idno) {
         HttpRequest request = HttpRequest.get("https://mobilecert.market.alicloudapi.com/mobile3MetaSimple?userName="
-                + URLEncoder.encode(name, StandardCharsets.UTF_8)
-                + "&identifyNum=" + idno + "&mobile=" + phone)
+                        + URLEncoder.encode(name, StandardCharsets.UTF_8)
+                        + "&identifyNum=" + idno + "&mobile=" + phone)
                 .header("Authorization", "APPCODE af29c2d37c4f415fac930d82f01fb559");
         String body = request.body();
         if (request.code() != 200) {
@@ -260,10 +260,9 @@ public class IdentityAuthService {
         User user = userRepo.findById(identityAuth.getUserId()).orElseThrow(new BusinessException("用户不存在"));
         if (user.getAuthStatus() == AuthStatus.SUCCESS) {
             result.put("status", AuthStatus.SUCCESS);
-        } else if (!Pattern
-                .matches("[1-9]{1}[0-9]{5}(19|20)[0-9]{2}((0[1-9]{1})|(1[0-2]{1}))((0[1-9]{1})|([1-2]{1}[0-9]{1}|(3[0-1]{1})))[0-9]{3}[0-9x]{1}", identityAuth
-                        .getIdNo()
-                        .toLowerCase())) {
+        } else if (identityAuth.getIdNo() == null ||
+                !Pattern.matches("[1-9]{1}[0-9]{5}(19|20)[0-9]{2}((0[1-9]{1})|(1[0-2]{1}))((0[1-9]{1})|([1-2]{1}[0-9]{1}|(3[0-1]{1})))[0-9]{3}[0-9x]{1}",
+                        identityAuth.getIdNo().toLowerCase())) {
             result.put("status", AuthStatus.FAIL);
             result.put("reason", "身份证格式错误");
         } else {