|
|
|
@ -5,9 +5,13 @@ 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.service.VerificationCodeService;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
@ -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);
|
|
|
|
|