飞滴出行网约车2022-乘客服务通过feign调用 service-passenger-user实现 根据手机号查询用户信息

master
yh 3 years ago
parent 929caaf234
commit 54277d39af

@ -1,7 +1,9 @@
package com.mashibing.apipassenger.remote;
import com.mashibing.internalcommon.dto.PassengerUser;
import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.request.VerificationCodeDTO;
import feign.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
@ -13,4 +15,7 @@ public interface ServicePassengerUserCLient {
@RequestMapping(method = RequestMethod.POST,value = "/user")
public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO);
@RequestMapping(method = RequestMethod.GET,value = "/user/{phone}")
public ResponseResult<PassengerUser> getUserByPhone(@PathVariable("phone") String phone);
}

@ -1,17 +1,23 @@
package com.mashibing.apipassenger.service;
import com.mashibing.apipassenger.remote.ServicePassengerUserCLient;
import com.mashibing.internalcommon.constant.CommonStatusEnum;
import com.mashibing.internalcommon.dto.PassengerUser;
import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.dto.TokenResult;
import com.mashibing.internalcommon.request.VerificationCodeDTO;
import com.mashibing.internalcommon.util.JwtUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class UserService {
@Autowired
private ServicePassengerUserCLient passengerUserCLient;
public ResponseResult getUserByAccessToken(String accessToken){
log.info("accessToken = "+accessToken);
@ -23,11 +29,9 @@ public class UserService {
String phone = tokenResult.getPhone();
// 根据手机号 查询用户信息
ResponseResult<PassengerUser> userByPhone = passengerUserCLient.getUserByPhone(phone);
PassengerUser passengerUser = new PassengerUser();
return ResponseResult.success(passengerUser);
return ResponseResult.success(userByPhone.getData());
}

@ -1,14 +1,10 @@
package com.mashibing.servicepassengeruser.controller;
import com.mashibing.internalcommon.dto.PassengerUser;
import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.request.VerificationCodeDTO;
import com.mashibing.servicepassengeruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
public class UserController {
@ -23,10 +19,9 @@ public class UserController {
}
@GetMapping("/user")
public ResponseResult getUser(@RequestBody VerificationCodeDTO verificationCodeDTO) {
String passengerPhone = verificationCodeDTO.getPassengerPhone();
return service.getUsers(passengerPhone);
@GetMapping("/user/{phone}")
public ResponseResult getUser(@PathVariable("phone") String passengerPhone){
return service.getUsersByPhone(passengerPhone);
}
}

@ -42,7 +42,7 @@ public class UserService {
}
public ResponseResult getUsers(String passengerPhone) {
public ResponseResult getUsersByPhone(String passengerPhone) {
PassengerUser user = new PassengerUser();

Loading…
Cancel
Save