|
|
|
@ -3,21 +3,17 @@ package com.taxi.apipassenger.service;
|
|
|
|
|
import com.internal.contant.CommonStatusEnum;
|
|
|
|
|
import com.internal.contant.IdentityConstant;
|
|
|
|
|
import com.internal.dto.ResponseResult;
|
|
|
|
|
import com.internal.dto.TokenResult;
|
|
|
|
|
import com.internal.request.VerificationCodeDTO;
|
|
|
|
|
import com.internal.response.CheckCodeResponse;
|
|
|
|
|
import com.internal.response.NumberResponse;
|
|
|
|
|
import com.internal.util.JwtUtils;
|
|
|
|
|
import com.internal.util.Utils;
|
|
|
|
|
import com.internal.util.RedisPrefixUtils;
|
|
|
|
|
import com.taxi.apipassenger.remote.ServicePassengerUserClient;
|
|
|
|
|
import com.taxi.apipassenger.remote.ServiceVerificatoncodeClient;
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Indexed;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.lang.invoke.ConstantCallSite;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -40,7 +36,7 @@ public class VerificationCodeService {
|
|
|
|
|
int numberCode = responseResult.getData().getNumberCode();
|
|
|
|
|
System.out.println("访问service-verificationcode服务,获取验证码:" + numberCode);
|
|
|
|
|
//key,value,过期时间
|
|
|
|
|
String key = Utils.getVerificationCodePrefixKey(passenegerPhone);
|
|
|
|
|
String key = RedisPrefixUtils.getVerificationCodePrefixKey(passenegerPhone);
|
|
|
|
|
//存入redis
|
|
|
|
|
stringRedisTemplate.opsForValue().set(key, numberCode + "", 2, TimeUnit.MINUTES);
|
|
|
|
|
|
|
|
|
@ -56,7 +52,7 @@ public class VerificationCodeService {
|
|
|
|
|
*/
|
|
|
|
|
public ResponseResult checkCode(String passenegerPhone, String verificationCode) {
|
|
|
|
|
//一、根据手机号,reids-key规则,查询验证码
|
|
|
|
|
String key = Utils.getVerificationCodePrefixKey(passenegerPhone);
|
|
|
|
|
String key = RedisPrefixUtils.getVerificationCodePrefixKey(passenegerPhone);
|
|
|
|
|
String codeRedis = stringRedisTemplate.opsForValue().get(key);
|
|
|
|
|
System.out.println("redis中的code:" + codeRedis);
|
|
|
|
|
|
|
|
|
@ -76,7 +72,7 @@ public class VerificationCodeService {
|
|
|
|
|
IdentityConstant.PASSENGER_IDENTITY);
|
|
|
|
|
|
|
|
|
|
//将token存入redis
|
|
|
|
|
String tokenKey = Utils.getTokenPrefixKey(passenegerPhone,
|
|
|
|
|
String tokenKey = RedisPrefixUtils.getTokenPrefixKey(passenegerPhone,
|
|
|
|
|
IdentityConstant.PASSENGER_IDENTITY);
|
|
|
|
|
stringRedisTemplate.opsForValue().set(tokenKey,token,30,TimeUnit.DAYS);
|
|
|
|
|
|
|
|
|
|