Created
March 14, 2024 23:48
-
-
Save jeanpierregomez/3a2007b99bc9a0afaf195ddbc5f6ed9a to your computer and use it in GitHub Desktop.
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(value = "/user", produces = MediaType.APPLICATION_JSON_VALUE) | |
@AllArgsConstructor | |
public class ApiRest { | |
private final UserUseCase userUseCase; | |
@GetMapping(path = "/{id}") | |
public ResponseEntity<User> getUser(@PathVariable("id") String id) { | |
return ResponseEntity.ok(userUseCase.getUser(id)); | |
} | |
@PostMapping(path = "/") | |
public ResponseEntity<User> saveUser(@RequestBody User user) { | |
return ResponseEntity.ok(userUseCase.saveUser(user)); | |
} | |
@DeleteMapping(path = "/{id}") | |
public ResponseEntity<String> deleteUser(@PathVariable("id") String id) { | |
userUseCase.deleteUser(id); | |
return ResponseEntity.ok("Usuario eliminado exitosamente"); | |
} | |
@PutMapping(path = "/") | |
public ResponseEntity<User> updateUser(@RequestBody User user) { | |
return ResponseEntity.ok(userUseCase.updateUser(user)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment