tickets-service.controller.ts64 lines, 1.5 KB
| 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | Get, |
| 5 | Headers, |
| 6 | Param, |
| 7 | ParseUUIDPipe, |
| 8 | Post, |
| 9 | } from '@nestjs/common'; |
| 10 | import { TicketsServiceService } from './tickets-service.service'; |
| 11 | import { CheckInTicketDto, PurchaseTicketDto } from '@app/common'; |
| 12 | |
| 13 | @Controller() |
| 14 | export class TicketsServiceController { |
| 15 | constructor(private readonly ticketsServiceService: TicketsServiceService) {} |
| 16 | |
| 17 | @Post('purchase') |
| 18 | purchase( |
| 19 | @Body() purchaseDto: PurchaseTicketDto, |
| 20 | @Headers('x-user-id') userId: string, |
| 21 | ) { |
| 22 | return this.ticketsServiceService.purchase(purchaseDto, userId); |
| 23 | } |
| 24 | |
| 25 | @Get('my-tickets') |
| 26 | findMyTickets(@Headers('x-user-id') userId: string) { |
| 27 | return this.ticketsServiceService.findMyTicket(userId); |
| 28 | } |
| 29 | |
| 30 | @Get(':id') |
| 31 | findOne( |
| 32 | @Param('id', ParseUUIDPipe) id: string, |
| 33 | @Headers('x-user-id') userId: string, |
| 34 | ) { |
| 35 | return this.ticketsServiceService.findOne(id, userId); |
| 36 | } |
| 37 | |
| 38 | @Post(':id/cancel') |
| 39 | cancel( |
| 40 | @Param('id', ParseUUIDPipe) id: string, |
| 41 | @Headers('x-user-id') userId: string, |
| 42 | ) { |
| 43 | return this.ticketsServiceService.cancel(id, userId); |
| 44 | } |
| 45 | |
| 46 | @Post('check-in') |
| 47 | checkIn( |
| 48 | @Body() checkInDto: CheckInTicketDto, |
| 49 | @Headers('x-user-id') organizerId: string, |
| 50 | ) { |
| 51 | return this.ticketsServiceService.checkIn( |
| 52 | checkInDto.ticketCode, |
| 53 | organizerId, |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | @Get('event/:eventId') |
| 58 | findEventTickets( |
| 59 | @Param('eventId', ParseUUIDPipe) eventId: string, |
| 60 | @Headers('x-user-id') organizerId: string, |
| 61 | ) { |
| 62 | return this.ticketsServiceService.findEventTickst(eventId, organizerId); |
| 63 | } |
| 64 | } |