|
|
@ -5,31 +5,35 @@ import com.mashibing.internalcommon.dto.ResponseResult;
|
|
|
|
import com.mashibing.internalcommon.response.NumberCodeResponse;
|
|
|
|
import com.mashibing.internalcommon.response.NumberCodeResponse;
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class VerificationCodeService {
|
|
|
|
public class VerificationCodeService {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ServiceVerificationcodeClient verificationcodeClient;
|
|
|
|
private ServiceVerificationcodeClient verificationcodeClient;
|
|
|
|
|
|
|
|
|
|
|
|
public String generatorCode(String passengerPhone){
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String prefixKey = "passenger-verification-code-";
|
|
|
|
|
|
|
|
|
|
|
|
// 调用验证码服务,获取验证码
|
|
|
|
|
|
|
|
System.out.println("调用验证码服务,获取验证码");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 使用 frign 远程调用生成验证码服务接口
|
|
|
|
public ResponseResult generatorCode(String passengerPhone){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 使用 feign 远程调用生成验证码服务接口
|
|
|
|
ResponseResult<NumberCodeResponse> numberCodeResponse = verificationcodeClient.getNumberCode(6);
|
|
|
|
ResponseResult<NumberCodeResponse> numberCodeResponse = verificationcodeClient.getNumberCode(6);
|
|
|
|
String numberCode = numberCodeResponse.getData().getNumberCode();
|
|
|
|
String numberCode = numberCodeResponse.getData().getNumberCode();
|
|
|
|
System.out.println("remote number code: "+numberCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 存入redis
|
|
|
|
// 存入redis
|
|
|
|
System.out.println("存入redis");
|
|
|
|
String redisKey = prefixKey + passengerPhone;
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
redisTemplate.opsForValue().set(redisKey,numberCode,2, TimeUnit.MINUTES);
|
|
|
|
result.put("code",1);
|
|
|
|
|
|
|
|
result.put("message","success");
|
|
|
|
// 返回处理结果
|
|
|
|
// 返回值
|
|
|
|
return ResponseResult.success("");
|
|
|
|
return result.toString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|