test task project
scala
sbt
- Play framework
- Play-Slick + inmemory
H2
database - macwire for dependency injection
- Play scala test
- sbt-native-packager
sbt run
starts project in development modesbt stage
stages app into/target/universal/stage/
foldersbt test
runs test
app
controllers # containg viewmodel + presentational logics
model
dao # contains database access logic
entity # domain model value-classes
service # contains business logic
module # dependency injection
util
Loader.scala # app entry point
conf
application.conf # configuration
logback.xml # logger configuration
routes # routes mapping
test
controllers
RestSpec.scala # rest tests
GET /api/account/:id
Responses with 200 if found
{
"data":
{
"id": "1",
"balance": 0,
"createdAt": 1538999758241,
"updatedAt": 1538999773671
}
}
otherwise responces with 404
GET http://localhost:9000/api/account?limit&offset
Example response:
{
"data": [
{
"id": "1",
"balance": 0,
"createdAt": 1538999758241,
"updatedAt": 1538999773671
},
{
"id": "2",
"balance": 10,
"createdAt": 1538999755462,
"updatedAt": 1538999773671
}
]
}
PUT http://localhost:9000/api/account/:id
Responses with 201 or with 200 if already created
POST http://localhost:9000/api/account/balance/add
{
"id": "1",
"amount": 10
}
Responses with 200 or with 404 if id not found
POST http://localhost:9000/api/moneytransfer
{
"idFrom": "1",
"idTo": "2",
"amount": 10
}
Responses
- 200 on success
- 404 if any of account is not found
- 400 if
From
account has insufficient money
POST http://localhost:9000/maintenance/tables
Creates tables
DELETE http://localhost:9000/maintenance/tables
Drops tables