Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Banking Application using Java8, Spring Boot, Spring Security and H2 DB
# Banking Application using Java 11, Spring Boot, Spring Security and H2 DB

RESTful API to simulate simple banking operations.

Expand All @@ -17,30 +17,58 @@ RESTful API to simulate simple banking operations.
git clone https://github.com/sbathina/BankApp

```
2. Enable Lombok support on your IDE
2. Ensure Java 11 JDK is installed

Download and install Java 11 JDK from:
```
https://adoptium.net/ (recommended)
or
https://www.oracle.com/java/technologies/downloads/#java11

```

Set the JAVA_HOME environment variable:
```
# Linux/macOS
export JAVA_HOME=/path/to/java-11-jdk
export PATH=$JAVA_HOME/bin:$PATH

# Windows
set JAVA_HOME=C:\path\to\java-11-jdk
set PATH=%JAVA_HOME%\bin;%PATH%

```

Verify Java version:
```
java -version

```

3. Enable Lombok support on your IDE

Refer to the following link for instructions:

```
https://projectlombok.org/setup/eclipse

```
3. Open IDE of your choice and Import as existing maven project in your workspace
4. Open IDE of your choice and Import as existing maven project in your workspace

```
- Import existing maven project
- Run mvn clean install
- If using STS, Run As Spring Boot App

```
4. Default port for the api is 8989
5. Default port for the api is 8989


### Prerequisites

* Java 8
* Java 11 JDK
* Spring Tool Suite 4 or similar IDE
* [Maven](https://maven.apache.org/) - Dependency Management
* [Maven](https://maven.apache.org/) 3.6+ - Dependency Management

### Maven Dependencies

Expand All @@ -52,16 +80,15 @@ spring-boot-starter-web
spring-boot-devtools
h2 - Inmemory database
lombok - to reduce boilerplate code
springfox-swagger2
springfox-swagger-ui
springdoc-openapi-ui - OpenAPI 3.0 documentation
spring-boot-starter-test
spring-security-test

```

## Swagger
## API Documentation

Please find the Rest API documentation in the below url
The application uses SpringDoc OpenAPI 3.0 for API documentation. Access the interactive API documentation at:

```
http://localhost:8989/bank-api/swagger-ui.html
Expand Down
17 changes: 6 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
<version>2.7.18</version>
<relativePath/>
</parent>
<groupId>com.coding.exercise</groupId>
<artifactId>bank-app</artifactId>
Expand All @@ -15,7 +15,7 @@
<description>Bank App Spring Boot Project</description>

<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -52,15 +52,10 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.15</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,18 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;

@Configuration
@EnableSwagger2
public class ApplicationConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.paths(PathSelectors.any())
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("BANKING APPLICATION REST API")
.description("API for Banking Application.")
.version("1.0.0").build();
public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("BANKING APPLICATION REST API")
.description("API for Banking Application.")
.version("1.0.0"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,62 +17,32 @@
import com.coding.exercise.bankapp.domain.TransferDetails;
import com.coding.exercise.bankapp.service.BankingServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@RestController
@RequestMapping("accounts")
@Api(tags = { "Accounts and Transactions REST endpoints" })
public class AccountController {

@Autowired
private BankingServiceImpl bankingService;

@GetMapping(path = "/{accountNumber}")
@ApiOperation(value = "Get account details", notes = "Find account details by account number")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> getByAccountNumber(@PathVariable Long accountNumber) {

return bankingService.findByAccountNumber(accountNumber);
}

@PostMapping(path = "/add/{customerNumber}")
@ApiOperation(value = "Add a new account", notes = "Create an new account for existing customer.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> addNewAccount(@RequestBody AccountInformation accountInformation,
@PathVariable Long customerNumber) {

return bankingService.addNewAccount(accountInformation, customerNumber);
}

@PutMapping(path = "/transfer/{customerNumber}")
@ApiOperation(value = "Transfer funds between accounts", notes = "Transfer funds between accounts.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> transferDetails(@RequestBody TransferDetails transferDetails,
@PathVariable Long customerNumber) {

return bankingService.transferDetails(transferDetails, customerNumber);
}

@GetMapping(path = "/transactions/{accountNumber}")
@ApiOperation(value = "Get all transactions", notes = "Get all Transactions by account number")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public List<TransactionDetails> getTransactionByAccountNumber(@PathVariable Long accountNumber) {

return bankingService.findTransactionsByAccountNumber(accountNumber);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,36 @@
import com.coding.exercise.bankapp.domain.CustomerDetails;
import com.coding.exercise.bankapp.service.BankingServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@RestController
@RequestMapping("customers")
@Api(tags = { "Customer REST endpoints" })
public class CustomerController {

@Autowired
private BankingServiceImpl bankingService;

@GetMapping(path = "/all")
@ApiOperation(value = "Find all customers", notes = "Gets details of all the customers")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public List<CustomerDetails> getAllCustomers() {

return bankingService.findAll();
}

@PostMapping(path = "/add")
@ApiOperation(value = "Add a Customer", notes = "Add customer and create an account")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> addCustomer(@RequestBody CustomerDetails customer) {

return bankingService.addCustomer(customer);
}

@GetMapping(path = "/{customerNumber}")
@ApiOperation(value = "Get customer details", notes = "Get Customer details by customer number.")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Success", response = CustomerDetails.class, responseContainer = "Object"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public CustomerDetails getCustomer(@PathVariable Long customerNumber) {

return bankingService.findByCustomerNumber(customerNumber);
}

@PutMapping(path = "/{customerNumber}")
@ApiOperation(value = "Update customer", notes = "Update customer and any other account information associated with him.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> updateCustomer(@RequestBody CustomerDetails customerDetails,
@PathVariable Long customerNumber) {

return bankingService.updateCustomer(customerDetails, customerNumber);
}

@DeleteMapping(path = "/{customerNumber}")
@ApiOperation(value = "Delete customer and related accounts", notes = "Delete customer and all accounts associated with him.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Object.class),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 500, message = "Internal Server Error") })

public ResponseEntity<Object> deleteCustomer(@PathVariable Long customerNumber) {

return bankingService.deleteCustomer(customerNumber);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.coding.exercise.bankapp;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class BankingApplicationTests {

Expand Down