api-driver调用service-verificationcode服务代码编写

main
topsun 2 years ago
parent 3bf5fb19dd
commit 6070c0e9c6

@ -32,6 +32,10 @@
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,15 @@
package com.taxi.apidriver.remote;
import com.internal.dto.ResponseResult;
import com.internal.response.NumberResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient("service-verificationcode")
public interface ServiceVerificationcodeClient {
@RequestMapping(method = RequestMethod.GET,value = "/numberCode/{size}")
ResponseResult<NumberResponse> getVerificationCode(@PathVariable("size") int size);
}

@ -4,11 +4,15 @@ import com.internal.contant.CommonStatusEnum;
import com.internal.contant.DriverCarConstant;
import com.internal.dto.ResponseResult;
import com.internal.response.DriverUserExistsResponse;
import com.internal.response.NumberResponse;
import com.taxi.apidriver.remote.ServiceDriverUserClient;
import com.taxi.apidriver.remote.ServiceVerificationcodeClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class VerficationCodeService {
@ -16,6 +20,11 @@ public class VerficationCodeService {
@Autowired
private ServiceDriverUserClient serviceDriverUserClient;
@Autowired
private ServiceVerificationcodeClient serviceVerificationcodeClient;
@Autowired
private StringRedisTemplate stringRedisTemplate;
public ResponseResult checkSendVerficationCode(String driverPhone) {
//查询该手机号的司机是否存在
DriverUserExistsResponse data =
@ -30,11 +39,13 @@ public class VerficationCodeService {
}
}
//获取验证码
ResponseResult<NumberResponse> numberResponse = serviceVerificationcodeClient.getVerificationCode(6);
int numberCode = numberResponse.getData().getNumberCode();
log.info("验证码"+numberCode);
//调用三方,获取验证码
//存入redis
// stringRedisTemplate.opsForValue().set(key, numberCode + "", 5, TimeUnit.MINUTES);
return ResponseResult.success();
}
}

Loading…
Cancel
Save