feat: add DocumentBatchCreateAPI for batch document creation
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run

This commit is contained in:
CaptainB 2025-04-30 18:18:56 +08:00
parent ee2ac7835c
commit ba5028858c
2 changed files with 34 additions and 5 deletions

View File

@ -4,7 +4,7 @@ from drf_spectacular.utils import OpenApiParameter
from common.mixins.api_mixin import APIMixin
from common.result import DefaultResultSerializer
from knowledge.serializers.common import BatchSerializer
from knowledge.serializers.document import DocumentCreateRequest
from knowledge.serializers.document import DocumentCreateRequest, DocumentInstanceSerializer
class DocumentCreateAPI(APIMixin):
@ -98,3 +98,32 @@ class DocumentBatchAPI(APIMixin):
@staticmethod
def get_response():
return DefaultResultSerializer
class DocumentBatchCreateAPI(APIMixin):
@staticmethod
def get_parameters():
return [
OpenApiParameter(
name="workspace_id",
description="工作空间id",
type=OpenApiTypes.STR,
location='path',
required=True,
),
OpenApiParameter(
name="knowledge_id",
description="知识库id",
type=OpenApiTypes.STR,
location='path',
required=True,
),
]
@staticmethod
def get_request():
return DocumentInstanceSerializer(many=True)
@staticmethod
def get_response():
return DefaultResultSerializer

View File

@ -8,7 +8,7 @@ from common.auth import TokenAuth
from common.auth.authentication import has_permissions
from common.constants.permission_constants import PermissionConstants
from common.result import result
from knowledge.api.document import DocumentSplitAPI, DocumentBatchAPI
from knowledge.api.document import DocumentSplitAPI, DocumentBatchAPI, DocumentBatchCreateAPI
from knowledge.api.knowledge import KnowledgeTreeReadAPI
from knowledge.serializers.document import DocumentSerializers
from knowledge.serializers.knowledge import KnowledgeSerializer
@ -76,9 +76,9 @@ class DocumentView(APIView):
methods=['POST'],
description=_('Create documents in batches'),
operation_id=_('Create documents in batches'),
request=DocumentBatchAPI.get_request(),
parameters=DocumentBatchAPI.get_parameters(),
responses=DocumentBatchAPI.get_response(),
request=DocumentBatchCreateAPI.get_request(),
parameters=DocumentBatchCreateAPI.get_parameters(),
responses=DocumentBatchCreateAPI.get_response(),
tags=[_('Knowledge Base/Documentation')]
)
@has_permissions([