From f21d301140ea0bf6aa61fe8e2b2a33d7ee4c7d48 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 12 May 2025 17:13:57 +0800 Subject: [PATCH] fix: change HTTP methods from PUT to GET for association and unassociation endpoints --- apps/knowledge/api/paragraph.py | 4 ++-- apps/knowledge/urls.py | 4 ++-- apps/knowledge/views/paragraph.py | 18 ++++++++---------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/knowledge/api/paragraph.py b/apps/knowledge/api/paragraph.py index e50249d9d..aceb1728a 100644 --- a/apps/knowledge/api/paragraph.py +++ b/apps/knowledge/api/paragraph.py @@ -201,14 +201,14 @@ class UnAssociationAPI(APIMixin): name="paragraph_id", description="段落id", type=OpenApiTypes.STR, - location='path', + location='query', required=True, ), OpenApiParameter( name="problem_id", description="问题id", type=OpenApiTypes.STR, - location='path', + location='query', required=True, ) ] diff --git a/apps/knowledge/urls.py b/apps/knowledge/urls.py index 87eb2ab4e..fbce801be 100644 --- a/apps/knowledge/urls.py +++ b/apps/knowledge/urls.py @@ -33,11 +33,11 @@ urlpatterns = [ path('workspace//knowledge//document//paragraph', views.ParagraphView.as_view()), path('workspace//knowledge//document//paragraph/batch_delete', views.ParagraphView.BatchDelete.as_view()), path('workspace//knowledge//document//paragraph/batch_generate_related', views.ParagraphView.BatchGenerateRelated.as_view()), + path( 'workspace//knowledge//document//paragraph/association', views.ParagraphView.Association.as_view()), + path( 'workspace//knowledge//document//paragraph/unassociation', views.ParagraphView.UnAssociation.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()), - path('workspace//knowledge//document//paragraph//problem//association', views.ParagraphView.Association.as_view()), - path('workspace//knowledge//document//paragraph//problem//unassociation', views.ParagraphView.UnAssociation.as_view()), path('workspace//knowledge//problem', views.ProblemView.as_view()), path('workspace//knowledge//problem/batch_delete', views.ProblemView.BatchDelete.as_view()), path('workspace//knowledge//problem/batch_association', views.ProblemView.BatchAssociation.as_view()), diff --git a/apps/knowledge/views/paragraph.py b/apps/knowledge/views/paragraph.py index 6bd91136a..9453b4077 100644 --- a/apps/knowledge/views/paragraph.py +++ b/apps/knowledge/views/paragraph.py @@ -207,7 +207,7 @@ class ParagraphView(APIView): authentication_classes = [TokenAuth] @extend_schema( - methods=['PUT'], + methods=['GET'], summary=_('Disassociation issue'), description=_('Disassociation issue'), operation_id=_('Disassociation issue'), # type: ignore @@ -216,15 +216,14 @@ class ParagraphView(APIView): tags=[_('Knowledge Base/Documentation/Paragraph')] # type: ignore ) @has_permissions(PermissionConstants.DOCUMENT_EDIT.get_workspace_permission()) - def put(self, request: Request, - workspace_id: str, knowledge_id: str, document_id: str, paragraph_id: str, problem_id: str): + def get(self, request: Request, workspace_id: str, knowledge_id: str, document_id: str): return result.success(ParagraphSerializers.Association( data={ 'workspace_id': workspace_id, 'knowledge_id': knowledge_id, 'document_id': document_id, - 'paragraph_id': paragraph_id, - 'problem_id': problem_id + 'paragraph_id': request.query_params.get('paragraph_id'), + 'problem_id': request.query_params.get('problem_id') } ).un_association()) @@ -232,7 +231,7 @@ class ParagraphView(APIView): authentication_classes = [TokenAuth] @extend_schema( - methods=['PUT'], + methods=['GET'], summary=_('Related questions'), description=_('Related questions'), operation_id=_('Related questions'), # type: ignore @@ -241,15 +240,14 @@ class ParagraphView(APIView): tags=[_('Knowledge Base/Documentation/Paragraph')] # type: ignore ) @has_permissions(PermissionConstants.DOCUMENT_EDIT.get_workspace_permission()) - def put(self, request: Request, - workspace_id: str, knowledge_id: str, document_id: str, paragraph_id: str, problem_id: str): + def get(self, request: Request, workspace_id: str, knowledge_id: str, document_id: str): return result.success(ParagraphSerializers.Association( data={ 'workspace_id': workspace_id, 'knowledge_id': knowledge_id, 'document_id': document_id, - 'paragraph_id': paragraph_id, - 'problem_id': problem_id + 'paragraph_id': request.query_params.get('paragraph_id'), + 'problem_id': request.query_params.get('problem_id') } ).association())