/
range
/
stock
Обзор
Документация
Войти
/
range
/
stock
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/src/courses/courses.controller.ts
45 строк
1 KB
Range18
Shedevro commit
23 ноя 2025, 09:15
23 ноя 2025, 09:15
59bb6f3
Код
Авторство
О чём код?
import { Controller, Delete, Get, Param, ParseIntPipe, Query, } from '@nestjs/common'; import { CoursesService, ElectiveCourse } from './courses.service'; import { Course } from './entities/course.entity'; import { ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger'; import { FindCoursesDto } from './dto/find-courses.dto'; @ApiTags('courses') @Controller('courses') export class CoursesController { constructor(private readonly coursesService: CoursesService) {} @Get() @ApiOperation({ summary: 'Получить список всех курсов' }) @ApiResponse({ status: 200, type: [Course] }) findAll( @Query() query: FindCoursesDto, ): Promise<(Course | ElectiveCourse)[]> { return this.coursesService.findAll(query); } @Get(':id') @ApiOperation({ summary: 'Получить курс по ID' }) @ApiParam({ name: 'id', type: Number, example: 1 }) @ApiResponse({ status: 200, type: Course }) @ApiResponse({ status: 404, description: 'Course not found' }) findOne(@Param('id', ParseIntPipe) id: number): Promise<Course> { return this.coursesService.findOne(id); } @Delete(':id') @ApiOperation({ summary: 'Удалить курс по ID' }) @ApiParam({ name: 'id', type: Number, example: 1 }) @ApiResponse({ status: 200, description: 'Курс удалён' }) @ApiResponse({ status: 404, description: 'Course not found' }) remove(@Param('id', ParseIntPipe) id: number): Promise<void> { return this.coursesService.remove(id); } }