- Pull code from this repository to your local.
- Change directory to acmebank
- On MacOS/Linux
./mvnw package
Or On Windows.\mvnw.cmd package
- On MacOS/Linux
./mvnw spring-boot:run
Or On Windows.\mvnw.cmd spring-boot:run
Or
- Import this project to IntelliJ
- Right click src/main/java/com/acmebank/accountsServices/AccountsApplication to show menu.
- click Run 'AccountsApplic...'
Request body of POST http://localhost:8080/accounts/transfer
{
"fromAccountId": 88888888,
"toAccountId": 12345678,
"amount": 100
}
- Assumed authorization has been done on gateway level.
- Assumed this service is a microservice to operate accounts belong to same user.
- Assumed low latency is not critical to this service, use database lock to entity for money transfer.
- In this project, I implemented the 'get the balance of my account' feature first. I have three reasons:
- As required to have initial balance of 1,000,000 HKD in accounts, I could establish H2 database in this project first.
- After database established, I need to think about the entity model of required which helps to build all the building blocks I need in this project.
- I chose to use Spring Data with H2 which simplify this implementation after I defined all the entities.
- Cannot use
account-manager
in package name, I usedaccount_manager
instead. - If you want to keep the data in H2 database, please set spring.sql.init.mode=never before second startup; If not, please delete acmebank.mv.db after the startup.