Skip to content

Instantly share code, notes, and snippets.

@jeanpierregomez
Created March 14, 2024 23:48
Show Gist options
  • Save jeanpierregomez/3a2007b99bc9a0afaf195ddbc5f6ed9a to your computer and use it in GitHub Desktop.
Save jeanpierregomez/3a2007b99bc9a0afaf195ddbc5f6ed9a to your computer and use it in GitHub Desktop.
@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