获取redis中验证码。

master
liuyuanqiang 2 years ago
parent f195c94d90
commit e20bc551f0

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.sql.SQLOutput;
import java.util.concurrent.TimeUnit;
@Service
@ -34,7 +35,7 @@ public class VerificationCodeService {
//存入redis
System.out.println("存入redis");
String key = verificationCodePrefix + numberCode;
String key = this.generateKeyByCode(passengerPhone);
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
@ -51,6 +55,9 @@ public class VerificationCodeService {
*/
public ResponseResult checkCode(String passengerPhone, String verificationCode) {
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("校验验证码");

Loading…
Cancel
Save