校验验证码骨架编写

main
topsun 2 years ago
parent 7a7d3735a7
commit 92aa34eb19

@ -5,6 +5,7 @@ import com.taxi.apipassenger.request.VerificationCodeDTO;
import com.taxi.apipassenger.service.VerificationCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@ -20,4 +21,11 @@ public class VerificationCodeController {
System.out.println("接受到的手机号码参数:"+passengerPhone);
return verificationCodeService.generatorCode(passengerPhone);
}
@PostMapping("/verification-code-check")
public ResponseResult verificationCodeCheck(@RequestBody VerificationCodeDTO verificationCodeDTO){
String passengerPhone = verificationCodeDTO.getPassengerPhone();
String verificationCode = verificationCodeDTO.getVerificationCode();
return verificationCodeService.checkCode(passengerPhone,verificationCode);
}
}

@ -1,14 +1,13 @@
package com.taxi.apipassenger.request;
import lombok.Data;
@Data
public class VerificationCodeDTO {
private String passengerPhone;
public String getPassengerPhone() {
return passengerPhone;
}
private String verificationCode;
public void setPassengerPhone(String passengerPhone) {
this.passengerPhone = passengerPhone;
}
}

@ -1,6 +1,7 @@
package com.taxi.apipassenger.service;
import com.internal.dto.ResponseResult;
import com.internal.response.CheckCodeResponse;
import com.internal.response.NumberResponse;
import com.taxi.apipassenger.remote.ServiceVerificatoncodeClient;
import net.sf.json.JSONObject;
@ -34,7 +35,27 @@ public class VerificationCodeService {
stringRedisTemplate.opsForValue().set(key,numberCode+"",2, TimeUnit.MINUTES);
//通过短信服务商,将对应的验证码发送到手机上。阿里短信服务,腾讯短信通,容联
return ResponseResult.success();
}
/**
*
* @param passenegerPhone
* @param verificationCode
* @return
*/
public ResponseResult checkCode(String passenegerPhone,String verificationCode) {
//一、根据手机号reids-key规则查询验证码
//二、判断验证码是否正确
//三、判断这个手机号是否存在用户,并进行对应的处理
//四、颁发令牌
CheckCodeResponse checkCodeResponse = new CheckCodeResponse();
checkCodeResponse.setToken("getToken");
return ResponseResult.success(checkCodeResponse);
}
}

@ -0,0 +1,12 @@
package com.internal.response;
import lombok.Data;
import lombok.Getter;
@Data
public class CheckCodeResponse {
private String token;
}
Loading…
Cancel
Save