Skip to content

Commit a09d0d5

Browse files
committed
feat: add ProblemParagraphAPI for retrieving associated paragraphs and update routing
1 parent 6cdd5b4 commit a09d0d5

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

apps/knowledge/api/problem.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ def get_response():
121121
return DefaultResultSerializer
122122

123123

124-
class ProblemEditAPI(ProblemReadAPI):
124+
class ProblemEditAPI(ProblemDeleteAPI):
125125
@staticmethod
126126
def get_request():
127127
return ProblemEditSerializer
128+
129+
130+
class ProblemParagraphAPI(ProblemDeleteAPI):
131+
pass

apps/knowledge/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem/batch_delete', views.ProblemView.BatchDelete.as_view()),
3535
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem/batch_association', views.ProblemView.BatchAssociation.as_view()),
3636
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem/<str:problem_id>', views.ProblemView.Operate.as_view()),
37+
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem/<str:problem_id>/paragraph', views.ProblemView.Paragraph.as_view()),
3738
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/problem/<int:current_page>/<int:page_size>', views.ProblemView.Page.as_view()),
3839
path('workspace/<str:workspace_id>/knowledge/<str:knowledge_id>/document/<int:current_page>/<int:page_size>', views.DocumentView.Page.as_view()),
3940
path('workspace/<str:workspace_id>/knowledge/<int:current_page>/<int:page_size>', views.KnowledgeView.Page.as_view()),

apps/knowledge/views/problem.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from common.result import result
1010
from common.utils.common import query_params_to_single_dict
1111
from knowledge.api.problem import ProblemReadAPI, ProblemBatchCreateAPI, BatchAssociationAPI, BatchDeleteAPI, \
12-
ProblemPageAPI, ProblemDeleteAPI, ProblemEditAPI
12+
ProblemPageAPI, ProblemDeleteAPI, ProblemEditAPI, ProblemParagraphAPI
1313
from knowledge.serializers.problem import ProblemSerializers
1414

1515

@@ -53,6 +53,28 @@ def post(self, request: Request, workspace_id: str, knowledge_id: str):
5353
data={'workspace_id': workspace_id, 'knowledge_id': knowledge_id, 'problem_list': request.data}
5454
).batch())
5555

56+
class Paragraph(APIView):
57+
authentication_classes = [TokenAuth]
58+
59+
@extend_schema(
60+
summary=_('Get a list of associated paragraphs'),
61+
description=_('Get a list of associated paragraphs'),
62+
operation_id=_('Get a list of associated paragraphs'),
63+
parameters=ProblemParagraphAPI.get_parameters(),
64+
responses=ProblemParagraphAPI.get_response(),
65+
tags=[_('Knowledge Base/Documentation/Paragraph/Question')]
66+
)
67+
@has_permissions(PermissionConstants.DOCUMENT_EDIT.get_workspace_permission())
68+
def get(self, request: Request, workspace_id: str, knowledge_id: str, problem_id: str):
69+
return result.success(ProblemSerializers.Operate(
70+
data={
71+
**query_params_to_single_dict(request.query_params),
72+
'workspace_id': workspace_id,
73+
'knowledge_id': knowledge_id,
74+
'problem_id': problem_id
75+
}
76+
).list_paragraph())
77+
5678
class BatchAssociation(APIView):
5779
authentication_classes = [TokenAuth]
5880

0 commit comments

Comments
 (0)