Advertisement
dsfsaegf

Untitled

Feb 26th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. @GetMapping(value = "/users/{id}")
  2. public ResponseEntity<ErrorResponse> read(@PathVariable(name = "id") int id) {
  3. UserData userData = usersService.getUserByID(id);
  4. ErrorResponse errorResponse;
  5. if (userData == null) {
  6. errorResponse = new ErrorResponse(ErrorCodes.NOT_FOUND, "User not found!");
  7. } else {
  8. UserJsonBuilder jsonBuilder = new UserJsonBuilder(userData);
  9. jsonBuilder.addFirstName();
  10. jsonBuilder.addHasPremium();
  11. String jsonString = jsonBuilder.getJsonString();
  12. errorResponse = new ErrorResponse(ErrorCodes.OK, jsonString);
  13. }
  14. return ResponseEntity.ok(errorResponse);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement