From fe4ffd4bf1138cde7db1f3ce87e3f4f9b9c9cf9e Mon Sep 17 00:00:00 2001 From: Michael Harlow <94586121+michaelharlow@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:19:10 -0600 Subject: [PATCH] frontend: Account by Id --- .../com/avengers/example/controller/AccountController.java | 6 ++++++ .../java/com/avengers/example/service/AccountService.java | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/avengers/example/controller/AccountController.java b/src/main/java/com/avengers/example/controller/AccountController.java index 19a59f3..c94f2be 100644 --- a/src/main/java/com/avengers/example/controller/AccountController.java +++ b/src/main/java/com/avengers/example/controller/AccountController.java @@ -33,4 +33,10 @@ public ResponseEntity findAll() { return new ResponseEntity<>(accountService.findAll(), HttpStatus.OK); } + + @GetMapping("/account/{id}") + public ResponseEntity findById(@PathVariable long id) + { + return new ResponseEntity<>(accountService.findById(id), HttpStatus.OK); + } } diff --git a/src/main/java/com/avengers/example/service/AccountService.java b/src/main/java/com/avengers/example/service/AccountService.java index ee93b9a..e54c76e 100644 --- a/src/main/java/com/avengers/example/service/AccountService.java +++ b/src/main/java/com/avengers/example/service/AccountService.java @@ -29,4 +29,9 @@ public Account findByEmailAndPassword(String email, String password) { return accountRepository.findByEmailAndPassword(email, password); } + + public Account findById(long id) + { + return accountRepository.findById(id).orElse(null); + } }