# Room and Operation Management REST API
This project is a RESTful API built with Java and Spring Boot for managing rooms and operations. It supports CRUD operations for both entities, checks room availability based on date and type, and handles room bookings and cancellations.
## Features
- CRUD operations for rooms (Stanza)
- CRUD operations for operations (Operazione)
- Check available rooms based on check-in and check-out dates and room type
- Book a room
- Cancel a booking and unlink the associated room
## Prerequisites
- Java 11 or later
- Maven
- Spring Boot
- H2 Database (or another database of your choice)
## Installation
1. Clone the repository:
```bash
git clone https://github.com/your-username/room-operation-management.git
-
Navigate to the project directory:
cd room-operation-management
-
Build the project using Maven:
mvn clean install
-
Run the application:
mvn spring-boot:run
-
Create a Room
POST /rooms
Request Body:
{ "type": "string", "number": "int", "capacity": "int" }
-
Get All Rooms
GET /rooms
-
Get a Room by ID
GET /rooms/{id}
-
Update a Room
PUT /rooms/{id}
Request Body:
{ "type": "string", "number": "int", "capacity": "int" }
-
Delete a Room
DELETE /rooms/{id}
-
Create an Operation
POST /operations
Request Body:
{ "description": "string", "date": "string (yyyy-MM-dd)", "roomId": "int" }
-
Get All Operations
GET /operations
-
Get an Operation by ID
GET /operations/{id}
-
Update an Operation
PUT /operations/{id}
Request Body:
{ "description": "string", "date": "string (yyyy-MM-dd)", "roomNumber": "String" }
-
Delete an Operation
DELETE /operations/{id}
-
Check Available Rooms
GET /rooms/available
Query Parameters:
checkIn
: string (yyyy-MM-dd)checkOut
: string (yyyy-MM-dd)type
: string
-
Book a Room
POST /bookings
Request Body:
{ "roomNumber": "int", "checkIn": "string (yyyy-MM-dd)", "checkOut": "string (yyyy-MM-dd)" }
-
Cancel a Booking
DELETE /bookings/{id}
id
(Long): Unique identifier for the roomtype
(Enum): Type of the room (e.g., single, double, suite)number
(String): Room numberprice
(Float): Room capacity
id
(Long): Unique identifier for the operationdateIn
(LocalDate): Date check in (yyyy-MM-dd)dateOut
(LocalDate): Date check out (yyyy-MM-dd)room
(Room): ID of the associated room
To run tests, use the following command:
mvn test
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to copy and paste this into your project's README.md file on GitHub.