diff --git a/apps/knowledge/urls.py b/apps/knowledge/urls.py index 5ff968dc7..660aeb68e 100644 --- a/apps/knowledge/urls.py +++ b/apps/knowledge/urls.py @@ -11,7 +11,9 @@ urlpatterns = [ path('workspace//knowledge//document', views.DocumentView.as_view()), path('workspace//knowledge//document/split', views.DocumentView.Split.as_view()), path('workspace//knowledge//document/split_pattern', views.DocumentView.SplitPattern.as_view()), - path('workspace//knowledge//document/batch', views.DocumentView.Batch.as_view()), + path('workspace//knowledge//document/batch_create', views.DocumentView.BatchCreate.as_view()), + path('workspace//knowledge//document/batch_sync', views.DocumentView.BatchSync.as_view()), + path('workspace//knowledge//document/batch_delete', views.DocumentView.BatchDelete.as_view()), path('workspace//knowledge//document/web', views.WebDocumentView.as_view()), path('workspace//knowledge//document/qa', views.QaDocumentView.as_view()), path('workspace//knowledge//document/table', views.TableDocumentView.as_view()), @@ -20,9 +22,9 @@ urlpatterns = [ path('workspace//knowledge//document//sync', views.DocumentView.SyncWeb.as_view()), path('workspace//knowledge//document//refresh', views.DocumentView.Refresh.as_view()), path('workspace//knowledge//document//cancel_task', views.DocumentView.CancelTask.as_view()), - path('workspace//knowledge//document//cancel_task/batch', views.DocumentView.BatchCancelTask.as_view()), + path('workspace//knowledge//document//batch_cancel_task', views.DocumentView.BatchCancelTask.as_view()), path('workspace//knowledge//document//paragraph', views.ParagraphView.as_view()), - path('workspace//knowledge//document//paragraph/batch', views.ParagraphView.Batch.as_view()), + path('workspace//knowledge//document//paragraph/batch_delete', views.ParagraphView.BatchDelete.as_view()), path('workspace//knowledge//document//paragraph/', views.ParagraphView.Operate.as_view()), path('workspace//knowledge//document//paragraph//problem', views.ParagraphView.Problem.as_view()), path( 'workspace//knowledge//document//paragraph//', views.ParagraphView.Page.as_view()), diff --git a/apps/knowledge/views/document.py b/apps/knowledge/views/document.py index ceee584fc..2ab81aedc 100644 --- a/apps/knowledge/views/document.py +++ b/apps/knowledge/views/document.py @@ -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)) diff --git a/apps/knowledge/views/paragraph.py b/apps/knowledge/views/paragraph.py index 3ceaa4fd6..389586498 100644 --- a/apps/knowledge/views/paragraph.py +++ b/apps/knowledge/views/paragraph.py @@ -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))