/Prenotazioni

Progetto Java utilizzando framework Spring e Rest API

Primary LanguageJava

# 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
  1. Navigate to the project directory:

    cd room-operation-management
  2. Build the project using Maven:

    mvn clean install
  3. Run the application:

    mvn spring-boot:run

Endpoints

Room Endpoints

  • 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}

Operation Endpoints

  • 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}

Booking Endpoints

  • 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}

Data Model

Room (Stanza)

  • id (Long): Unique identifier for the room
  • type (Enum): Type of the room (e.g., single, double, suite)
  • number (String): Room number
  • price (Float): Room capacity

Prenotazione (Prenotazione)

  • id (Long): Unique identifier for the operation
  • dateIn (LocalDate): Date check in (yyyy-MM-dd)
  • dateOut (LocalDate): Date check out (yyyy-MM-dd)
  • room (Room): ID of the associated room

Running Tests

To run tests, use the following command:

mvn test

License

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.