@@ -22,6 +26,17 @@ import java.util.UUID; @Service public class VerificationCodeServiceImpl implements VerificationCodeService { + /** + * redis的操作对象 + */ + @Autowired + private RedisTemplate redisTemplate; + + /** + * 用户手机验证码redis存储的前缀 + */ + private static final String PASSENGER_PHONE_VERIFICATION_CODE_PREFIX = "PASSENGER::PHONE::VERIFICATION::CODE::"; + /** * 生成一个乘客的短信验证码 * @@ -40,7 +55,8 @@ public class VerificationCodeServiceImpl implements VerificationCodeService { verificationCodeRedis.setVerificationCode(code); verificationCodeRedis.setPassengerPhone(verificationCode.getPassengerPhone()); verificationCodeRedis.setToken(token); - // TODO 将 verificationCodeRedis 存入redis + // 将 verificationCodeRedis 存入redis + this.redisTemplate.opsForValue().set(PASSENGER_PHONE_VERIFICATION_CODE_PREFIX + token, verificationCodeRedis, 5, TimeUnit.MINUTES); // 将token和code返回 PassengerVerificationCodeVO result = new PassengerVerificationCodeVO(); result.setVerificationCode(code); diff --git a/service/service-verification-code/src/main/resources/bootstrap-dev.yaml b/service/service-verification-code/src/main/resources/bootstrap-dev.yaml index c57e8ec..727027e 100644 --- a/service/service-verification-code/src/main/resources/bootstrap-dev.yaml +++ b/service/service-verification-code/src/main/resources/bootstrap-dev.yaml @@ -7,3 +7,4 @@ spring: config: server-addr: 192.168.3.231:8848 namespace: taxi-dev + file-extension: yaml