|
9 | 9 | from common.result import result |
10 | 10 | from common.utils.common import query_params_to_single_dict |
11 | 11 | from knowledge.api.paragraph import ParagraphReadAPI, ParagraphCreateAPI, ParagraphBatchDeleteAPI, ParagraphEditAPI, \ |
12 | | - ParagraphGetAPI, ProblemCreateAPI, UnAssociationAPI, AssociationAPI |
| 12 | + ParagraphGetAPI, ProblemCreateAPI, UnAssociationAPI, AssociationAPI, ParagraphPageAPI |
13 | 13 | from knowledge.serializers.paragraph import ParagraphSerializers |
14 | 14 |
|
15 | 15 |
|
@@ -232,3 +232,29 @@ def get(self, request: Request, |
232 | 232 | 'problem_id': problem_id |
233 | 233 | } |
234 | 234 | ).association()) |
| 235 | + |
| 236 | + class Page(APIView): |
| 237 | + authentication_classes = [TokenAuth] |
| 238 | + |
| 239 | + @extend_schema( |
| 240 | + methods=['GET'], |
| 241 | + summary=_('Get paragraph list by pagination'), |
| 242 | + description=_('Get paragraph list by pagination'), |
| 243 | + operation_id=_('Get paragraph list by pagination'), |
| 244 | + parameters=ParagraphPageAPI.get_parameters(), |
| 245 | + responses=ParagraphPageAPI.get_response(), |
| 246 | + tags=[_('Knowledge Base/Documentation/Paragraph')] |
| 247 | + ) |
| 248 | + @has_permissions(PermissionConstants.DOCUMENT_EDIT.get_workspace_permission()) |
| 249 | + def get(self, request: Request, |
| 250 | + workspace_id: str, knowledge_id: str, document_id: str, current_page: int, page_size: int): |
| 251 | + d = ParagraphSerializers.Query( |
| 252 | + data={ |
| 253 | + **query_params_to_single_dict(request.query_params), |
| 254 | + 'workspace_id': workspace_id, |
| 255 | + 'knowledge_id': knowledge_id, |
| 256 | + 'document_id': document_id |
| 257 | + } |
| 258 | + ) |
| 259 | + d.is_valid(raise_exception=True) |
| 260 | + return result.success(d.page(current_page, page_size)) |
0 commit comments