优化代码

main
XiaoHH 2 years ago
parent 4f3e06237b
commit 3ba44be9c7

@ -51,8 +51,7 @@ public class PassengerVerificationController {
* @return bool
*/
@PostMapping("/check")
public ResponseEntity<Boolean> checkVerificationCode(@RequestBody PassengerVerificationCodeVO passengerVerificationCode) {
Boolean checkResult = this.verificationService.checkPhoneVerificationCode(passengerVerificationCode);
return ResponseEntity.success(checkResult);
public ResponseEntity<Integer> checkVerificationCode(@RequestBody PassengerVerificationCodeVO passengerVerificationCode) {
return ResponseEntity.success(this.verificationService.checkPhoneVerificationCode(passengerVerificationCode));
}
}

@ -29,5 +29,5 @@ public interface PassengerVerificationService {
* @param passengerVerificationCode
* @return bool
*/
Boolean checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode);
Integer checkPhoneVerificationCode(PassengerVerificationCodeVO passengerVerificationCode);
}

@ -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;
/**
* <p>
@ -52,7 +45,7 @@ public class PassengerVerificationServiceImpl implements PassengerVerificationSe
public String generationPhoneVerificationCode(PassengerVerificationCodeDTO verificationCode) {
ResponseEntity<PassengerVerificationCodeVO> 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<Integer> 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;

@ -27,12 +27,12 @@ public class ResponseEntity<T> 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<T> 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<T> implements Serializable {
/**
*
*/
private T date;
private T data;
/**
*
@ -126,12 +126,12 @@ public class ResponseEntity<T> 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() {

Loading…
Cancel
Save