Skip to content

Instantly share code, notes, and snippets.

@MrMjauh
Created June 30, 2019 21:16
Show Gist options
  • Save MrMjauh/159a8e88ff6103f5116daae3bf3f5a3b to your computer and use it in GitHub Desktop.
Save MrMjauh/159a8e88ff6103f5116daae3bf3f5a3b to your computer and use it in GitHub Desktop.
Controller
@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