events-service.controller.ts73 lines, 1.7 KB
| 1 | import { |
| 2 | Body, |
| 3 | Controller, |
| 4 | Get, |
| 5 | Headers, |
| 6 | Param, |
| 7 | ParseUUIDPipe, |
| 8 | Post, |
| 9 | Put, |
| 10 | } from '@nestjs/common'; |
| 11 | import { EventsServiceService } from './events-service.service'; |
| 12 | import { CreateEventDto, UpdateEventDto } from '@app/common'; |
| 13 | |
| 14 | @Controller() |
| 15 | export class EventsServiceController { |
| 16 | constructor(private readonly eventsServiceService: EventsServiceService) {} |
| 17 | |
| 18 | @Post() |
| 19 | create( |
| 20 | @Body() createEventDto: CreateEventDto, |
| 21 | @Headers('x-user-id') userId: string, |
| 22 | ) { |
| 23 | return this.eventsServiceService.create(createEventDto, userId); |
| 24 | } |
| 25 | |
| 26 | @Get() |
| 27 | findAll() { |
| 28 | return this.eventsServiceService.findAll(); |
| 29 | } |
| 30 | |
| 31 | @Get('my-events') |
| 32 | findMyEvent(@Headers('x-user-id') userId: string) { |
| 33 | return this.eventsServiceService.findMyEvent(userId); |
| 34 | } |
| 35 | |
| 36 | @Get(':id') |
| 37 | findOne(@Param('id', ParseUUIDPipe) id: string) { |
| 38 | return this.eventsServiceService.findOne(id); |
| 39 | } |
| 40 | |
| 41 | @Put(':id') |
| 42 | update( |
| 43 | @Param('id', ParseUUIDPipe) id: string, |
| 44 | @Body() updateEventDto: UpdateEventDto, |
| 45 | @Headers('x-user-id') userId: string, |
| 46 | @Headers('x-user-role') userRole: string, |
| 47 | ) { |
| 48 | return this.eventsServiceService.update( |
| 49 | id, |
| 50 | updateEventDto, |
| 51 | userId, |
| 52 | userRole, |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | @Post(':id/publish') |
| 57 | publish( |
| 58 | @Param('id', ParseUUIDPipe) id: string, |
| 59 | @Headers('x-user-id') userId: string, |
| 60 | @Headers('x-user-role') userRole: string, |
| 61 | ) { |
| 62 | return this.eventsServiceService.publish(id, userId, userRole); |
| 63 | } |
| 64 | |
| 65 | @Post(':id/cancel') |
| 66 | cancel( |
| 67 | @Param('id', ParseUUIDPipe) id: string, |
| 68 | @Headers('x-user-id') userId: string, |
| 69 | @Headers('x-user-role') userRole: string, |
| 70 | ) { |
| 71 | return this.eventsServiceService.cancel(id, userId, userRole); |
| 72 | } |
| 73 | } |