mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
36 lines
2.0 KiB
TypeScript
36 lines
2.0 KiB
TypeScript
import { Body, Controller, Delete, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth, ApiParam, ApiQuery, ApiResponse } from '@nestjs/swagger';
|
|
import { SeatsService } from './seats.service';
|
|
import { HoldSeatsDto } from './seats.dto';
|
|
import { JwtGuard } from '../../common/jwt.guard';
|
|
|
|
@ApiTags('Seats')
|
|
@Controller('seats')
|
|
export class SeatsController {
|
|
constructor(private service: SeatsService) {}
|
|
|
|
// ── Seat Map ──────────────────────────────────────────────────────────────
|
|
@Get('seatmap/:tripId')
|
|
@ApiOperation({ summary: 'Get seat map for a trip' })
|
|
@ApiParam({ name: 'tripId', description: 'Trip UUID' })
|
|
@ApiQuery({ name: 'coachId', required: false, description: 'Filter by coach UUID' })
|
|
@ApiResponse({ status: 200, description: 'Returns coaches with seats and seat class info' })
|
|
getSeatMap(@Param('tripId') tripId: string, @Query('coachId') coachId?: string) { return this.service.getSeatMap(tripId, coachId); }
|
|
|
|
// ── Hold / Release ────────────────────────────────────────────────────────
|
|
@Post('hold')
|
|
@UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth')
|
|
@ApiOperation({ summary: 'Hold seats for 15 minutes' })
|
|
@ApiResponse({ status: 201, description: 'Seats held successfully' })
|
|
@ApiResponse({ status: 409, description: 'One or more seats unavailable' })
|
|
holdSeats(@Body() dto: HoldSeatsDto) { return this.service.holdSeats(dto); }
|
|
|
|
@Delete('hold/:holdId')
|
|
@UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth')
|
|
@ApiOperation({ summary: 'Release a seat hold' })
|
|
@ApiParam({ name: 'holdId', description: 'Hold UUID' })
|
|
@ApiResponse({ status: 200, description: 'Hold released' })
|
|
@ApiResponse({ status: 404, description: 'Hold not found' })
|
|
releaseHold(@Param('holdId') holdId: string) { return this.service.releaseHold(holdId); }
|
|
}
|