diff --git a/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/repository/UserRepository.java b/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/repository/UserRepository.java index f225aa7..0ae9b4a 100644 --- a/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/repository/UserRepository.java +++ b/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/repository/UserRepository.java @@ -8,5 +8,6 @@ @Repository public interface UserRepository extends JpaRepository { + Optional findByPhoneNumber(String phoneNumber); } diff --git a/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalance.java b/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalance.java index 8aa5e34..91bc0bf 100644 --- a/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalance.java +++ b/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalance.java @@ -4,5 +4,5 @@ //implementing an empty interface public interface CheckBalance { - Double checkBalance(String userId) throws UsernameNotFoundException; + Double checkBalance(String phoneNumber) throws UsernameNotFoundException; } \ No newline at end of file diff --git a/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalanceController.java b/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalanceController.java index 8e877ee..6fff0e9 100644 --- a/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalanceController.java +++ b/power-pay-backend/src/main/java/com/adorsys/gis/powerpay/powerpaybackend/services/CheckBalanceController.java @@ -25,14 +25,17 @@ public CheckBalanceController(CheckBalance checkBalanceService, UserRepository u this.userRepository = userRepository; } - @GetMapping("/{userId}") - public ResponseEntity checkBalance(@PathVariable String userId) { - Optional user = userRepository.findByPhoneNumber(userId); + + @GetMapping("/{phoneNumber}") + public ResponseEntity checkBalance(@PathVariable String phoneNumber) { + Optional user = userRepository.findByPhoneNumber(phoneNumber); if (user.isPresent()) { - Double balance = checkBalanceService.checkBalance(userId); - return ResponseEntity.ok("Balance for user ID" + " : " + balance); + Double balance = checkBalanceService.checkBalance(phoneNumber); + return ResponseEntity.ok("Balance for user phoneNumber" + " : " + balance); + } else { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("User not found"); } } } +