get user by username

This commit is contained in:
2023-04-27 11:07:17 +02:00
parent a3f276fbdd
commit b91ff3c5b2
3 changed files with 16 additions and 0 deletions

View File

@@ -48,6 +48,16 @@ public class UserController {
}
}
@GetMapping("/get/username/{username}")
public ResponseEntity<User> getUserByUsername(@PathVariable("username") String username) {
User user = userService.getUserByUsernameService(username);
if (user != null) {
return new ResponseEntity<>(user, HttpStatus.OK);
} else {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
}
@PostMapping("/create/{id}")
public ResponseEntity<User> createUser(@RequestBody User user) {
User createdUser = userService.createUser(user);