From c6d9fc07e469db108a93b466136e2041ccc645c4 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 12 Jul 2020 14:57:52 +0200 Subject: [PATCH] WIP --- .../java/de/juplo/boot/data/jdbc/UserController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/de/juplo/boot/data/jdbc/UserController.java b/src/main/java/de/juplo/boot/data/jdbc/UserController.java index 1ff11d8..513ec5a 100644 --- a/src/main/java/de/juplo/boot/data/jdbc/UserController.java +++ b/src/main/java/de/juplo/boot/data/jdbc/UserController.java @@ -52,6 +52,18 @@ public class UserController { return ResponseEntity.ok(user); } + @DeleteMapping("{username}") + public ResponseEntity removeUser(@PathVariable String username) { + User user = repository.findByUsername(UserController.sanitize(username)); + + if (user == null) + return ResponseEntity.notFound().build(); + + repository.delete(user); + + return ResponseEntity.ok(user); + } + @GetMapping() public ResponseEntity> getUsers() { return ResponseEntity.ok(repository.findAll()); -- 2.20.1