|
| 1 | +import { applyDecorators } from '@nestjs/common'; |
| 2 | +import { ApiBody, ApiOperation, ApiParam, ApiQuery, ApiResponse } from '@nestjs/swagger'; |
| 3 | +import { ActionResponse } from 'src/shared/dtos'; |
| 4 | +import { |
| 5 | + ApiConflict, |
| 6 | + ApiForbidden, |
| 7 | + ApiNotFound, |
| 8 | + ApiUnauthorized, |
| 9 | + ApiValidationError, |
| 10 | +} from 'src/shared/error'; |
| 11 | +import { CreateTeamDto, InviteMemberDto, SyncTagsDto, TagResponse, UpdateTeamDto } from '../dtos'; |
| 12 | + |
| 13 | +export const CreateTeamSwagger = () => |
| 14 | + applyDecorators( |
| 15 | + ApiOperation({ summary: 'Создать новую команду' }), |
| 16 | + ApiBody({ type: CreateTeamDto.Output }), |
| 17 | + ApiResponse({ |
| 18 | + status: 201, |
| 19 | + description: 'Команда успешно создана', |
| 20 | + type: ActionResponse.Output, |
| 21 | + }), |
| 22 | + ApiConflict('Команда с таким slug уже существует'), |
| 23 | + ApiValidationError(), |
| 24 | + ApiUnauthorized(), |
| 25 | + ); |
| 26 | + |
| 27 | +export const FindAllTeamsSwagger = () => |
| 28 | + applyDecorators( |
| 29 | + ApiOperation({ summary: 'Получить список команд пользователя' }), |
| 30 | + ApiResponse({ |
| 31 | + status: 200, |
| 32 | + description: 'Список команд получен', |
| 33 | + type: [Object], |
| 34 | + }), |
| 35 | + ApiUnauthorized(), |
| 36 | + ); |
| 37 | + |
| 38 | +export const FindOneTeamSwagger = () => |
| 39 | + applyDecorators( |
| 40 | + ApiOperation({ summary: 'Получить детальную информацию о команде по slug' }), |
| 41 | + ApiParam({ name: 'slug', description: 'Уникальный идентификатор (слаг) команды' }), |
| 42 | + ApiResponse({ |
| 43 | + status: 200, |
| 44 | + description: 'Данные команды получены', |
| 45 | + type: Object, |
| 46 | + }), |
| 47 | + ApiNotFound('Команда не найдена'), |
| 48 | + ApiUnauthorized(), |
| 49 | + ); |
| 50 | + |
| 51 | +export const UpdateTeamSwagger = () => |
| 52 | + applyDecorators( |
| 53 | + ApiOperation({ summary: 'Обновить данные команды' }), |
| 54 | + ApiBody({ type: UpdateTeamDto.Output }), |
| 55 | + ApiParam({ name: 'slug', description: 'Слаг команды для редактирования' }), |
| 56 | + ApiResponse({ |
| 57 | + status: 200, |
| 58 | + description: 'Команда успешно обновлена', |
| 59 | + type: ActionResponse.Output, |
| 60 | + }), |
| 61 | + ApiForbidden(), |
| 62 | + ApiNotFound(), |
| 63 | + ApiValidationError(), |
| 64 | + ApiUnauthorized(), |
| 65 | + ); |
| 66 | + |
| 67 | +export const RemoveTeamSwagger = () => |
| 68 | + applyDecorators( |
| 69 | + ApiOperation({ summary: 'Удалить команду' }), |
| 70 | + ApiParam({ name: 'slug', description: 'Слаг команды для удаления' }), |
| 71 | + ApiResponse({ |
| 72 | + status: 204, |
| 73 | + description: 'Команда успешно удалена', |
| 74 | + type: ActionResponse.Output, |
| 75 | + }), |
| 76 | + ApiForbidden(), |
| 77 | + ApiNotFound(), |
| 78 | + ApiUnauthorized(), |
| 79 | + ); |
| 80 | + |
| 81 | +export const SyncTeamTagsSwagger = () => |
| 82 | + applyDecorators( |
| 83 | + ApiOperation({ summary: 'Синхронизировать теги команды' }), |
| 84 | + ApiBody({ type: SyncTagsDto.Output }), |
| 85 | + ApiResponse({ status: 200, description: 'Теги обновлены', type: ActionResponse.Output }), |
| 86 | + ApiForbidden(), |
| 87 | + ApiNotFound(), |
| 88 | + ApiUnauthorized(), |
| 89 | + ); |
| 90 | + |
| 91 | +export const GetAllTagsSwagger = () => |
| 92 | + applyDecorators( |
| 93 | + ApiOperation({ |
| 94 | + summary: 'Получить список всех тегов', |
| 95 | + description: 'Используется для поиска и автокомплита при создании команд.', |
| 96 | + }), |
| 97 | + ApiQuery({ name: 'search', required: false, description: 'Поиск по названию тега' }), |
| 98 | + ApiResponse({ |
| 99 | + status: 200, |
| 100 | + description: 'Список тегов успешно получен', |
| 101 | + type: [TagResponse.Output], |
| 102 | + }), |
| 103 | + ApiUnauthorized(), |
| 104 | + ); |
| 105 | + |
| 106 | +export const GetMembersSwagger = () => |
| 107 | + applyDecorators( |
| 108 | + ApiOperation({ summary: 'Получить список всех участников команды' }), |
| 109 | + ApiParam({ name: 'slug', description: 'Слаг команды' }), |
| 110 | + ApiResponse({ |
| 111 | + status: 200, |
| 112 | + description: 'Список участников получен', |
| 113 | + type: [Object], |
| 114 | + }), |
| 115 | + ApiUnauthorized(), |
| 116 | + ApiForbidden(), |
| 117 | + ); |
| 118 | + |
| 119 | +export const InviteMemberSwagger = () => |
| 120 | + applyDecorators( |
| 121 | + ApiOperation({ summary: 'Пригласить пользователя в команду по Email' }), |
| 122 | + ApiBody({ type: InviteMemberDto.Output }), |
| 123 | + ApiParam({ name: 'slug', description: 'Слаг команды' }), |
| 124 | + ApiResponse({ status: 201, description: 'Инвайт создан и отправлен' }), |
| 125 | + ApiValidationError('Ошибка в формате email или данных'), |
| 126 | + ApiUnauthorized(), |
| 127 | + ApiForbidden(), |
| 128 | + ); |
| 129 | + |
| 130 | +export const UpdateMemberSwagger = () => |
| 131 | + applyDecorators( |
| 132 | + ApiOperation({ summary: 'Изменить роль или статус участника' }), |
| 133 | + ApiParam({ name: 'slug', description: 'Слаг команды' }), |
| 134 | + ApiParam({ name: 'userId', description: 'ID пользователя' }), |
| 135 | + ApiResponse({ |
| 136 | + status: 200, |
| 137 | + description: 'Данные участника обновлены', |
| 138 | + type: ActionResponse.Output, |
| 139 | + }), |
| 140 | + ApiNotFound('Участник или команда не найдены'), |
| 141 | + ApiUnauthorized(), |
| 142 | + ApiForbidden(), |
| 143 | + ); |
| 144 | + |
| 145 | +export const RemoveMemberSwagger = () => |
| 146 | + applyDecorators( |
| 147 | + ApiOperation({ summary: 'Удалить участника из команды' }), |
| 148 | + ApiParam({ name: 'slug', description: 'Слаг команды' }), |
| 149 | + ApiParam({ name: 'userId', description: 'ID пользователя' }), |
| 150 | + ApiResponse({ |
| 151 | + status: 204, |
| 152 | + type: ActionResponse.Output, |
| 153 | + description: 'Участник успешно удален', |
| 154 | + }), |
| 155 | + ApiNotFound(), |
| 156 | + ApiUnauthorized(), |
| 157 | + ApiForbidden(), |
| 158 | + ); |
0 commit comments