From 3ba44be9c7547870e817d29b100119a518fdf4e8 Mon Sep 17 00:00:00 2001 From: XiaoHH <1431984546@qq.com> Date: Thu, 6 Jul 2023 13:31:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PassengerVerificationController.java | 5 ++--- .../service/PassengerVerificationService.java | 2 +- .../PassengerVerificationServiceImpl.java | 13 +++-------- .../entity/respose/ResponseEntity.java | 22 +++++++++---------- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/api/api-passenger/src/main/java/com/greateme/passenger/controller/PassengerVerificationController.java b/api/api-passenger/src/main/java/com/greateme/passenger/controller/PassengerVerificationController.java index 0be09ab..b89c74d 100644 --- a/api/api-passenger/src/main/java/com/greateme/passenger/controller/PassengerVerificationController.java +++ b/api/api-passenger/src/main/java/com/greateme/passenger/controller/PassengerVerificationController.java @@ -51,8 +51,7 @@ public class PassengerVerificationController { * @return 检查结果,返回bool,判断是否正确 */ @PostMapping("/check") - public ResponseEntity checkVerificationCode(@RequestBody PassengerVerificationCodeVO passengerVerificationCode) { - Boolean checkResult = this.verificationService.checkPhoneVerificationCode(passengerVerificationCode); - return ResponseEntity.success(checkResult); + public ResponseEntity checkVerificationCode(@RequestBody PassengerVerificationCodeVO passengerVerificationCode) { + return ResponseEntity.success(this.verificationService.checkPhoneVerificationCode(passengerVerificationCode)); } } diff --git a/api/api-passenger/src/main/java/com/greateme/passenger/service/PassengerVerificationService.java b/api/api-passenger/src/main/java/com/greateme/passenger/service/PassengerVerificationService.java index 3ac5ce4..d524297 100644 --- a/api/api-passenger/src/main/java/com/greateme/passenger/service/PassengerVerificationService.java +++ b/api/api-passenger/src/main/java/com/greateme/passenger/service/PassengerVerificationService.java @@ -29,5 +29,5 @@ public interface PassengerVerificationService { * @param passengerVerificationCode 手机验证码的检查对象 * @return 检查结果,返回bool,判断是否正确 */ - Boolean checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode); + Integer checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode); } diff --git a/api/api-passenger/src/main/java/com/greateme/passenger/service/impl/PassengerVerificationServiceImpl.java b/api/api-passenger/src/main/java/com/greateme/passenger/service/impl/PassengerVerificationServiceImpl.java index a95c5a4..dad18fb 100644 --- a/api/api-passenger/src/main/java/com/greateme/passenger/service/impl/PassengerVerificationServiceImpl.java +++ b/api/api-passenger/src/main/java/com/greateme/passenger/service/impl/PassengerVerificationServiceImpl.java @@ -1,22 +1,15 @@ package com.greateme.passenger.service.impl; -import com.greateme.contant.business.VerificationCodeConstant; import com.greateme.contant.http.HttpStatus; import com.greateme.entity.respose.ResponseEntity; import com.greateme.passenger.service.PassengerVerificationService; -import com.greateme.util.StringUtil; import com.greateme.verification.entity.dto.PassengerVerificationCodeDTO; -import com.greateme.verification.entity.dto.PassengerVerificationCodeRedisDTO; import com.greateme.verification.entity.vo.PassengerVerificationCodeVO; import com.greateme.verification.feign.VerificationCodeRemote; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; - -import java.util.Objects; -import java.util.UUID; /** *

@@ -52,7 +45,7 @@ public class PassengerVerificationServiceImpl implements PassengerVerificationSe public String generationPhoneVerificationCode(PassengerVerificationCodeDTO verificationCode) { ResponseEntity passengerVerificationCodeEntity = verificationCodeRemote.passengerPhone(verificationCode, 6); if (HttpStatus.SUCCESS.getCode() == passengerVerificationCodeEntity.getCode()) { - PassengerVerificationCodeVO passengerVerificationCode = passengerVerificationCodeEntity.getDate(); + PassengerVerificationCodeVO passengerVerificationCode = passengerVerificationCodeEntity.getData(); if (null != passengerVerificationCode) { log.info("成功生成验证码:{},验证码的token为:{}", passengerVerificationCode.getVerificationCode(), passengerVerificationCode.getVerificationToken()); return passengerVerificationCode.getVerificationToken(); @@ -70,10 +63,10 @@ public class PassengerVerificationServiceImpl implements PassengerVerificationSe * @return 检查结果,返回bool,判断是否正确 */ @Override - public Boolean checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode) { + public Integer checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode) { ResponseEntity checkResult = verificationCodeRemote.checkPhoneVerificationCode(passengerVerificationCode); if (HttpStatus.SUCCESS.getCode() == checkResult.getCode()) { - return Objects.equals(VerificationCodeConstant.VERIFICATION_CODE_RIGHT, checkResult.getDate()); + return checkResult.getData(); } log.error("判断验证码是否正确的是否发生了错误,错误码:{},错误信息:{}", checkResult.getCode(), checkResult.getMessage()); return null; diff --git a/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java b/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java index 34fbcb4..9009c39 100644 --- a/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java +++ b/common/common-entity/src/main/java/com/greateme/entity/respose/ResponseEntity.java @@ -27,12 +27,12 @@ public class ResponseEntity implements Serializable { * 全参构造函数 * * @param code 状态码 - * @param date 数据内容 + * @param data 数据内容 * @param message 处理的消息信息 */ - public ResponseEntity(int code, T date, String message) { + public ResponseEntity(int code, T data, String message) { this.code = code; - this.date = date; + this.data = data; this.message = message; } @@ -40,12 +40,12 @@ public class ResponseEntity implements Serializable { * 带HttpStatus和数据的构造函数 * * @param httpStatus http状态枚举 - * @param date 返回的数据内容 + * @param data 返回的数据内容 */ - public ResponseEntity(HttpStatus httpStatus, T date) { + public ResponseEntity(HttpStatus httpStatus, T data) { this.code = httpStatus.getCode(); this.message = httpStatus.getMessage(); - this.date = date; + this.data = data; } /** @@ -79,7 +79,7 @@ public class ResponseEntity implements Serializable { /** * 返回的数据内容 */ - private T date; + private T data; /** * 返回的处理的消息信息 @@ -126,12 +126,12 @@ public class ResponseEntity implements Serializable { this.code = code; } - public T getDate() { - return date; + public T getData() { + return data; } - public void setDate(T date) { - this.date = date; + public void setData(T date) { + this.data = date; } public String getMessage() {