Skip to content

johnpapwinter/acme-room-booker

Repository files navigation

Room Booker API

A Spring Boot REST API for managing meeting room bookings and user authentication.

Features

  • User authentication and authorization with JWT
  • Meeting room booking management
  • User role management
  • Search functionality for room availability

API Endpoints

Authentication

Register New User

POST /api/auth/register

Request Body:

{
  "name": "string",
  "email": "string",
  "username": "string",
  "password": "string",
  "confirmPassword": "string"
}

Response: Returns the created user ID

Login

POST /api/auth/login

Request Body:

{
  "username": "string",
  "password": "string"
}

Response:

{
  "token": "string",
  "username": "string",
  "email": "string",
  "id": "number",
  "roles": ["string"]
}

User Management

Get All Users

GET /api/user/get-all?page=0&size=10

Response: Paginated list of users with their details

Toggle User Role

GET /api/user/toggle-role/{userId}

Response: Updated user ID

Meeting Management

Get All Meetings

GET /api/meetings/get-all?page=0&size=10

Response: Paginated list of meetings

Book Meeting

POST /api/meetings/book

Request Body:

{
  "meetingRoom": "enum",
  "bookedBy": "string (email)",
  "bookingDate": "YYYY-MM-DD",
  "startTime": "HH:mm:ss",
  "endTime": "HH:mm:ss"
}

Response: Created meeting ID

Cancel Meeting

GET /api/meetings/cancel/{id}

Response: Cancelled meeting details

Search Meetings

POST /api/meetings/search?page=0&size=10

Request Body:

{
  "meetingRoom": "enum",
  "bookingDate": "YYYY-MM-DD"
}

Response: Paginated list of meetings matching the search criteria

Data Models

Meeting DTO

{
  "id": "number",
  "meetingRoom": "enum",
  "bookedBy": "string (email)",
  "bookingDate": "YYYY-MM-DD",
  "startTime": "HH:mm:ss",
  "endTime": "HH:mm:ss"
}

User DTO

{
  "name": "string",
  "email": "string",
  "username": "string",
  "role": "enum"
}

Validation

The API includes comprehensive validation for all endpoints:

  • Required field validation
  • Email format validation
  • Password matching validation for registration
  • Date and time validation for meetings

Security

  • JWT-based authentication
  • Role-based access control
  • Secure password handling
  • Protected endpoints requiring authentication

Error Handling

The API uses standardized error messages with unique error codes:

  • ARB1001: Room is required
  • ARB1002: Meeting organizer is required
  • ARB1003: Invalid email address
  • ARB1004: Date is required
  • ARB1005: Starting time is required
  • ARB1006: End time is required
  • ARB1007: Name is required
  • ARB1008: Email is required
  • ARB1009: Username is required
  • ARB1010: Password is required
  • ARB1012: Confirmation password required

Prerequisites

  • Java 17 or higher
  • Spring Boot 3.x
  • Maven/Gradle for dependency management
  • PostgreSQL/MySQL database (configure in application.properties)

Getting Started

  1. Clone the repository
  2. Configure your database connection in application.properties
  3. Run the application using Maven:
    ./mvnw spring-boot:run
  4. The API will be available at http://localhost:8080

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published