mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
feat: update document and paragraph batch operations to use PUT method and rename classes for clarity
This commit is contained in:
parent
a04c2efa41
commit
ecc25796a6
|
|
@ -11,7 +11,9 @@ urlpatterns = [
|
|||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document', views.DocumentView.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/split', views.DocumentView.Split.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/split_pattern', views.DocumentView.SplitPattern.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/batch', views.DocumentView.Batch.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/batch_create', views.DocumentView.BatchCreate.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/batch_sync', views.DocumentView.BatchSync.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/batch_delete', views.DocumentView.BatchDelete.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/web', views.WebDocumentView.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/qa', views.QaDocumentView.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/table', views.TableDocumentView.as_view()),
|
||||
|
|
@ -20,9 +22,9 @@ urlpatterns = [
|
|||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/sync', views.DocumentView.SyncWeb.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/refresh', views.DocumentView.Refresh.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/cancel_task', views.DocumentView.CancelTask.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/cancel_task/batch', views.DocumentView.BatchCancelTask.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/batch_cancel_task', views.DocumentView.BatchCancelTask.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph', views.ParagraphView.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/batch', views.ParagraphView.Batch.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/batch_delete', views.ParagraphView.BatchDelete.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<str:paragraph_id>', views.ParagraphView.Operate.as_view()),
|
||||
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<str:paragraph_id>/problem', views.ParagraphView.Problem.as_view()),
|
||||
path( 'workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<str:document_id>/paragraph/<int:current_page>/<int:page_size>', views.ParagraphView.Page.as_view()),
|
||||
|
|
|
|||
|
|
@ -248,11 +248,11 @@ class DocumentView(APIView):
|
|||
'knowledge_id': knowledge_id, 'workspace_id': workspace_id}
|
||||
).batch_cancel(request.data))
|
||||
|
||||
class Batch(APIView):
|
||||
class BatchCreate(APIView):
|
||||
authentication_classes = [TokenAuth]
|
||||
|
||||
@extend_schema(
|
||||
methods=['POST'],
|
||||
methods=['PUT'],
|
||||
description=_('Create documents in batches'),
|
||||
summary=_('Create documents in batches'),
|
||||
operation_id=_('Create documents in batches'),
|
||||
|
|
@ -265,11 +265,14 @@ class DocumentView(APIView):
|
|||
PermissionConstants.DOCUMENT_CREATE.get_workspace_permission(),
|
||||
PermissionConstants.DOCUMENT_EDIT.get_workspace_permission(),
|
||||
])
|
||||
def post(self, request: Request, workspace_id: str, knowledge_id: str):
|
||||
def put(self, request: Request, workspace_id: str, knowledge_id: str):
|
||||
return result.success(DocumentSerializers.Batch(
|
||||
data={'knowledge_id': knowledge_id, 'workspace_id': workspace_id}
|
||||
).batch_save(request.data))
|
||||
|
||||
class BatchSync(APIView):
|
||||
authentication_classes = [TokenAuth]
|
||||
|
||||
@extend_schema(
|
||||
methods=['PUT'],
|
||||
description=_('Batch sync documents'),
|
||||
|
|
@ -289,8 +292,11 @@ class DocumentView(APIView):
|
|||
data={'knowledge_id': knowledge_id, 'workspace_id': workspace_id}
|
||||
).batch_sync(request.data))
|
||||
|
||||
class BatchDelete(APIView):
|
||||
authentication_classes = [TokenAuth]
|
||||
|
||||
@extend_schema(
|
||||
methods=['DELETE'],
|
||||
methods=['PUT'],
|
||||
description=_('Delete documents in batches'),
|
||||
summary=_('Delete documents in batches'),
|
||||
operation_id=_('Delete documents in batches'),
|
||||
|
|
@ -303,7 +309,7 @@ class DocumentView(APIView):
|
|||
PermissionConstants.DOCUMENT_CREATE.get_workspace_permission(),
|
||||
PermissionConstants.DOCUMENT_EDIT.get_workspace_permission(),
|
||||
])
|
||||
def delete(self, request: Request, workspace_id: str, knowledge_id: str):
|
||||
def put(self, request: Request, workspace_id: str, knowledge_id: str):
|
||||
return result.success(DocumentSerializers.Batch(
|
||||
data={'workspace_id': workspace_id, 'knowledge_id': knowledge_id}
|
||||
).batch_delete(request.data))
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ class ParagraphView(APIView):
|
|||
data={'workspace_id': workspace_id, 'knowledge_id': knowledge_id, 'document_id': document_id}
|
||||
).save(request.data))
|
||||
|
||||
class Batch(APIView):
|
||||
class BatchDelete(APIView):
|
||||
authentication_classes = [TokenAuth]
|
||||
|
||||
@extend_schema(
|
||||
methods=['DELETE'],
|
||||
methods=['PUT'],
|
||||
summary=_('Batch Paragraph'),
|
||||
description=_('Batch Paragraph'),
|
||||
operation_id=_('Batch Paragraph'),
|
||||
|
|
@ -65,7 +65,7 @@ class ParagraphView(APIView):
|
|||
tags=[_('Knowledge Base/Documentation/Paragraph')]
|
||||
)
|
||||
@has_permissions(PermissionConstants.DOCUMENT_EDIT.get_workspace_permission())
|
||||
def delete(self, request: Request, workspace_id: str, knowledge_id: str, document_id: str):
|
||||
def put(self, request: Request, workspace_id: str, knowledge_id: str, document_id: str):
|
||||
return result.success(ParagraphSerializers.Batch(
|
||||
data={'workspace_id': workspace_id, 'knowledge_id': knowledge_id, 'document_id': document_id}
|
||||
).batch_delete(request.data))
|
||||
|
|
|
|||
Loading…
Reference in New Issue