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

master
yh 3 years ago
parent 929caaf234
commit 54277d39af

@ -1,7 +1,9 @@
package com.mashibing.apipassenger.remote; package com.mashibing.apipassenger.remote;
import com.mashibing.internalcommon.dto.PassengerUser;
import com.mashibing.internalcommon.dto.ResponseResult; import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.request.VerificationCodeDTO; import com.mashibing.internalcommon.request.VerificationCodeDTO;
import feign.Param;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -13,4 +15,7 @@ public interface ServicePassengerUserCLient {
@RequestMapping(method = RequestMethod.POST,value = "/user") @RequestMapping(method = RequestMethod.POST,value = "/user")
public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO); 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; package com.mashibing.apipassenger.service;
import com.mashibing.apipassenger.remote.ServicePassengerUserCLient;
import com.mashibing.internalcommon.constant.CommonStatusEnum; import com.mashibing.internalcommon.constant.CommonStatusEnum;
import com.mashibing.internalcommon.dto.PassengerUser; import com.mashibing.internalcommon.dto.PassengerUser;
import com.mashibing.internalcommon.dto.ResponseResult; import com.mashibing.internalcommon.dto.ResponseResult;
import com.mashibing.internalcommon.dto.TokenResult; import com.mashibing.internalcommon.dto.TokenResult;
import com.mashibing.internalcommon.request.VerificationCodeDTO;
import com.mashibing.internalcommon.util.JwtUtils; import com.mashibing.internalcommon.util.JwtUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class UserService { public class UserService {
@Autowired
private ServicePassengerUserCLient passengerUserCLient;
public ResponseResult getUserByAccessToken(String accessToken){ public ResponseResult getUserByAccessToken(String accessToken){
log.info("accessToken = "+accessToken); log.info("accessToken = "+accessToken);
@ -23,11 +29,9 @@ public class UserService {
String phone = tokenResult.getPhone(); String phone = tokenResult.getPhone();
// 根据手机号 查询用户信息 // 根据手机号 查询用户信息
ResponseResult<PassengerUser> userByPhone = passengerUserCLient.getUserByPhone(phone);
PassengerUser passengerUser = new PassengerUser(); return ResponseResult.success(userByPhone.getData());
return ResponseResult.success(passengerUser);
} }

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

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

Loading…
Cancel
Save