Give database name as hotels in MySQL
- Hotel:
- id - Primary Key.
- name - Hotel name.
- city - City of hotels.
- date(YYYY-MM-DD) - To search according to date.
- rooms(Int) - Room count default 0.
- stars(float) - Rating from 0 to 10
- availability(Y/N) - Y: yes, N:no. Default: Y
- wifi(Y/N) - Y: yes, N:no. Default: N
- restaurant(Y/N) - Y: yes, N:no. Default: N
- airConditioning(Y/N) - Y: yes, N:no. Default: N
- meals(Y/N) - Y: yes, N:no. Default: N
- Comment
- id - Primary Key.
- stars(float) - Rating from 0 to 10.
- comment - Comment by user
- hotel_id - Id of hotel on which commented.
- user_id - Id of user who commented.
- Users
- id - Primary Key.
- userName - Name of the user
- emailId - Users emailId.
- Post: api/v1/hotel
{
"name" : "Marriott International",
"city" : "Pune",
"date" : "2021-05-31",
"rooms": "10",
"availability":"Y",
"wifi": "Y",
"restaurant" : "Y",
"airConditioning" : "N",
"meals" : "Y"
}
-
DELETE : api/v1/hotel?id=1
If hotel with id 1 present the hotel gets deleted else an ERROR is thrown.
-
PUT : api/v1/hotel?id=1
If hotel with id 1 present the hotel gets updated else an ERROR is thrown.
{
"id" : "1",
"name" : "Marriott International",
"city" : "Banglore",
"date" : "2021-05-31",
"rooms": "10",
"availability":"Y",
"wifi": "Y",
"restaurant" : "Y",
"airConditioning" : "N",
"meals" : "Y"
}
- GET - api/v1/hotel
Returns all hotel list with comments and users who commented if present.
{
"id": 1,
"name": "Marriott International",
"city": "Pune",
"date": "2021-05-31",
"rooms": 10,
"stars": 9.0,
"availability": "Y",
"wifi": "Y",
"restaurant": "Y",
"airConditioning": "N",
"meals": "Y",
"comment":[
{
"id": 1,
"stars": 9.0,
"comment": "Hotel's food was very good. And staff was also very friendly.",
"users":{
"id": 1,
"userName": "XYZ",
"email": "xyz@gmail.com",
"createdAt": "2021-05-31T20:35:56.000+00:00"
}
}
]
}
Returns list of hotel based on the attributes passed in search Comparators used are :- case ':' return EQUALITY; case '!': return NEGATION; case '>': return GREATER_THAN; case '<': return LESS_THAN; case '~': return LIKE
{
"id": 1,
"name": "Marriott International",
"city": "Pune",
"date": "2021-05-31",
"rooms": 10,
"stars": 9.0,
"availability": "Y",
"wifi": "Y",
"restaurant": "Y",
"airConditioning": "N",
"meals": "Y",
"comment":[
{
"id": 1,
"stars": 9.0,
"comment": "Hotel's food was very good. And staff was also very friendly.",
"users":{
"id": 1,
"userName": "XYZ",
"email": "xyz@gmail.com",
"createdAt": "2021-05-31T20:35:56.000+00:00"
}
}
]
}
- Post: api/v1/comment
If hotel with hotelId 1 and user with userId 1 is present then only comment is saved. And the hotels rating is saved.
{
"stars": "9",
"comment": "Hotel's food was very good. And staff was also very friendly.",
"hotelId" : "1",
"userId":"1"
}
-
DELETE : api/v1/comment?id=1
If comment with id 1 present the comment gets deleted else an ERROR is thrown.
-
PUT : api/v1/hotel?id=1 If comment with id 1,hotel with hotelId 1 and user with userId 1 is present then only comment is saved. And the hotels rating is saved
{
"id" : "1",
"stars": "9",
"comment": "Hotel's food was very good. Staff was also very friendly. Rooms were also clean.",
"hotelId" : "1",
"userId":"1"
}
- GET - api/v1/comment
Returns all comment list with users who commented if present.
{
{
"id": 1,
"stars": 9.0,
"comment": "Hotel's food was very good. Staff was also very friendly.Rooms were also clean.",
"users":{
"id": 1,
"userName": "XYZ",
"email": "xyz@gmail.com",
"createdAt": "2021-05-31T20:35:56.000+00:00"
}
- Post: api/v1/user
{
"userName": "XYZ",
"email": "xyz@gmail.com"
}
-
DELETE : api/v1/user?id=1
If user with id 1 present the user gets deleted else an ERROR is thrown.
-
PUT : api/v1/hotel?id=1
If user with id 1 present the user gets updated else an ERROR is thrown.
{
"id":"1",
"userName": "ABC",
"email": "abc@gmail.com"
}
- GET - api/v1/user
Returns all users list if present.
{
"id": 1,
"userName": "XYZ",
"email": "xyz@gmail.com",
"createdAt": "2021-05-31T17:10:01.000+00:00"
},
For further details use Swagger UI at:http://localhost:8080/swagger-ui.html