From be63fc3c106583af65fa7161c1172e48e4d95f31 Mon Sep 17 00:00:00 2001 From: backdev-1 Date: Tue, 30 Jun 2026 23:32:57 +0700 Subject: [PATCH] Add api key for use rest api --- ...open-api.yaml => open-api-controller.yaml} | 477 +++++- infrastructure/open-api-key-controller.yaml | 350 ++++ infrastructure/support-controller.yaml | 1410 +++++++++++++++++ 3 files changed, 2178 insertions(+), 59 deletions(-) rename infrastructure/{open-api.yaml => open-api-controller.yaml} (70%) create mode 100644 infrastructure/open-api-key-controller.yaml create mode 100644 infrastructure/support-controller.yaml diff --git a/infrastructure/open-api.yaml b/infrastructure/open-api-controller.yaml similarity index 70% rename from infrastructure/open-api.yaml rename to infrastructure/open-api-controller.yaml index f979dce..17bb5e1 100644 --- a/infrastructure/open-api.yaml +++ b/infrastructure/open-api-controller.yaml @@ -100,9 +100,6 @@ paths: message_desc: "User not found" message_body: {} - # = INTERNAL ENDPOINTS предназначены для работы с данными = - # = Для использования эндпоинтов предусмотрен только внутренний ключ X-Internal-Key (header) = - /api/internal/data-info: post: tags: @@ -137,10 +134,10 @@ paths: value: msg_id: 30019 message_body: - top: 10, + top: 10 type: "image" tariffStatistic: - summary: Информация по таррифам + summary: Информация по тарифам value: msg_id: 30020 message_body: @@ -164,7 +161,7 @@ paths: value: msg_id: 30024 tokenStatistic: - summary: Подписки + summary: Статистика токенов value: msg_id: 30025 incomingStatistic: @@ -195,7 +192,6 @@ paths: page_size: 10 sort_by: "createdAt" sort_direction: "desc" - responses: '200': description: Ответ с запрашиваемой информацией @@ -393,7 +389,6 @@ paths: '404': description: Файл не найден - # ========== DATA ENDPOINTS TODO ========== /api/v{version}/data: post: tags: @@ -408,7 +403,6 @@ paths: - **20007** - Поиск по изображению (ImageFoundRequestHandler) **Пользователи:** - - **20008** - Авторизация через сторонние сервисы (AuthRequestHandler) - **20009** - Верификация регистрации (VerifyRegisterUserHandler) - **30014** - Информация о пользователе (UserInfoHandler) - **30016** - Верификация пользователя (UserVerificationHandler) @@ -421,7 +415,6 @@ paths: **Платежи:** - **30005** - Платежи (PaymentHandler) - - **30008** - Расчет стоимости (CostHandler) **Мониторинг и нарушения:** - **30007** - Мониторинг (MonitoringHandler) @@ -463,7 +456,7 @@ paths: $ref: '#/components/schemas/BaseRequest' examples: fileUploadInit: - summary: Инициализация загрузки файла + summary: "[20004] Инициализация загрузки файла" value: msg_id: 20004 message_body: @@ -471,35 +464,280 @@ paths: file_name: "document.pdf" file_type: "document" extension: "pdf" - convert_to: "protected" + convertTo: "protected" file_size: 1048576 fileTypes: - summary: Получение типов файлов + summary: "[20004] Получение типов файлов" value: msg_id: 20004 message_body: action: "file_types" fileExtensions: - summary: Получение расширений для типа + summary: "[20004] Получение расширений для типа" value: msg_id: 20004 message_body: action: "file_extension" file_type: "image" - companyInfo: - summary: Информация о компании + fileUploadChunks: + summary: "[20004] Статус чанков загрузки" + value: + msg_id: 20004 + message_body: + action: "chunks" + upload_id: "550e8400-e29b-41d4-a716-446655440000" + fileUploadCancel: + summary: "[20004] Отмена загрузки" + value: + msg_id: 20004 + message_body: + action: "cancel" + upload_id: "550e8400-e29b-41d4-a716-446655440000" + fileUploadProgress: + summary: "[20004] Прогресс загрузки" + value: + msg_id: 20004 + message_body: + action: "progress" + upload_id: "550e8400-e29b-41d4-a716-446655440000" + + fileInfo: + summary: "[20005] Информация о файле" + value: + msg_id: 20005 + message_body: + action: "file_info" + file_id: "550e8400-e29b-41d4-a716-446655440000" + userFilesInfo: + summary: "[20005] Статистика по файлам пользователя" + value: + msg_id: 20005 + message_body: + action: "user_files_info" + userFiles: + summary: "[20005] Список файлов пользователя" + value: + msg_id: 20005 + message_body: + action: "user_files" + page: 1 + page_size: 20 + searchFiles: + summary: "[20005] Поиск файлов с фильтрацией" + value: + msg_id: 20005 + message_body: + action: "search_files" + query: "документ" + type: "application/pdf" + statuses: ["ACTIVE", "BLOCKED"] + date_filter: "month" + sort_by: "createdAt" + sort_order: "desc" + page: 1 + page_size: 20 + storageUsage: + summary: "[20005] Использование дискового пространства" + value: + msg_id: 20005 + message_body: + action: "storage_usage" + deleteFile: + summary: "[20005] Удаление файла" + value: + msg_id: 20005 + message_body: + action: "delete_file" + file_id: "550e8400-e29b-41d4-a716-446655440000" + changePermission: + summary: "[20005] Изменение прав доступа" + value: + msg_id: 20005 + message_body: + action: "change_permission" + file_id: "550e8400-e29b-41d4-a716-446655440000" + permissions: + VIEW: true + DOWNLOAD: false + + imageSearch: + summary: "[20007] Поиск изображения" + value: + msg_id: 20007 + message_body: + file_id: "550e8400-e29b-41d4-a716-446655440000" + + verifyUser: + summary: "[20009] Верификация пользователя" + value: + msg_id: 20009 + message_body: + user_id: 123 + verify_token: "abc123def456" + + companyCreate: + summary: "[30000] Создание компании" value: msg_id: 30000 message_body: - action: "get_info" + action: "create" + company_name: "ООО Моя Компания" + company_data: + phone: "+79991234567" + email: "info@company.ru" + companyGetById: + summary: "[30000] Получение компании по ID" + value: + msg_id: 30000 + message_body: + action: "getCompany" + company_id: "company-uuid-123" + + tariffAdd: + summary: "[30001] Добавление тарифа" + value: + msg_id: 30001 + message_body: + action: "add" + type: "MONTHLY" + tariff_name: "Премиум" + tariff_price: 999.99 + + tariffInfoCreate: + summary: "[30002] Создание информации о тарифе" + value: + msg_id: 30002 + message_body: + action: "create" + tariff_id: 1 + + referralUserStats: + summary: "[30003] Статистика пользователя" + value: + msg_id: 30003 + message_body: + action: "userStats" + + paymentUserPayments: + summary: "[30005] Список платежей" + value: + msg_id: 30005 + message_body: + action: "user_payments" + email: "user@example.com" + + monitoringSet: + summary: "[30007] Установка мониторинга" + value: + msg_id: 30007 + message_body: + file_id: "550e8400-e29b-41d4-a716-446655440000" + monitoring_type: "MONITORING_DAILY" + + violationList: + summary: "[30009] Список нарушений" + value: + msg_id: 30009 + message_body: + action: "list" + page: 0 + size: 10 + + violationStats: + summary: "[30010] Статистика нарушений" + value: + msg_id: 30010 + message_body: {} + globalSearch: - summary: Глобальный поиск + summary: "[30011] Глобальный поиск" value: msg_id: 30011 message_body: query: "изображение кота" filters: file_type: "image" + + notionAdd: + summary: "[30012] Добавление заметки" + value: + msg_id: 30012 + message_body: + action: "add_notion" + violation_id: 1 + message: "Текст заметки" + + complaintCreate: + summary: "[30013] Создание жалобы" + value: + msg_id: 30013 + message_body: + action: "create" + violation_id: 1 + text: "Текст жалобы" + + userInfoGetAllPaginated: + summary: "[30014] Получить всех пользователей с пагинацией" + value: + msg_id: 30014 + message_body: + action: "getAllWithPagination" + page: 0 + size: 10 + + notificationList: + summary: "[30015] Список уведомлений" + value: + msg_id: 30015 + message_body: + action: "list" + page: 0 + size: 10 + + userVerificationVerify: + summary: "[30016] Верифицировать пользователя" + value: + msg_id: 30016 + message_body: + action: "verified" + user_id: 123 + verified: true + + lawCaseCreate: + summary: "[30017] Создать юридическое дело" + value: + msg_id: 30017 + message_body: + action: "create" + name: "Дело о нарушении" + description: "Описание дела" + priority: "HIGH" + violation_id: 1 + + tokenOpGetList: + summary: "[30018] Список операций с токенами" + value: + msg_id: 30018 + message_body: + action: "get_list" + page: 0 + size: 20 + + monitoringStatistic: + summary: "[30027] Статистика мониторинга" + value: + msg_id: 30027 + message_body: {} + + dockViewHistory: + summary: "[30028] История просмотров документов" + value: + msg_id: 30028 + message_body: + action: "history_view" + page: 0 + size: 10 + responses: '200': description: Успешный ответ @@ -509,7 +747,7 @@ paths: $ref: '#/components/schemas/BaseResponse' examples: fileUploadInitSuccess: - summary: Успешная инициализация загрузки + summary: "[20004] Успешная инициализация загрузки" value: msg_id: 20004 message_code: 0 @@ -521,26 +759,179 @@ paths: chunk_size: 209715 status: "INITIALIZED" fileTypesSuccess: - summary: Типы файлов + summary: "[20004] Типы файлов" value: msg_id: 20004 message_code: 0 message_desc: "Operation successful" message_body: - file_types: - - "IMAGE" - - "DOCUMENT" - - "AUDIO" + file_types: ["IMAGE", "DOCUMENT", "AUDIO"] count: 3 + + fileInfoSuccess: + summary: "[20005] Информация о файле" + value: + msg_id: 20005 + message_code: 0 + message_desc: "Operation successful" + message_body: + id: "550e8400-e29b-41d4-a716-446655440000" + file_name: "document.pdf" + status: "ACTIVE" + + imageSearchSuccess: + summary: "[20007] Результаты поиска изображений" + value: + msg_id: 20007 + message_code: 0 + message_desc: "Operation successful" + message_body: + images: + - url: "https://example.com/similar-image.jpg" + title: "Похожее изображение" + page: 1 + total_results: 25 + + verifySuccess: + summary: "[20009] Успешная верификация" + value: + msg_id: 20009 + message_code: 0 + message_desc: "Operation successful" + message_body: + token: "eyJhbGciOiJIUzI1NiIs..." + verified: true + email: "user@example.com" + + companyCreateSuccess: + summary: "[30000] Компания создана" + value: + msg_id: 30000 + message_code: 0 + message_desc: "Company created successfully" + message_body: + id: "company-uuid-123" + company_name: "ООО Моя Компания" + + tariffAddSuccess: + summary: "[30001] Тариф добавлен" + value: + msg_id: 30001 + message_code: 0 + message_desc: "Tariff added successfully" + message_body: + tariff_name: "Премиум" + tariff_type: "MONTHLY" + + referralUserStatsSuccess: + summary: "[30003] Статистика пользователя" + value: + msg_id: 30003 + message_code: 0 + message_desc: "Operation successful" + message_body: + total_invitees: 15 + total_earned: 5000.00 + + paymentUserPaymentsSuccess: + summary: "[30005] Список платежей" + value: + msg_id: 30005 + message_code: 0 + message_desc: "Operation successful" + message_body: + payments: + - payment_uuid: "payment-uuid-123" + amount: 999.99 + + monitoringSetSuccess: + summary: "[30007] Мониторинг установлен" + value: + msg_id: 30007 + message_code: 0 + message_desc: "Monitoring settings updated" + message_body: + file_id: "550e8400-e29b-41d4-a716-446655440000" + monitoring_type: "MONITORING_DAILY" + + violationListSuccess: + summary: "[30009] Список нарушений" + value: + msg_id: 30009 + message_code: 0 + message_desc: "Operation successful" + message_body: + violations: [] + total_elements: 25 + + globalSearchStatsSuccess: + summary: "[30011] Статистика глобального поиска" + value: + msg_id: 30011 + message_code: 0 + message_desc: "" + message_body: + total_searches: 150 + + complaintCreateSuccess: + summary: "[30013] Жалоба создана" + value: + msg_id: 30013 + message_code: 0 + message_desc: "Complaint created successfully" + message_body: + id: 1 + status: "OPEN" + + notificationListSuccess: + summary: "[30015] Список уведомлений" + value: + msg_id: 30015 + message_code: 0 + message_desc: "Operation successful" + message_body: + notifications: [] + unread_count: 5 + + lawCaseCreateSuccess: + summary: "[30017] Юридическое дело создано" + value: + msg_id: 30017 + message_code: 0 + message_desc: "Operation successful" + message_body: + id: 1 + name: "Дело о нарушении" + + tokenOpListSuccess: + summary: "[30018] Список операций с токенами" + value: + msg_id: 30018 + message_code: 0 + message_desc: "Operation successful" + message_body: + operations: [] + total_elements: 50 + + monitoringStatisticSuccess: + summary: "[30027] Статистика мониторинга" + value: + msg_id: 30027 + message_code: 0 + message_desc: "Operation successful" + message_body: + day: 10 + month: 5 + weekly: 7 + invalidMsgId: - summary: Неверный msg_id + summary: "[Common] Неверный msg_id" value: msg_id: 99999 message_code: 4 message_desc: "Message id not found" message_body: {} - # ========== FILE UPLOAD ENDPOINTS ========== /api/v{version}/files/chunk: post: tags: @@ -719,7 +1110,6 @@ paths: file_path: "/uploads/user123/doc.pdf" remaining_chunks: 2 - # ========== FILE DOWNLOAD ENDPOINTS ========== /api/v{version}/files/download/{fileId}: get: tags: @@ -763,7 +1153,7 @@ paths: type: string description: Имя файла для сохранения example: 'attachment; filename="document.pdf"' - '200-json': + '403': description: Ошибка при скачивании content: application/json: @@ -838,7 +1228,6 @@ paths: type: string format: binary - # ========== FILE SIMILARITY ENDPOINTS ========== /api/v{version}/files/{fileId}/similar: get: tags: @@ -919,7 +1308,6 @@ paths: has_previous: false - /api/check/{fileId}: get: tags: @@ -962,7 +1350,6 @@ paths: DOCUMENT: 45 AUDIO: 12 -# ========== COMPONENTS ========== components: schemas: BaseRequest: @@ -1025,42 +1412,24 @@ components: properties: action: type: string - description: | - Действие с загрузкой: - - init - инициализация загрузки - - file_types - получение доступных типов файлов - - file_extension - получение расширений для типа - - chunks - статус чанков - - cancel - отмена загрузки - - progress - прогресс загрузки enum: [init, file_types, file_extension, chunks, cancel, progress] example: init file_name: type: string - description: Имя файла (для action=init) example: "document.pdf" file_type: type: string - description: Тип файла (image, document, audio) enum: [IMAGE, DOCUMENT, AUDIO] - example: DOCUMENT extension: type: string - description: Расширение файла - example: "pdf" convert_to: type: string - description: Формат конвертации - example: "protected" file_size: type: integer format: int64 - description: Размер файла в байтах - example: 1048576 upload_id: type: string format: uuid - description: ID сессии загрузки (для action=cancel, chunks, progress) InitFileResponse: type: object @@ -1068,20 +1437,14 @@ components: upload_id: type: string format: uuid - description: ID сессии загрузки file_name: type: string - description: Имя файла total_chunks: type: integer - description: Общее количество чанков chunk_size: type: integer - description: Размер одного чанка в байтах status: type: string - description: Статус загрузки - example: "INITIALIZED" ChunkUploadResponse: type: object @@ -1162,10 +1525,8 @@ components: type: array items: type: string - example: ["IMAGE", "DOCUMENT", "AUDIO"] count: type: integer - example: 3 FileExtensionResponse: type: object @@ -1174,13 +1535,11 @@ components: type: array items: type: string - example: ["jpg", "jpeg", "png", "gif"] count: type: integer max_file_size: type: integer format: int64 - description: Максимальный размер файла в байтах CanceledUploadResponse: type: object diff --git a/infrastructure/open-api-key-controller.yaml b/infrastructure/open-api-key-controller.yaml new file mode 100644 index 0000000..b8f9a23 --- /dev/null +++ b/infrastructure/open-api-key-controller.yaml @@ -0,0 +1,350 @@ +openapi: 3.0.3 +info: + title: NoCopy API - API Keys + description: API для управления пользовательскими API ключами + version: 1.0.0 + contact: + name: NoCopy + +servers: + - url: http://localhost:8080 + description: Локальный + - url: https://dev-workspace.not-copy.com/ + description: Дев + +tags: + - name: User + description: Управление пользовательскими данными и API ключами + +paths: + /api/user/api-keys: + post: + tags: + - User + summary: Создание API ключа + description: | + Создаёт новый API ключ для пользователя. + - Требуется авторизация (Bearer токен) + - Если имя не указано, будет присвоено "Unnamed key" + - Возвращает полный ключ только один раз при создании + - Префикс ключа можно использовать для идентификации без раскрытия секрета + operationId: createApiKey + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + name: + type: string + description: Название ключа для идентификации (опционально) + example: "My API Key" + maxLength: 255 + examples: + withName: + summary: С указанием названия + value: + name: "Production Key" + withDescription: + summary: С описательным названием + value: + name: "Key for mobile app" + withoutName: + summary: Без названия (по умолчанию "Unnamed key") + value: {} + minimalExample: + summary: Пустое тело запроса + value: {} + responses: + '200': + description: Ключ успешно создан + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + success: + summary: API ключ создан + value: + msg_id: null + message_code: 0 + message_desc: "API key created successfully" + message_body: + apiKey: "sk-live-abc123def456789ghi012jkl345mno678" + successWithDescription: + summary: API ключ с описанием создан + value: + msg_id: null + message_code: 0 + message_desc: "API key created successfully" + message_body: + apiKey: "sk-test-xyz987abc654def321ghi098jkl765mno" + '401': + description: Неавторизованный доступ + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + unauthorized: + summary: Токен не предоставлен или недействителен + value: + msg_id: null + message_code: 7 + message_desc: "Authentication required" + message_body: null + + get: + tags: + - User + summary: Получение списка API ключей + description: | + Возвращает все API ключи текущего пользователя. + + **Особенности:** + - Требуется авторизация (Bearer токен) + - Полные ключи не возвращаются, только префиксы + - Включает информацию об активности и времени использования + operationId: listApiKeys + security: + - BearerAuth: [] + responses: + '200': + description: Список ключей пользователя + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + success: + summary: Список с несколькими ключами + value: + msg_id: null + message_code: 0 + message_desc: null + message_body: + - id: 1 + name: "Production Key" + prefix: "sk-live-abc123..." + isActive: true + createdAt: "2025-01-15T10:30:00Z" + lastUsedAt: "2025-06-30T14:22:00Z" + - id: 2 + name: "Key for mobile app" + prefix: "sk-live-def456..." + isActive: true + createdAt: "2025-03-20T08:00:00Z" + lastUsedAt: "2025-06-29T18:45:00Z" + - id: 3 + name: "Old Development Key" + prefix: "sk-test-ghi789..." + isActive: false + createdAt: "2025-02-10T12:00:00Z" + lastUsedAt: "2025-05-15T09:30:00Z" + singleKey: + summary: Один активный ключ + value: + msg_id: null + message_code: 0 + message_desc: null + message_body: + - id: 1 + name: "My API Key" + prefix: "sk-live-abc123..." + isActive: true + createdAt: "2025-06-01T00:00:00Z" + lastUsedAt: null + empty: + summary: Нет созданных ключей + value: + msg_id: null + message_code: 0 + message_desc: null + message_body: [] + '401': + description: Неавторизованный доступ + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + unauthorized: + summary: Токен не предоставлен или недействителен + value: + msg_id: null + message_code: 7 + message_desc: "Authentication required" + message_body: null + + /api/user/api-keys/{keyId}: + delete: + tags: + - User + summary: Отзыв (удаление) API ключа + description: | + Деактивирует API ключ пользователя. Ключ становится неактивным и больше не может использоваться. + + **Особенности:** + - Требуется авторизация (Bearer токен) + - Пользователь может отозвать только свои ключи + - Отозванный ключ нельзя восстановить (нужно создавать новый) + operationId: revokeApiKey + security: + - BearerAuth: [] + parameters: + - name: keyId + in: path + required: true + schema: + type: integer + format: int64 + description: ID ключа для отзыва + example: 1 + responses: + '200': + description: Ключ успешно отозван + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + success: + summary: Ключ отозван + value: + msg_id: null + message_code: 0 + message_desc: null + message_body: null + '401': + description: Неавторизованный доступ + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + unauthorized: + summary: Токен не предоставлен или недействителен + value: + msg_id: null + message_code: 7 + message_desc: "Authentication required" + message_body: null + '403': + description: Доступ запрещён (ключ не принадлежит пользователю) + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + forbidden: + summary: Ключ принадлежит другому пользователю + value: + msg_id: null + message_code: 6 + message_desc: "Access denied" + message_body: null + '404': + description: Ключ не найден + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + examples: + notFound: + summary: Ключ с указанным ID не существует + value: + msg_id: null + message_code: 4 + message_desc: "API key not found" + message_body: + keyId: 999 + +components: + schemas: + BaseResponse: + type: object + properties: + msg_id: + type: integer + description: Идентификатор сообщения (может быть null) + nullable: true + example: null + message_code: + type: integer + description: | + Код результата: + - 0 - Успешно + - 4 - Ресурс не найден + - 6 - Доступ запрещён + - 7 - Требуется авторизация + example: 0 + message_desc: + type: string + description: Описание результата операции (может быть null) + nullable: true + example: "API key created successfully" + message_body: + description: Данные ответа + nullable: true + oneOf: + - type: object + properties: + apiKey: + type: string + description: Полный API ключ (только при создании) + example: "sk-live-abc123def456..." + description: Ответ при создании ключа + - type: array + items: + $ref: '#/components/schemas/ApiKeyInfo' + description: Список ключей пользователя + - type: object + description: Пустой объект или null + nullable: true + example: null + + ApiKeyInfo: + type: object + description: Информация об API ключе + properties: + id: + type: integer + format: int64 + description: Уникальный идентификатор ключа + example: 1 + name: + type: string + description: Название ключа + example: "Production Key" + prefix: + type: string + description: Префикс ключа для идентификации + example: "sk-live-abc123..." + isActive: + type: boolean + description: Активен ли ключ + example: true + createdAt: + type: string + format: date-time + description: Дата и время создания ключа + example: "2025-01-15T10:30:00Z" + lastUsedAt: + type: string + format: date-time + nullable: true + description: Дата и время последнего использования (null если не использовался) + example: "2025-06-30T14:22:00Z" + + securitySchemes: + BearerAuth: + type: http + scheme: bearer + bearerFormat: JWT + description: JWT токен для авторизации (получить через /api/auth) + +security: + - BearerAuth: [] \ No newline at end of file diff --git a/infrastructure/support-controller.yaml b/infrastructure/support-controller.yaml new file mode 100644 index 0000000..5965a1c --- /dev/null +++ b/infrastructure/support-controller.yaml @@ -0,0 +1,1410 @@ +openapi: 3.0.3 +info: + title: NoCopy API - Files, Payments, Payouts, Search, User + description: | + API для работы с файлами, платежами, выплатами, поиском и пользователями. + Включает контроллеры: + - FileController + - GlobalSearchController + - PaymentController + - PayoutController + - SearchSettingsController + - UserController + version: 1.0.0 + contact: + name: NoCopy + +servers: + - url: http://localhost:8080 + description: Локальный + - url: https://dev-workspace.not-copy.com/ + description: Дев + +tags: + - name: Files + description: Работа с файлами (публичный доступ, защита, проверка) + - name: Search + description: Глобальный поиск и настройки поисковых систем + - name: Payments + description: Платежи и управление методами оплаты + - name: Payouts + description: Выплаты и управление методами выплат + - name: User + description: Управление пользователями и профилем + +paths: + /api/files/public/{fileId}: + get: + tags: + - Files + summary: Публичное получение файла + description: | + Получение файла по ID без авторизации. + Поддерживает стриминг для больших файлов. + operationId: getPublicFile + parameters: + - name: fileId + in: path + required: true + schema: + type: string + description: ID файла + responses: + '200': + description: Файл + content: + application/octet-stream: + schema: + type: string + format: binary + image/jpeg: + schema: + type: string + format: binary + image/png: + schema: + type: string + format: binary + application/pdf: + schema: + type: string + format: binary + headers: + Content-Disposition: + schema: + type: string + description: Имя файла + example: 'inline; filename="document.pdf"' + Cache-Control: + schema: + type: string + example: "public, max-age=3600" + '404': + description: Файл не найден + '500': + description: Внутренняя ошибка сервера + + /api/files/public/file-info/{fileId}: + get: + tags: + - Files + summary: Публичная информация о файле + description: Получение метаданных файла по ID без авторизации + operationId: getPublicFileInfo + parameters: + - name: fileId + in: path + required: true + schema: + type: string + description: ID файла + responses: + '200': + description: Информация о файле + content: + application/json: + schema: + $ref: '#/components/schemas/FileEntityResponse' + '404': + description: Файл не найден + + /api/files/protected/{fileId}/{type}: + get: + tags: + - Files + summary: Получение защищённого файла + description: | + Получение защищённого файла или его миниатюры. + Доступен только для защищённых файлов. + operationId: getProtectedFile + parameters: + - name: fileId + in: path + required: true + schema: + type: string + description: ID файла + - name: type + in: path + required: true + schema: + type: string + enum: [file, thumbnail] + description: Тип файла (file или thumbnail) + example: file + responses: + '200': + description: Защищённый файл или миниатюра + content: + application/octet-stream: + schema: + type: string + format: binary + image/jpeg: + schema: + type: string + format: binary + image/png: + schema: + type: string + format: binary + headers: + Content-Disposition: + schema: + type: string + example: 'inline; filename*=UTF-8''''document_nocopy_protected.pdf' + '404': + description: Файл не найден + '500': + description: Файл не защищён или ошибка обработки + + /api/files/public/{fileId}/{type}: + get: + tags: + - Files + summary: Публичное получение файла с типом + description: Получение файла или миниатюры по ID и типу + operationId: getPublicFileWithType + parameters: + - name: fileId + in: path + required: true + schema: + type: string + description: ID файла + - name: type + in: path + required: true + schema: + type: string + enum: [file, thumbnail] + description: Тип файла (file или thumbnail) + responses: + '200': + description: Файл или миниатюра + content: + application/octet-stream: + schema: + type: string + format: binary + '404': + description: Файл не найден + + /api/files/check-file/status/{userId}: + get: + tags: + - Files + summary: Статус проверки файлов пользователя + description: Получение текущего статуса лимитов проверки файлов + operationId: getCheckStatus + parameters: + - name: userId + in: path + required: true + schema: + type: integer + format: int64 + description: ID пользователя + responses: + '200': + description: Статус проверки + content: + application/json: + schema: + $ref: '#/components/schemas/CheckStatus' + + /api/files/check-file/update-limit/{userId}/{limit}: + post: + tags: + - Files + summary: Обновление лимита проверок + description: Обновление лимита проверок файлов для пользователя + operationId: updateCheckLimit + parameters: + - name: userId + in: path + required: true + schema: + type: integer + format: int64 + description: ID пользователя + - name: limit + in: path + required: true + schema: + type: integer + description: Новый лимит проверок + responses: + '200': + description: Лимит обновлён + content: + application/json: + schema: + $ref: '#/components/schemas/ProtectedFileCheck' + + /api/files/protect/{fileId}/{convertTo}: + post: + tags: + - Files + summary: Защита файла + description: Запуск процесса защиты файла с конвертацией в указанный формат + operationId: protectFile + parameters: + - name: fileId + in: path + required: true + schema: + type: string + description: ID файла + - name: convertTo + in: path + required: true + schema: + type: string + description: Формат конвертации (например, protected) + example: protected + responses: + '200': + description: Информация о защите файла + content: + application/json: + schema: + $ref: '#/components/schemas/FileInfo' + + /api/files/download/user-passport/archive/{userId}: + get: + tags: + - Files + summary: Скачивание архива паспорта + description: Сборка и скачивание ZIP-архива с данными паспорта пользователя + operationId: downloadPassportZip + parameters: + - name: userId + in: path + required: true + schema: + type: integer + format: int64 + description: ID пользователя + responses: + '200': + description: ZIP архив + content: + application/zip: + schema: + type: string + format: binary + headers: + Content-Disposition: + schema: + type: string + example: 'attachment; filename=passport_123.zip' + '500': + description: Ошибка сборки архива + + /api/v1/global-search/start: + post: + tags: + - Search + summary: Запуск глобального поиска + description: Запуск задачи глобального поиска по файлам пользователя + operationId: startGlobalSearch + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalSearchStartRequest' + responses: + '200': + description: Задача поиска создана или файлы не найдены + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/GlobalSearchStartResponse' + - type: string + example: "Files for search not found" + + /api/v1/global-search/actual-task: + get: + tags: + - Search + summary: Получение активной задачи поиска + description: Получение текущей активной (PROCESSING) задачи поиска пользователя + operationId: getActualSearchTask + security: + - BearerAuth: [] + responses: + '200': + description: Активная задача или сообщение об отсутствии + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/GlobalSearchTask' + - type: string + example: "Task not found" + + /api/v1/global-search/violation-summary: + get: + tags: + - Search + summary: Сводка по нарушениям + description: Получение сводки по нарушениям для файлов пользователя + operationId: getViolationSummary + security: + - BearerAuth: [] + responses: + '200': + description: Сводка по нарушениям + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/FileViolationSummaryDTO' + + /api/v1/global-search/violation-summary-with-files: + post: + tags: + - Search + summary: Сводка по нарушениям с пагинацией + description: Получение сводки по нарушениям с фильтрацией и пагинацией + operationId: getViolationSummaryWithFiles + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + file_name: + type: string + sort_direction: + type: string + enum: [asc, desc] + page: + type: integer + size: + type: integer + start_date: + type: string + end_date: + type: string + responses: + '200': + description: Сводка по нарушениям с пагинацией + content: + application/json: + schema: + type: object + properties: + content: + type: array + items: + $ref: '#/components/schemas/FileViolationSummaryDTO' + total_elements: + type: integer + total_pages: + type: integer + number: + type: integer + size: + type: integer + + /api/v1/global-search/status/{taskId}: + get: + tags: + - Search + summary: Статус задачи поиска + description: Получение статуса и прогресса задачи глобального поиска + operationId: getSearchTaskStatus + security: + - BearerAuth: [] + parameters: + - name: taskId + in: path + required: true + schema: + type: string + description: ID задачи поиска + responses: + '200': + description: Статус задачи + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/GlobalSearchStatusResponse' + - type: string + example: "Task not found" + + /api/payments/create: + post: + tags: + - Payments + summary: Создание платежа + description: Создание нового платежа для пользователя + operationId: createPayment + parameters: + - name: email + in: query + required: true + schema: + type: string + description: Email пользователя + - name: tariffId + in: query + required: true + schema: + type: integer + format: int64 + description: ID тарифа + - name: operationType + in: query + required: true + schema: + type: string + description: Тип операции + - name: operationUuid + in: query + required: true + schema: + type: string + description: UUID операции + responses: + '200': + description: Платёж создан + content: + application/json: + schema: + $ref: '#/components/schemas/Payment' + '404': + description: Тариф или пользователь не найден + + /api/payments/webhook/yookassa: + post: + tags: + - Payments + summary: Webhook ЮKassa + description: Обработка уведомлений от ЮKassa + operationId: handleYooKassaNotification + requestBody: + required: true + content: + application/json: + schema: + type: object + responses: + '200': + description: Уведомление обработано + + /api/payments/auto-renewal: + post: + tags: + - Payments + summary: Управление автопродлением + description: Включение или отключение автопродления подписки + operationId: setAutoRenewal + security: + - BearerAuth: [] + parameters: + - name: renewal + in: query + required: true + schema: + type: boolean + description: Включить (true) или отключить (false) автопродление + responses: + '200': + description: Статус автопродления изменён + content: + application/json: + schema: + type: object + properties: + message: + type: string + '404': + description: Пользователь не найден + + /api/payments/methods: + get: + tags: + - Payments + summary: Список методов оплаты + description: Получение сохранённых методов оплаты пользователя + operationId: getPaymentMethods + security: + - BearerAuth: [] + responses: + '200': + description: Список методов оплаты + content: + application/json: + schema: + type: array + items: + type: object + '404': + description: Пользователь не найден + + /api/payments/methods/{paymentMethodId}: + delete: + tags: + - Payments + summary: Удаление метода оплаты + description: Удаление сохранённого метода оплаты + operationId: deletePaymentMethod + security: + - BearerAuth: [] + parameters: + - name: paymentMethodId + in: path + required: true + schema: + type: string + description: ID метода оплаты + responses: + '200': + description: Метод оплаты удалён + content: + application/json: + schema: + type: object + properties: + message: + type: string + '404': + description: Пользователь не найден + + /api/payouts/create-request: + post: + tags: + - Payouts + summary: Создание заявки на выплату + description: Создание новой заявки на выплату средств + operationId: createPayoutRequest + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PayoutRequestDTO' + responses: + '201': + description: Заявка создана + content: + application/json: + schema: + $ref: '#/components/schemas/PayoutRequest' + '404': + description: Пользователь не найден + '409': + description: Недостаточно средств, уже есть активная заявка или неверный метод выплаты + + /api/payouts/requests: + get: + tags: + - Payouts + summary: Список заявок на выплату + description: Получение всех заявок на выплату пользователя + operationId: getUserPayoutRequests + security: + - BearerAuth: [] + responses: + '200': + description: Список заявок + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PayoutRequest' + '404': + description: Пользователь не найден + + /api/payouts/requests/{requestId}: + get: + tags: + - Payouts + summary: Получение заявки по ID + description: Получение конкретной заявки на выплату + operationId: getPayoutRequest + security: + - BearerAuth: [] + parameters: + - name: requestId + in: path + required: true + schema: + type: integer + format: int64 + description: ID заявки + responses: + '200': + description: Заявка найдена + content: + application/json: + schema: + $ref: '#/components/schemas/PayoutRequest' + '404': + description: Пользователь не найден + + /api/payouts/requests/{requestId}/process: + post: + tags: + - Payouts + summary: Обработка заявки на выплату + description: Запуск обработки заявки на выплату (административное действие) + operationId: processPayoutRequest + parameters: + - name: requestId + in: path + required: true + schema: + type: integer + format: int64 + description: ID заявки + responses: + '200': + description: Заявка обработана + content: + application/json: + schema: + $ref: '#/components/schemas/PayoutRequest' + + /api/payouts/requests/{requestId}/cancel: + post: + tags: + - Payouts + summary: Отмена заявки на выплату + description: Отмена заявки на выплату пользователем + operationId: cancelPayoutRequest + security: + - BearerAuth: [] + parameters: + - name: requestId + in: path + required: true + schema: + type: integer + format: int64 + description: ID заявки + responses: + '200': + description: Заявка отменена + content: + application/json: + schema: + $ref: '#/components/schemas/PayoutRequest' + '404': + description: Пользователь не найден + + /api/payouts/user/payout-methods: + get: + tags: + - Payouts + summary: Методы выплат пользователя + description: Получение сохранённых методов выплат пользователя + operationId: getUserPayoutMethods + security: + - BearerAuth: [] + responses: + '200': + description: Список методов выплат + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PayoutMethodDTO' + '404': + description: Пользователь не найден + + /api/payouts/payout-methods: + get: + tags: + - Payouts + summary: Доступные типы методов выплат + description: Получение списка доступных типов методов выплат + operationId: getAvailablePayoutMethodTypes + responses: + '200': + description: Список типов методов выплат + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PayoutMethodTypeDTO' + + /api/payouts/payout-method/card: + post: + tags: + - Payouts + summary: Добавление карты для выплат + description: Добавление банковской карты как метода выплаты + operationId: addCardPayoutMethod + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddCardRequest' + responses: + '201': + description: Карта добавлена + content: + application/json: + schema: + $ref: '#/components/schemas/PayoutMethodDTO' + '404': + description: Пользователь не найден + + /api/payouts/payout-method/bank-transfer: + post: + tags: + - Payouts + summary: Добавление банковского перевода для выплат + description: Добавление банковского счёта как метода выплаты + operationId: addBankTransferPayoutMethod + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/AddBankTransferRequest' + responses: + '201': + description: Банковский перевод добавлен + content: + application/json: + schema: + $ref: '#/components/schemas/PayoutMethodDTO' + '404': + description: Пользователь не найден + + /api/payouts/payout-method/{methodId}/default: + put: + tags: + - Payouts + summary: Установка метода выплаты по умолчанию + description: Установка указанного метода выплаты как основного + operationId: setDefaultPayoutMethod + security: + - BearerAuth: [] + parameters: + - name: methodId + in: path + required: true + schema: + type: integer + format: int64 + description: ID метода выплаты + responses: + '200': + description: Метод установлен по умолчанию + '404': + description: Пользователь не найден + + /api/search/settings: + get: + tags: + - Search + summary: Получение настроек поиска + description: Получение текущих настроек поисковых систем и прокси + operationId: getSearchSettings + responses: + '200': + description: Настройки поиска + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + + put: + tags: + - Search + summary: Обновление настроек поиска + description: Обновление настроек поисковых систем и прокси + operationId: updateSearchSettings + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SearchSettingsDto' + responses: + '200': + description: Настройки обновлены + content: + application/json: + schema: + $ref: '#/components/schemas/BaseResponse' + + /v1/api/user: + get: + tags: + - User + summary: Получение информации о пользователе + description: Получение полной информации о пользователе по email + operationId: getUserByEmail + parameters: + - name: email + in: query + required: true + schema: + type: string + description: Email пользователя + responses: + '200': + description: Информация о пользователе + content: + application/json: + schema: + $ref: '#/components/schemas/UserDTO' + '404': + description: Пользователь не найден + + patch: + tags: + - User + summary: Обновление пользователя + description: Частичное обновление данных пользователя + operationId: updateUser + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UserRequest' + responses: + '200': + description: Пользователь обновлён + content: + application/json: + schema: + $ref: '#/components/schemas/UserDTO' + + /v1/api/user/change-password: + post: + tags: + - User + summary: Смена пароля + description: Смена пароля пользователя + operationId: changePassword + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ChangePasswordRequest' + responses: + '200': + description: Пароль изменён + content: + application/json: + schema: + $ref: '#/components/schemas/UserDTO' + + /v1/api/user/create-user: + post: + tags: + - User + summary: Создание пользователя + description: Создание нового пользователя (административное действие) + operationId: createUser + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RegRequest' + responses: + '200': + description: Пользователь создан + content: + application/json: + schema: + type: object + properties: + user: + type: object + token: + type: string + + /v1/api/user/delete-user/{userId}: + delete: + tags: + - User + summary: Удаление пользователя + description: Удаление пользователя по ID + operationId: deleteUser + parameters: + - name: userId + in: path + required: true + schema: + type: integer + format: int64 + description: ID пользователя + responses: + '200': + description: Пользователь удалён + content: + application/json: + schema: + type: object + properties: + userId: + type: integer + deleted: + type: string + example: "true" + +components: + schemas: + BaseResponse: + type: object + properties: + msg_id: + type: integer + message_code: + type: integer + message_desc: + type: string + message_body: + type: object + + FileEntityResponse: + type: object + properties: + id: + type: string + user_id: + type: integer + format: int64 + original_file_name: + type: string + stored_file_name: + type: string + file_path: + type: string + protected_file_path: + type: string + thumbnail_file_url: + type: string + file_size: + type: integer + format: int64 + mime_type: + type: string + file_extension: + type: string + checksum: + type: string + upload_session_id: + type: string + status: + type: string + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + formatted_size: + type: string + download_url: + type: string + exists_on_disk: + type: boolean + support_id: + type: integer + protect_status: + type: string + owner_name: + type: string + owner_email: + type: string + owner_company: + type: string + file_name: + type: string + file_format: + type: string + checks_count: + type: integer + file_upload_date: + type: string + format: date-time + monitoring: + type: string + permissions: + type: object + appeal_infos: + type: array + items: + type: object + + CheckStatus: + type: object + properties: + checks_today: + type: integer + checks_limit: + type: integer + can_check: + type: boolean + + ProtectedFileCheck: + type: object + properties: + id: + type: integer + user_id: + type: integer + checks_today: + type: integer + checks_limit: + type: integer + last_check_date: + type: string + format: date-time + + FileInfo: + type: object + properties: + id: + type: string + file_name: + type: string + file_path: + type: string + mime_type: + type: string + + GlobalSearchStartRequest: + type: object + properties: + search_type: + type: string + file_types: + type: array + items: + type: string + date_from: + type: string + date_to: + type: string + + GlobalSearchStartResponse: + type: object + properties: + task_id: + type: string + status: + type: string + total_files: + type: integer + + GlobalSearchTask: + type: object + properties: + task_id: + type: string + status: + type: string + total_files: + type: integer + processed_files: + type: integer + created_at: + type: string + format: date-time + + GlobalSearchStatusResponse: + type: object + properties: + task_id: + type: string + status: + type: string + search_type: + type: string + progress: + type: integer + + FileViolationSummaryDTO: + type: object + properties: + file_id: + type: string + support_id: + type: integer + file_name: + type: string + file_size: + type: integer + format: int64 + mime_type: + type: string + status: + type: string + created_at: + type: string + format: date-time + violation_count: + type: integer + format: int64 + count_law_case: + type: integer + format: int64 + count_complaint: + type: integer + format: int64 + latest_violation_date: + type: string + format: date-time + + Payment: + type: object + properties: + id: + type: integer + format: int64 + status: + type: string + payment_uuid: + type: string + amount: + type: number + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + operation_type: + type: string + + PayoutRequestDTO: + type: object + properties: + amount: + type: number + payout_method_id: + type: integer + format: int64 + payout_type: + type: string + + PayoutRequest: + type: object + properties: + id: + type: integer + format: int64 + amount: + type: number + status: + type: string + created_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + + PayoutMethodDTO: + type: object + properties: + id: + type: integer + format: int64 + type: + type: string + display_name: + type: string + masked_details: + type: string + card_number: + type: string + is_default: + type: boolean + is_verified: + type: boolean + + PayoutMethodTypeDTO: + type: object + properties: + code: + type: string + name: + type: string + + AddCardRequest: + type: object + properties: + card_number: + type: string + card_holder: + type: string + expiry_date: + type: string + + AddBankTransferRequest: + type: object + properties: + bank_name: + type: string + bic: + type: string + correspondent_account: + type: string + account_number: + type: string + account_holder: + type: string + inn: + type: string + kpp: + type: string + + SearchSettingsDto: + type: object + properties: + engines: + type: object + additionalProperties: + type: boolean + example: + yandex: true + google: true + proxy_enabled: + type: boolean + + UserDTO: + type: object + properties: + id: + type: integer + format: int64 + email: + type: string + full_name: + type: string + phone: + type: string + verified_status: + type: string + active: + type: boolean + company: + type: string + tariffs: + type: array + items: + type: object + tariff_info: + $ref: '#/components/schemas/TariffInfoDTO' + gender_type: + type: string + birthday: + type: string + created_at: + type: string + format: date-time + permission: + type: object + + TariffInfoDTO: + type: object + properties: + id: + type: string + status: + type: string + start_tariff: + type: string + format: date-time + end_tariff: + type: string + format: date-time + tariff_id: + type: integer + format: int64 + tariff_name: + type: string + tokens: + type: integer + max_file_on_disk: + type: integer + format: int64 + current_file_on_disk: + type: integer + format: int64 + current_file_counts: + type: integer + max_file_counts: + type: integer + + UserRequest: + type: object + properties: + full_name: + type: string + phone: + type: string + gender_type: + type: string + birthday: + type: string + + ChangePasswordRequest: + type: object + properties: + email: + type: string + old_password: + type: string + new_password: + type: string + + RegRequest: + type: object + properties: + full_name: + type: string + email: + type: string + password: + type: string + phone: + type: string + + securitySchemes: + BearerAuth: + type: http + scheme: bearer + bearerFormat: JWT + description: JWT токен для авторизации + +security: + - BearerAuth: [] \ No newline at end of file