Много

This commit is contained in:
2024-09-12 00:39:01 +04:00
parent 6b07bd89b8
commit 8fb9214246
24 changed files with 643 additions and 194 deletions

View File

@@ -1,16 +1,23 @@
import {
Body,
Controller,
Get,
HttpCode,
HttpStatus,
HttpStatus, Post,
UseGuards,
} from "@nestjs/common";
import { AuthGuard } from "../auth/auth.guard";
import { ScheduleService } from "./schedule.service";
import { ScheduleDto } from "../dto/schedule.dto";
import {
GroupScheduleDto,
GroupScheduleRequestDto,
ScheduleDto,
ScheduleGroupsDto,
} from "../dto/schedule.dto";
import { ResultDto } from "../utility/validation/class-validator.interceptor";
import {
ApiExtraModels,
ApiNotFoundResponse,
ApiOkResponse,
ApiOperation,
refs,
@@ -19,7 +26,7 @@ import {
@Controller("api/v1/schedule")
@UseGuards(AuthGuard)
export class ScheduleController {
constructor(private scheduleService: ScheduleService) {}
constructor(private readonly scheduleService: ScheduleService) {}
@ApiExtraModels(ScheduleDto)
@ApiOperation({ summary: "Получение расписания", tags: ["schedule"] })
@@ -33,4 +40,40 @@ export class ScheduleController {
getSchedule(): Promise<ScheduleDto> {
return this.scheduleService.getSchedule();
}
@ApiExtraModels(GroupScheduleDto)
@ApiOperation({
summary: "Получение расписания группы",
tags: ["schedule"],
})
@ApiOkResponse({
description: "Расписание получено успешно",
schema: refs(GroupScheduleDto)[0],
})
@ApiNotFoundResponse({ description: "Требуемая группа не найдена" })
@ResultDto(GroupScheduleDto)
@HttpCode(HttpStatus.OK)
@Post("getGroup")
getGroupSchedule(
@Body() groupDto: GroupScheduleRequestDto,
): Promise<GroupScheduleDto> {
return this.scheduleService.getGroup(groupDto.name);
}
@ApiExtraModels(ScheduleGroupsDto)
@ApiOperation({
summary: "Получение списка названий всех групп в расписании",
tags: ["schedule"],
})
@ApiOkResponse({
description: "Список получен успешно",
schema: refs(ScheduleGroupsDto)[0],
})
@ApiNotFoundResponse({ description: "Требуемая группа не найдена" })
@ResultDto(ScheduleGroupsDto)
@HttpCode(HttpStatus.OK)
@Get("getGroupNames")
async getGroupNames(): Promise<ScheduleGroupsDto> {
return this.scheduleService.getGroupNames();
}
}