/
Befun
/
KiizLab
Обзор
Документация
Войти
/
Befun
/
KiizLab
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/src/course/course.controller.ts
74 строки
2 KB
BeFun
init frontend
25 апр 2025, 21:57
25 апр 2025, 21:57
f476f7b
Код
Авторство
О чём код?
import { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common' import { ApiBearerAuth, ApiResponse } from '@nestjs/swagger' import { Auth } from 'src/auth/decorators/auth.decorator' import { CourseService } from './course.service' import { CreateCourseDto, UpdateCourseDto } from './dto/createCourse.dto' @Controller('course') export class CourseController { constructor(private readonly courseService: CourseService) {} @Get() @Auth() @ApiBearerAuth() @ApiResponse({ status: 200, description: 'Выдаёт информацию о всех курсах' }) @ApiResponse({ status: 400, description: 'Неверный id' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированный' }) async getAll() { return this.courseService.getAll() } @Post() @Auth() @ApiBearerAuth() @ApiResponse({ status: 201, description: 'Создаёт новый курс' }) @ApiResponse({ status: 400, description: 'Неверный id' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированный' }) async create(@Body() dto: CreateCourseDto) { return this.courseService.create(dto) } @Put(':id') @Auth() @ApiBearerAuth() @ApiResponse({ status: 200, description: 'Изменяет курс' }) @ApiResponse({ status: 400, description: 'Неверный id' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированный' }) async update(@Param('id') id: string, @Body() dto: UpdateCourseDto) { return this.courseService.update(id, dto) } @Delete(':id') @Auth() @ApiBearerAuth() @ApiResponse({ status: 200, description: 'Удоляет курс' }) @ApiResponse({ status: 400, description: 'Неверный id' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированный' }) async delete(@Param('id') id: string) { return this.courseService.delete(id) } }