/
voting
/
voting-backend
Обзор
Документация
Войти
/
voting
/
voting-backend
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
main
src/api/admin/events/events.controller.ts
82 строки
3 KB
pulintim
Запрос на слияние 'docs/update-25' (
#25
) из docs/update-25 в main
18 июл 2026, 21:05
Верифицирован
18 июл 2026, 21:05
80fda85
Код
Авторство
О чём код?
import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Param, ParseUUIDPipe, Post, Put } from '@nestjs/common' import { ApiBadRequestResponse, ApiCreatedResponse, ApiNoContentResponse, ApiNotFoundResponse, ApiOkResponse, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger' import { CreateEventDto } from './dto/create-event.dto' import { AdminEventResponseDto } from './dto/event-response.dto' import { UpdateEventDto } from './dto/update-event.dto' import { AdminEventsService } from './events.service' @ApiTags('admin/events') @Controller('admin/events') export class AdminEventsController { constructor(private readonly adminEventsService: AdminEventsService) {} @Post() @HttpCode(HttpStatus.CREATED) @ApiOperation({ summary: 'Create event' }) @ApiBadRequestResponse({ description: 'Validation failed' }) @ApiCreatedResponse({ type: AdminEventResponseDto }) async create(@Body() body: CreateEventDto): Promise<AdminEventResponseDto> { return this.adminEventsService.create(body) } @Get() @ApiOperation({ summary: 'List events' }) @ApiOkResponse({ type: AdminEventResponseDto, isArray: true }) async findAll(): Promise<AdminEventResponseDto[]> { return this.adminEventsService.findAll() } @Get(':id') @ApiOperation({ summary: 'Get event by id' }) @ApiParam({ name: 'id', format: 'uuid' }) @ApiBadRequestResponse({ description: 'Invalid UUID' }) @ApiNotFoundResponse({ description: 'Event not found' }) @ApiOkResponse({ type: AdminEventResponseDto }) async findById(@Param('id', ParseUUIDPipe) id: string): Promise<AdminEventResponseDto> { return this.adminEventsService.findById(id) } @Put(':id') @ApiOperation({ summary: 'Update event' }) @ApiParam({ name: 'id', format: 'uuid' }) @ApiBadRequestResponse({ description: 'Invalid UUID or validation failed' }) @ApiNotFoundResponse({ description: 'Event not found' }) @ApiOkResponse({ type: AdminEventResponseDto }) async update( @Param('id', ParseUUIDPipe) id: string, @Body() body: UpdateEventDto ): Promise<AdminEventResponseDto> { return this.adminEventsService.update(id, body) } @Delete(':id') @HttpCode(HttpStatus.NO_CONTENT) @ApiOperation({ summary: 'Delete event' }) @ApiParam({ name: 'id', format: 'uuid' }) @ApiBadRequestResponse({ description: 'Invalid UUID' }) @ApiNotFoundResponse({ description: 'Event not found' }) @ApiNoContentResponse() async remove(@Param('id', ParseUUIDPipe) id: string): Promise<void> { await this.adminEventsService.remove(id) } }