mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 02:58:11 +00:00
Initial commit of edr-passenger-api alpha version
This commit is contained in:
@@ -1,48 +1,14 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Post,
|
||||
Query,
|
||||
} from "@nestjs/common";
|
||||
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { TicketsService } from './tickets.service';
|
||||
import { JwtGuard } from '../../common/jwt.guard';
|
||||
|
||||
import { CreateTicketDto } from "./dto/create-ticket.dto";
|
||||
import { FilterTicketDto } from "./dto/filter-ticket.dto";
|
||||
import { TicketsService } from "./tickets.service";
|
||||
|
||||
@ApiTags("tickets")
|
||||
// @UseGuards(JwtAuthGuard) — TODO: integrate @edr/auth
|
||||
@Controller("tickets")
|
||||
@ApiTags('Tickets')
|
||||
@Controller('tickets')
|
||||
@UseGuards(JwtGuard)
|
||||
@ApiBearerAuth('JWT-auth')
|
||||
export class TicketsController {
|
||||
constructor(private readonly ticketsService: TicketsService) {}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: "Issue a new passenger ticket" })
|
||||
create(@Body() dto: CreateTicketDto) {
|
||||
return this.ticketsService.create(dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: "List passenger tickets (paginated)" })
|
||||
findAll(@Query() filter: FilterTicketDto) {
|
||||
return this.ticketsService.findAll(filter);
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
@ApiOperation({ summary: "Get a ticket by ID" })
|
||||
findOne(@Param("id", ParseUUIDPipe) id: string) {
|
||||
return this.ticketsService.findById(id);
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
@HttpCode(204)
|
||||
@ApiOperation({ summary: "Cancel a ticket" })
|
||||
cancel(@Param("id", ParseUUIDPipe) id: string) {
|
||||
return this.ticketsService.cancel(id);
|
||||
}
|
||||
constructor(private service: TicketsService) {}
|
||||
@Get(':bookingRef') @ApiOperation({ summary: 'Get ticket by booking reference' }) getByRef(@Param('bookingRef') ref: string) { return this.service.getByRef(ref); }
|
||||
@Post(':bookingRef/validate') @ApiOperation({ summary: 'Validate ticket at gate (staff)' }) validate(@Param('bookingRef') ref: string, @Body('validatorId') validatorId: string) { return this.service.validate(ref, validatorId); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user