This is a small test project to create apis for classes and bookings using Java SpringBoot
Classes and Bookings
Either of these two are needed to run these services.
- Docker
- MySql server (if using mysql the settings are needed to be updated in the application properties)
The installation steps are very simple.
- First we need to package the project if it is not already packged i.e. the target folder has the BookingAPI Jar file
$ mvn package -DskipTests
This step should create target -> BookingAPI-0.0.1-SNAPSHOT.jar
- Second we need to build the docker compose
$ docker-compose up --build -d
This step should create two containers:
The successful deployment on docker should allow the access of the swagger view which is used to document the apis Swagger should be accessible here click here
If docker is not available, project can be opened with IntelliJ IDEA and run from there or Jar file can be used to run directly from the terminal.
- First step here will be to set the settings for mysql server in application.properties src->main->resources->application.properties
It will also be needed to create database in mysql server called bookingdata (no need to create tables, they are automatically created on startup)
- After setting the database we need to package the project
$ mvn package
- Next we can run the jar created in the target folder
$ nohup java -jar /BookingAPI-0.0.1-SNAPSHOT.jar &
The successful deployment should allow the access of the swagger view which is used to document the apis Swagger should be accessible here click here
There are also two junit tests in the src->test to test the apis, they were created while development of the apis.
- POST /classes
Here it is important to not pass any id
or 400
error will occur
{
"capacity": 10,
"endDate": "2021-09-18T14:23:21.540Z",
"name": "pilates",
"startDate": "2021-09-10T14:23:21.540Z"
}
- POST /bookings
As booking is linked with classes it is important to pass the id
of class
{
"classDate": "2021-09-15T14:36:31.476Z",
"gclass": {
"id": 1
},
"memberName": "aniqa"
}