|
|
@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.SQLOutput;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
@ -34,7 +35,7 @@ public class VerificationCodeService {
|
|
|
|
|
|
|
|
|
|
|
|
//存入redis
|
|
|
|
//存入redis
|
|
|
|
System.out.println("存入redis");
|
|
|
|
System.out.println("存入redis");
|
|
|
|
String key = verificationCodePrefix + numberCode;
|
|
|
|
String key = this.generateKeyByCode(passengerPhone);
|
|
|
|
stringRedisTemplate.opsForValue().set(key, "" + numberCode,2, TimeUnit.MINUTES);
|
|
|
|
stringRedisTemplate.opsForValue().set(key, "" + numberCode,2, TimeUnit.MINUTES);
|
|
|
|
|
|
|
|
|
|
|
|
//发送短信。。。
|
|
|
|
//发送短信。。。
|
|
|
@ -43,6 +44,9 @@ public class VerificationCodeService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String generateKeyByCode(String passengerPhone){
|
|
|
|
|
|
|
|
return this.verificationCodePrefix + passengerPhone;
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 校验验证码
|
|
|
|
* 校验验证码
|
|
|
|
* @param passengerPhone
|
|
|
|
* @param passengerPhone
|
|
|
@ -51,6 +55,9 @@ public class VerificationCodeService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public ResponseResult checkCode(String passengerPhone, String verificationCode) {
|
|
|
|
public ResponseResult checkCode(String passengerPhone, String verificationCode) {
|
|
|
|
System.out.println("根据手机号和验证码,查询redis");
|
|
|
|
System.out.println("根据手机号和验证码,查询redis");
|
|
|
|
|
|
|
|
String key = this.generateKeyByCode(passengerPhone);
|
|
|
|
|
|
|
|
String codeRedis = stringRedisTemplate.opsForValue().get(key);
|
|
|
|
|
|
|
|
System.out.println("code in redis:" + codeRedis);
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("校验验证码");
|
|
|
|
System.out.println("校验验证码");
|
|
|
|
|
|
|
|
|
|
|
|