room reservation added
This commit is contained in:
+97
@@ -308,5 +308,102 @@ Retrieves and displays a previously uploaded image.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Room Reservations
|
||||||
|
|
||||||
|
### Get All Rooms
|
||||||
|
Retrieves a list of all available rooms.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/rooms`
|
||||||
|
- **Method:** `GET`
|
||||||
|
- **Response:** Array of room objects.
|
||||||
|
|
||||||
|
### Create Room
|
||||||
|
Creates a new room.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/rooms`
|
||||||
|
- **Method:** `POST`
|
||||||
|
- **Authentication:** Required (Admin)
|
||||||
|
- **Body:**
|
||||||
|
- `name` (string, required): The name of the room.
|
||||||
|
- `capacity` (number, required): The capacity of the room.
|
||||||
|
- `description` (string, optional): A description of the room.
|
||||||
|
- **Response:** Created room object.
|
||||||
|
|
||||||
|
### Update Room
|
||||||
|
Updates an existing room.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/rooms`
|
||||||
|
- **Method:** `PUT`
|
||||||
|
- **Authentication:** Required (Admin)
|
||||||
|
- **Body:**
|
||||||
|
- `id` (number, required): The ID of the room to update.
|
||||||
|
- `name` (string, optional): The new name.
|
||||||
|
- `capacity` (number, optional): The new capacity.
|
||||||
|
- `description` (string, optional): The new description.
|
||||||
|
- **Response:** Updated room object.
|
||||||
|
|
||||||
|
### Delete Room
|
||||||
|
Deletes a room.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/rooms`
|
||||||
|
- **Method:** `DELETE`
|
||||||
|
- **Authentication:** Required (Admin)
|
||||||
|
- **Body:**
|
||||||
|
- `id` (number, required): The ID of the room to delete.
|
||||||
|
- **Response:** `{"message": "Room deleted"}`
|
||||||
|
|
||||||
|
### Get All Reservations
|
||||||
|
Retrieves a list of all room reservations, preloading room details.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/reservations`
|
||||||
|
- **Method:** `GET`
|
||||||
|
- **Response:** Array of reservation objects.
|
||||||
|
|
||||||
|
### Create Reservation
|
||||||
|
Creates a new room reservation.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/reservations`
|
||||||
|
- **Method:** `POST`
|
||||||
|
- **Authentication:** Required (Admin)
|
||||||
|
- **Body:**
|
||||||
|
- `roomId` (number, required): The ID of the room.
|
||||||
|
- `customerName` (string, required): The name of the customer.
|
||||||
|
- `customerPhone` (string, required): The phone number of the customer.
|
||||||
|
- `guestsCount` (number, required): Number of guests.
|
||||||
|
- `startsAt` (string, required): Start time (ISO 8601).
|
||||||
|
- `endsAt` (string, required): End time (ISO 8601).
|
||||||
|
- `notes` (string, optional): Additional notes.
|
||||||
|
- **Response:** Created reservation object.
|
||||||
|
|
||||||
|
### Update Reservation
|
||||||
|
Updates an existing reservation.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/reservations`
|
||||||
|
- **Method:** `PUT`
|
||||||
|
- **Authentication:** Required (Admin)
|
||||||
|
- **Body:**
|
||||||
|
- `id` (number, required): The ID of the reservation to update.
|
||||||
|
- `roomId` (number, optional): The new room ID.
|
||||||
|
- `customerName` (string, optional): The new customer name.
|
||||||
|
- `customerPhone` (string, optional): The new customer phone.
|
||||||
|
- `guestsCount` (number, optional): The new guests count.
|
||||||
|
- `startsAt` (string, optional): The new start time.
|
||||||
|
- `endsAt` (string, optional): The new end time.
|
||||||
|
- `status` (string, optional): The new status ('confirmed' or 'cancelled').
|
||||||
|
- `notes` (string, optional): New notes.
|
||||||
|
- **Response:** Updated reservation object.
|
||||||
|
|
||||||
|
### Delete Reservation
|
||||||
|
Deletes a reservation.
|
||||||
|
|
||||||
|
- **URL:** `/api/room-reservations/reservations`
|
||||||
|
- **Method:** `DELETE`
|
||||||
|
- **Authentication:** Required (Admin)
|
||||||
|
- **Body:**
|
||||||
|
- `id` (number, required): The ID of the reservation to delete.
|
||||||
|
- **Response:** `{"message": "Reservation deleted"}`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Rate Limiting
|
## Rate Limiting
|
||||||
Some endpoints (like login, registration, and deletion) are protected by rate limiting to prevent abuse. If you receive a `429 Too Many Requests` response, please wait before trying again.
|
Some endpoints (like login, registration, and deletion) are protected by rate limiting to prevent abuse. If you receive a `429 Too Many Requests` response, please wait before trying again.
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ export default class CategoriesController {
|
|||||||
* @returns An array of all categories.
|
* @returns An array of all categories.
|
||||||
*/
|
*/
|
||||||
async getAll() {
|
async getAll() {
|
||||||
const categories = await Category.all()
|
return await Category.all()
|
||||||
return categories
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,8 +22,7 @@ export default class CategoriesController {
|
|||||||
async getOne({ request }: HttpContext) {
|
async getOne({ request }: HttpContext) {
|
||||||
try {
|
try {
|
||||||
const id = request.body().id
|
const id = request.body().id
|
||||||
const category = await Category.find(id)
|
return await Category.find(id)
|
||||||
return category
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Category retrieval failed: %s', error)
|
logger.error('Category retrieval failed: %s', error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ export default class UsersController {
|
|||||||
* @returns An array of all users.
|
* @returns An array of all users.
|
||||||
*/
|
*/
|
||||||
async getAll() {
|
async getAll() {
|
||||||
const users = await User.all()
|
return await User.all()
|
||||||
return users
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a single user.
|
* Retrieve a single user.
|
||||||
*
|
*
|
||||||
* @param request - The HTTP context containing the request data.
|
* @param request - The HTTP context containing the request data.
|
||||||
|
* @param response - The HTTP context's response object.
|
||||||
* @returns The user with the specified id.
|
* @returns The user with the specified id.
|
||||||
*/
|
*/
|
||||||
async getOne({ request, response }: HttpContext) {
|
async getOne({ request, response }: HttpContext) {
|
||||||
|
|||||||
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
import { defineConfig, services } from '@adonisjs/ally'
|
import { defineConfig } from '@adonisjs/ally'
|
||||||
import type { InferSocialProviders } from '@adonisjs/ally/types'
|
import type { InferSocialProviders } from '@adonisjs/ally/types'
|
||||||
import env from '#start/env'
|
|
||||||
|
|
||||||
const allyConfig = defineConfig({})
|
const allyConfig = defineConfig({})
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,15 @@ export default class extends BaseSeeder {
|
|||||||
async run() {
|
async run() {
|
||||||
await User.create({
|
await User.create({
|
||||||
email: 'kiss.david@test.hu',
|
email: 'kiss.david@test.hu',
|
||||||
password: 'Palacsinta1.',
|
password: 'Password123',
|
||||||
fullName: 'Kiss Dávid',
|
fullName: 'Kiss Dávid',
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
})
|
})
|
||||||
|
await User.create({
|
||||||
|
email: 'admin@paprikaetterem.net',
|
||||||
|
password: '1Sziwem1',
|
||||||
|
fullName: 'Admin',
|
||||||
|
role: 'admin',
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const RestaurantMenusController = () => import('#controllers/restaurant_menus_co
|
|||||||
const CategoriesController = () => import('#controllers/categories_controller')
|
const CategoriesController = () => import('#controllers/categories_controller')
|
||||||
const UsersController = () => import('#controllers/users_controller')
|
const UsersController = () => import('#controllers/users_controller')
|
||||||
const ImagesController = () => import('#controllers/images_controller')
|
const ImagesController = () => import('#controllers/images_controller')
|
||||||
|
const RoomReservationsController = () => import('#controllers/room_reservations_controller')
|
||||||
|
|
||||||
// Auth routes
|
// Auth routes
|
||||||
router.group(() => {
|
router.group(() => {
|
||||||
@@ -132,5 +133,40 @@ router
|
|||||||
router.get('/:filename', [ImagesController, 'show']).as('images.show')
|
router.get('/:filename', [ImagesController, 'show']).as('images.show')
|
||||||
})
|
})
|
||||||
.prefix('/images')
|
.prefix('/images')
|
||||||
|
|
||||||
|
// Room and Reservation routes
|
||||||
|
router
|
||||||
|
.group(() => {
|
||||||
|
// Rooms
|
||||||
|
router.get('/rooms', [RoomReservationsController, 'listRooms']).as('rooms.list')
|
||||||
|
router
|
||||||
|
.post('/rooms', [RoomReservationsController, 'createRoom'])
|
||||||
|
.as('rooms.create')
|
||||||
|
.use([middleware.auth(), middleware.admin()])
|
||||||
|
router
|
||||||
|
.put('/rooms', [RoomReservationsController, 'updateRoom'])
|
||||||
|
.as('rooms.update')
|
||||||
|
.use([middleware.auth(), middleware.admin()])
|
||||||
|
router
|
||||||
|
.delete('/rooms', [RoomReservationsController, 'deleteRoom'])
|
||||||
|
.as('rooms.delete')
|
||||||
|
.use([middleware.auth(), middleware.admin()])
|
||||||
|
|
||||||
|
// Reservations
|
||||||
|
router.get('/reservations', [RoomReservationsController, 'index']).as('reservations.index')
|
||||||
|
router
|
||||||
|
.post('/reservations', [RoomReservationsController, 'store'])
|
||||||
|
.as('reservations.store')
|
||||||
|
.use([middleware.auth(), middleware.admin()])
|
||||||
|
router
|
||||||
|
.put('/reservations', [RoomReservationsController, 'update'])
|
||||||
|
.as('reservations.update')
|
||||||
|
.use([middleware.auth(), middleware.admin()])
|
||||||
|
router
|
||||||
|
.delete('/reservations', [RoomReservationsController, 'destroy'])
|
||||||
|
.as('reservations.destroy')
|
||||||
|
.use([middleware.auth(), middleware.admin()])
|
||||||
|
})
|
||||||
|
.prefix('/room-reservations')
|
||||||
})
|
})
|
||||||
.prefix('/api')
|
.prefix('/api')
|
||||||
|
|||||||
Reference in New Issue
Block a user