diff --git a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java index c912186..48250bc 100644 --- a/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java +++ b/users/src/main/java/com/huoran/users/controller/AliRealNameAuthenticationController.java @@ -79,13 +79,15 @@ public class AliRealNameAuthenticationController { //身份证信息返回 String idCardInformationReturn = FaceRecognitionAidUtil.IdCardOCRRecognition(imgFile, side); if (ObjectUtils.isEmpty(idCardInformationReturn)) { - throw new RuntimeException("身份证图片验证失败,请重新再试!"); +// ("身份证图片验证失败,请重新再试!"); + return R.error("身份证图片验证失败,请重新再试!"); } IdCardOCRResp resp = new Gson().fromJson(idCardInformationReturn, IdCardOCRResp.class); if (resp.getSuccess()) { return R.ok().put("data", resp); } else { - throw new RuntimeException("身份证图片验证失败,请重新再试!"); +// ("身份证图片验证失败,请重新再试!"); + return R.error("身份证图片验证失败,请重新再试!"); } } @@ -101,7 +103,8 @@ public class AliRealNameAuthenticationController { RealNameAuthenticationResp info = new Gson().fromJson(json, RealNameAuthenticationResp.class); if (!info.getRespCode().equals("0000")) { - throw new RuntimeException(info.getRespMessage()); + // (); + return R.error(info.getRespMessage()); } QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -151,7 +154,7 @@ public class AliRealNameAuthenticationController { queryWrapper.eq("account_id", accountId); UserAuthenticationInformation userAuthenticationInformation = service.getOne(queryWrapper); if (ObjectUtils.isEmpty(userAuthenticationInformation)) { - return R.ok().put("data", false); + return R.ok().put("data", false).put("msg", "未认证"); } return R.ok().put("data", true).put("authenticationInformation", userAuthenticationInformation); } @@ -174,11 +177,13 @@ public class AliRealNameAuthenticationController { if (info.getSuccess()) { return R.ok().put("data", info); } else { - throw new RuntimeException("营业执照图片验证,请重新再试!"); + //("营业执照图片验证失败,请重新再试!"); + return R.error("营业执照图片验证失败,请重新再试!"); } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException("营业执照图片验证,请重新再试!"); +// ("营业执照图片验证失败,请重新再试!"); + return R.error("营业执照图片验证失败,请重新再试!"); } } @@ -214,7 +219,9 @@ public class AliRealNameAuthenticationController { if (info.getStatus()) { if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), certification.getId(), enterpriseCertification.getOpenId()))) { errorMsg = "企业名称已存在"; - throw new RuntimeException(errorMsg); +// (errorMsg); + + return R.error(errorMsg); } enterpriseCertificationService.updateById(enterpriseCertification); @@ -225,7 +232,8 @@ public class AliRealNameAuthenticationController { } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException(errorMsg); +// (errorMsg); + return R.error(errorMsg); } @@ -258,7 +266,7 @@ public class AliRealNameAuthenticationController { if (info.getStatus()) { if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, enterpriseCertification.getOpenId()))) { errorMsg = "企业名称已存在"; - throw new RuntimeException(errorMsg); + return R.error(errorMsg); } enterpriseCertificationService.save(enterpriseCertification); return R.ok("提交成功,请等待审核!"); @@ -268,7 +276,7 @@ public class AliRealNameAuthenticationController { } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException(errorMsg); + return R.error().put("message", errorMsg); } @@ -294,20 +302,20 @@ public class AliRealNameAuthenticationController { if (info.getStatus()) { /*if (!ObjectUtils.isEmpty(enterpriseCertificationService.checkWhetherItExists(enterpriseCertification.getCompanyName(), null, enterpriseCertification.getOpenId()))) { errorMsg = "企业名称已存在"; - throw new RuntimeException(errorMsg); + (errorMsg); } enterpriseCertificationService.save(enterpriseCertification);*/ } else { errorMsg = info.getReason(); - System.err.println("错误信息:"+errorMsg); + System.err.println("错误信息:" + errorMsg); } } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException(errorMsg); + errorMsg = "系统错误"; } - } + } } \ No newline at end of file