Created
June 30, 2019 21:16
-
-
Save MrMjauh/159a8e88ff6103f5116daae3bf3f5a3b to your computer and use it in GitHub Desktop.
Controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
@RequestMapping("/user") | |
public class UserController { | |
private IUserService userService; | |
@Autowired | |
public UserController(IUserService userService) { | |
this.userService = userService; | |
} | |
@AccessAuthenticated | |
@GetMapping | |
public UserDTO getMe(@AuthenticationPrincipal AuthenticatedUser authenticatedUser) { | |
User user = this.userService.getUser(authenticatedUser.getId()); | |
if (user == null) { | |
throw new BaseException(Resource.ErrorCode.RESOURCE_NOT_FOUND, "Can not find user"); | |
} | |
return UserDTO.from(user); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment