/
Befun
/
KiizLab
Обзор
Документация
Войти
/
Befun
/
KiizLab
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/src/step/step.controller.ts
80 строк
3 KB
BeFun
init frontend
25 апр 2025, 21:57
25 апр 2025, 21:57
f476f7b
Код
Авторство
О чём код?
import { Body, Controller, Delete, Get, Param, Post, Put, UsePipes, ValidationPipe } from '@nestjs/common' import { ApiBearerAuth, ApiResponse } from '@nestjs/swagger' import { Auth } from 'src/auth/decorators/auth.decorator' import { CreateStepDto, UpdateStepDto } from './dto/createStep.dto' import { StepService } from './step.service' @Controller('step') export class StepController { constructor(private readonly stepService: StepService) {} @Get(':id') @Auth() @ApiBearerAuth() @ApiResponse({ status: 200, description: 'Выдаёт информацию об конкретной счасти статьи' }) @ApiResponse({ status: 400, description: 'Неверный id' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированный' }) async getStep(@Param('id') id: string) { return this.stepService.getById(id) } @UsePipes(new ValidationPipe()) @Post() @Auth('teacher') @ApiBearerAuth() @ApiResponse({ status: 201, description: 'Создаёт отдельную часть урока' }) @ApiResponse({ status: 400, description: 'Неверно введеные данные' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированый' }) @ApiResponse({ status: 403, description: 'У пользователя нехватает прав' }) async create(@Body() dto: CreateStepDto) { return this.stepService.create(dto) } @UsePipes(new ValidationPipe()) @Put(':id') @Auth('teacher') @ApiBearerAuth() @ApiResponse({ status: 200, description: 'Обновление контента шага' }) @ApiResponse({ status: 400, description: 'Неверно введеные данные' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированый' }) @ApiResponse({ status: 403, description: 'У пользователя нехватает прав' }) async update(@Param('id') id: string, dto: UpdateStepDto) { return this.stepService.update(id, dto) } @Delete(':id') @Auth('teacher') @ApiBearerAuth() @ApiResponse({ status: 200, description: 'Удаление шага' }) @ApiResponse({ status: 400, description: 'Неверно введеные данные' }) @ApiResponse({ status: 401, description: 'Пользователь не зарегистрированый' }) @ApiResponse({ status: 403, description: 'У пользователя нехватает прав' }) async delete(@Param('id') id: string) { return this.stepService.delete(id) } }