Skip to content

Commit

Permalink
Merge branch 'main' of github.com:kouamschekina/e2e-banking-app
Browse files Browse the repository at this point in the history
  • Loading branch information
kouamschekina committed Jun 13, 2024
2 parents e7417c3 + 91e8378 commit d610b2c
Show file tree
Hide file tree
Showing 15 changed files with 792 additions and 419 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ public CheckBalanceController(CheckBalance checkBalanceService, UserRepository u
this.userRepository = userRepository;
}

@GetMapping("/{userId}")
public ResponseEntity<String> checkBalance(@PathVariable String userId) {
Optional<User> user = userRepository.findByPhoneNumber(userId);

@GetMapping("/{phoneNumber}")
public ResponseEntity<String> checkBalance(@PathVariable String phoneNumber) {
Optional<User> 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");
}
}
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.adorsys.gis.powerpay.powerpaybackend.domain;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.*;

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Procedure {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package com.adorsys.gis.powerpay.powerpaybackend.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.*;

@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String phoneNumber;
private String pin;
private String userName;

public Long getId(){
return id;
}

public void setId(Long id){
this.id = id;
}

public String getPhoneNumber() {
return phoneNumber;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Optional;

@Repository
public interface UserRepository extends JpaRepository<User, String> {
public interface UserRepository extends JpaRepository<User, Long> {

Optional<User> findByPhoneNumber(String phoneNumber);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

//implementing an empty interface
public interface CheckBalance {
Double checkBalance(String userId) throws UsernameNotFoundException;
Double checkBalance(String phoneNumber) throws UsernameNotFoundException;
}
8 changes: 7 additions & 1 deletion power-pay-backend/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
spring:
application:
name: e2e-banking-app
profile:
active: dev,postgres

management:
endpoints:
web:
exposure:
include: health, metrics
endpoint:
health:
show-details: always
show-details: always
Loading

0 comments on commit d610b2c

Please sign in to comment.