refactor admin to use eventbus

This commit is contained in:
Roland Schneider
2025-12-11 22:47:54 +01:00
parent 93b1fb9610
commit 453d02612c
27 changed files with 298 additions and 225 deletions

View File

@@ -16,7 +16,7 @@
"@nestjs/mapped-types": "^2.1.0",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.2.1",
"@nestjs/swagger": "^11.2.3",
"@nestjs/typeorm": "^11.0.0",
"bcrypt": "^5.1.1",
"class-transformer": "^0.5.1",
@@ -2109,9 +2109,9 @@
}
},
"node_modules/@microsoft/tsdoc": {
"version": "0.15.1",
"resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.15.1.tgz",
"integrity": "sha512-4aErSrCR/On/e5G2hDP0wjooqDdauzEbIq8hIkIe5pXV0rtWJZvdCEKL0ykZxex+IxIwBp0eGeV48hQN07dXtw==",
"version": "0.16.0",
"resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.16.0.tgz",
"integrity": "sha512-xgAyonlVVS+q7Vc7qLW0UrJU7rSFcETRWsqdXZtjzRU8dF+6CkozTK4V4y1LwOX7j8r/vHphjDeMeGI4tNGeGA==",
"license": "MIT"
},
"node_modules/@napi-rs/wasm-runtime": {
@@ -2620,17 +2620,17 @@
}
},
"node_modules/@nestjs/swagger": {
"version": "11.2.1",
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-11.2.1.tgz",
"integrity": "sha512-1MS7xf0pzc1mofG53xrrtrurnziafPUHkqzRm4YUVPA/egeiMaSerQBD/feiAeQ2BnX0WiLsTX4HQFO0icvOjQ==",
"version": "11.2.3",
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-11.2.3.tgz",
"integrity": "sha512-a0xFfjeqk69uHIUpP8u0ryn4cKuHdra2Ug96L858i0N200Hxho+n3j+TlQXyOF4EstLSGjTfxI1Xb2E1lUxeNg==",
"license": "MIT",
"dependencies": {
"@microsoft/tsdoc": "0.15.1",
"@microsoft/tsdoc": "0.16.0",
"@nestjs/mapped-types": "2.1.0",
"js-yaml": "4.1.0",
"js-yaml": "4.1.1",
"lodash": "4.17.21",
"path-to-regexp": "8.3.0",
"swagger-ui-dist": "5.29.4"
"swagger-ui-dist": "5.30.2"
},
"peerDependencies": {
"@fastify/static": "^8.0.0",
@@ -7814,9 +7814,9 @@
"license": "MIT"
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@@ -10202,9 +10202,9 @@
}
},
"node_modules/swagger-ui-dist": {
"version": "5.29.4",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.29.4.tgz",
"integrity": "sha512-gJFDz/gyLOCQtWwAgqs6Rk78z9ONnqTnlW11gimG9nLap8drKa3AJBKpzIQMIjl5PD2Ix+Tn+mc/tfoT2tgsng==",
"version": "5.30.2",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.30.2.tgz",
"integrity": "sha512-HWCg1DTNE/Nmapt+0m2EPXFwNKNeKK4PwMjkwveN/zn1cV2Kxi9SURd+m0SpdcSgWEK/O64sf8bzXdtUhigtHA==",
"license": "Apache-2.0",
"dependencies": {
"@scarf/scarf": "=1.4.0"

View File

@@ -30,7 +30,7 @@
"@nestjs/mapped-types": "^2.1.0",
"@nestjs/passport": "^11.0.5",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.2.1",
"@nestjs/swagger": "^11.2.3",
"@nestjs/typeorm": "^11.0.0",
"bcrypt": "^5.1.1",
"class-transformer": "^0.5.1",

View File

@@ -9,6 +9,7 @@ import {
Query,
ParseIntPipe,
UseGuards,
ValidationPipe,
} from '@nestjs/common';
import { CalendarService } from './calendar.service';
import { GetCalendarDto } from './dto/get-calendar.dto';
@@ -18,8 +19,9 @@ import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { RolesGuard } from '../auth/roles.guard';
import { Roles } from '../auth/roles.decorator';
import { Role } from '../auth/role.enum';
import { CreateBookingDto } from './dto/create-booking.dto';
import { CalendarCreateBookingDto } from './dto/create-booking.dto';
import { CancelBookingDto } from './dto/cancel-booking.dto';
import { ApiBody } from '@nestjs/swagger';
@Controller('calendar')
@UseGuards(JwtAuthGuard, RolesGuard)
@@ -73,9 +75,10 @@ export class CalendarController {
// Create a booking for a specific event occurrence
@Post('events/:id/bookings')
@ApiBody({ type: CalendarCreateBookingDto })
createBooking(
@Param('id', ParseIntPipe) eventId: number,
@Body() createBookingDto: CreateBookingDto,
@Body(new ValidationPipe()) createBookingDto: CalendarCreateBookingDto,
) {
return this.calendarService.createBooking(eventId, createBookingDto);
}

View File

@@ -14,7 +14,7 @@ import { CreateEventDto } from './dto/create-event.dto';
import { CreateExceptionDto } from './dto/create-exception.dto';
import { Booking } from '../entity/booking.entity';
import { CancelBookingDto } from './dto/cancel-booking.dto';
import { CreateBookingDto } from './dto/create-booking.dto';
import { CalendarCreateBookingDto } from './dto/create-booking.dto';
import { EventType } from '../entity/event-type.entity';
// --- Type-Safe Maps ---
@@ -520,7 +520,7 @@ export class CalendarService {
async createBooking(
eventId: number,
createBookingDto: CreateBookingDto,
createBookingDto: CalendarCreateBookingDto,
): Promise<Booking> {
const { occurrenceStartTime, userId } = createBookingDto;

View File

@@ -7,23 +7,28 @@ import {
Min,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';
export class CreateBookingDto {
export class CalendarCreateBookingDto {
@IsNotEmpty()
@Type(() => Date)
@IsDate()
@ApiProperty()
occurrenceStartTime: Date;
@IsNotEmpty()
@IsInt()
@ApiProperty()
userId: number; // Replaces userName/userEmail
@IsOptional()
@IsInt()
@Min(1)
@ApiProperty()
reservedSeatsCount?: number = 1;
@IsOptional()
@IsString()
@ApiProperty()
notes?: string;
}