This Hotel Application is built as an backend API using Java Spring Boot application lets you perform the following operations:
- Add Hotel
- Get all Hotels
Following is a description of each of the above operations and how to perform them.
This is the first step to perform before using the application. The username and password are used for all the subsequesnt requests for authentication.
API Endpoint
POST /hotel
Body
{
"name":"Hotel Marina",
"address":{
"line1":"23 Marina Way",
"city":"Richmond",
"state":"CA",
"country":"USA",
"zip":"94804",
"type":"HOTEL"
},
"rooms":[{"type":"SINGLE", "status":"AVAILABLE"},
{"type":"SINGLE", "status":"AVAILABLE"},
{"type":"SINGLE", "status":"AVAILABLE"},
{"type":"SINGLE", "status":"AVAILABLE"},
{"type":"DOUBLE", "status":"AVAILABLE"},
{"type":"DOUBLE", "status":"AVAILABLE"},
{"type":"SUITE", "status":"AVAILABLE"}]
}
Response
Hotel added : Hotel Marina:2
This call returns the following details of a single hotel:
- id
- adddress
- count of different types of rooms in the hotel
API Endpoint
GET /hotel/<id>
Response
{
"id": 2,
"name": "Hotel Marina",
"address": {
"id": 1,
"line1": "23 Marina Way",
"line2": null,
"city": "Richmond",
"state": "CA",
"country": "USA",
"zip": 94804,
"type": "HOTEL"
},
"roomCounts": {
"DOUBLE": 2,
"SINGLE": 4,
"SUITE": 1
}
}
This call returns a list of all the Hotels and its properties like Address and Room details
API Endpoint
GET /hotel/all
Response
[
{
"id": 1,
"name": "Grand Bay New",
"address": null,
"roomCounts": {
"DOUBLE": 1,
"SINGLE": 1,
"SUITE": 1
}
},
{
"id": 2,
"name": "Hotel Marina",
"address": {
"id": 1,
"line1": "23 Marina Way",
"line2": null,
"city": "Richmond",
"state": "CA",
"country": "USA",
"zip": 94804,
"type": "HOTEL"
},
"roomCounts": {
"DOUBLE": 2,
"SINGLE": 4,
"SUITE": 1
}
}
]
-
For downloading and running the code, you should have the following installed on your system:
- Java8 and above
- Git or Gitbash
- Maven
- Docker
- SQL
- Liquibase
-
Checkout code from repository :
git clone https://github.com/choudhury-abhishek29/<>
-
This will create a directory
hotel
. -
Go inside the directory
hotel
and checkout themaster
branch.cd hotel git checkout master
-
To setup the database,navigate to the following directory :
hotel/src/main/resources/db/changelog
-
Run
liquibase update --username <username>
-
This should successfully create the following tables:
- hotel
- room
- address
- booking
- customer
- reservation