parent
2203388b65
commit
c7e41b8d31
@ -0,0 +1,23 @@
|
|||||||
|
package com.taxi.apipassenger.controller;
|
||||||
|
|
||||||
|
import com.internal.dto.ResponseResult;
|
||||||
|
import com.taxi.apipassenger.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserController {
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@GetMapping("/usersInfo")
|
||||||
|
public ResponseResult getUserInfo(HttpServletRequest httpServletRequest){
|
||||||
|
//从http请求中获取accessToken
|
||||||
|
String authorization = httpServletRequest.getHeader("Authorization");
|
||||||
|
//根据accessToken查询
|
||||||
|
return userService.getUserInfo(authorization);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.taxi.apipassenger.service;
|
||||||
|
|
||||||
|
import com.internal.dto.PassengerUser;
|
||||||
|
import com.internal.dto.ResponseResult;
|
||||||
|
import com.internal.dto.TokenResult;
|
||||||
|
import com.internal.util.JwtUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class UserService {
|
||||||
|
|
||||||
|
public ResponseResult getUserInfo(String accessToken) {
|
||||||
|
TokenResult tokenResult = null;
|
||||||
|
PassengerUser userInfoResult = null;
|
||||||
|
try {
|
||||||
|
tokenResult = JwtUtils.checkToken(accessToken);
|
||||||
|
String passengerPhone = tokenResult.getPassengerPhone();
|
||||||
|
userInfoResult = new PassengerUser();
|
||||||
|
|
||||||
|
//根据手机号查询用户信息
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return ResponseResult.success(userInfoResult);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue