From 03a858f2882bedeb5925b65cb045ccbbb1202329 Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期三, 24 十一月 2021 16:01:04 +0800 Subject: [PATCH] [update] otp呼叫方式調整,並針對sit版本除錯 --- pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java | 29 +++++++++++++---------------- 1 files changed, 13 insertions(+), 16 deletions(-) diff --git a/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java b/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java index 6308dac..65abd26 100644 --- a/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java +++ b/pamapi/src/main/java/com/pollex/pam/web/rest/OtpResource.java @@ -21,6 +21,7 @@ import javax.xml.rpc.ServiceException; import java.rmi.RemoteException; +import java.util.Arrays; import java.util.UUID; @RestController @@ -43,22 +44,18 @@ @PostMapping("/sendOtp") public ResponseEntity<Object> sendOtp(@RequestBody OtpLoginVM login) { - try { - if(applicationProperty.isMockLogin()) { - return new ResponseEntity<>(getMockSendOtpResponse(), HttpStatus.OK); - } - - if(login.getLoginType() == OtpLoginTypeEnum.SMS) { - return new ResponseEntity<>(otpWebService.sendByPhone(login.getAccount()), HttpStatus.OK); - } - else if(login.getLoginType() == OtpLoginTypeEnum.EMAIL) { - return new ResponseEntity<>(otpWebService.sendByEmail(login.getAccount()), HttpStatus.OK); - } - - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("can not support this login type, loginType = " + login.getLoginType().name()); - } catch (ServiceException | RemoteException e) { - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("connecting otp web service error"); + if(applicationProperty.isMockLogin()) { + return new ResponseEntity<>(getMockSendOtpResponse(), HttpStatus.OK); } + + if(login.getLoginType() == OtpLoginTypeEnum.SMS) { + return new ResponseEntity<>(otpWebService.sendByPhone(login.getAccount()), HttpStatus.OK); + } + else if(login.getLoginType() == OtpLoginTypeEnum.EMAIL) { + return new ResponseEntity<>(otpWebService.sendByEmail(login.getAccount()), HttpStatus.OK); + } + + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("can not support this login type, loginType = " + login.getLoginType().name()); } @PostMapping("/verify") @@ -79,6 +76,6 @@ private OtpResponseDTO getMockSendOtpResponse() { String indexKey = UUID.randomUUID().toString().substring(0, 8); - return new OtpResponseDTO(new String[]{indexKey, "0", "", ""}); + return new OtpResponseDTO(Arrays.asList(indexKey, "0", "", "")); } } -- Gitblit v1.8.0