From 52de3458048e3c5bfb7d50d92a68c53983d8a530 Mon Sep 17 00:00:00 2001 From: warren Date: Mon, 23 Dec 2024 23:54:45 +0800 Subject: [PATCH] reformat api --- api/controllers/console/app/workflow.py | 17 ++++------------- api/fields/workflow_fields.py | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/api/controllers/console/app/workflow.py b/api/controllers/console/app/workflow.py index ae679a0ce4ec4c..648cf5c02499cb 100644 --- a/api/controllers/console/app/workflow.py +++ b/api/controllers/console/app/workflow.py @@ -457,21 +457,12 @@ def get(self, app_model: App): parser.add_argument("page", type=inputs.int_range(1, 99999), required=False, default=1, location="args") parser.add_argument("limit", type=inputs.int_range(1, 100), required=False, default=20, location="args") args = parser.parse_args() - page = args.get('page') - limit = args.get('limit') + page = args.get("page") + limit = args.get("limit") workflow_service = WorkflowService() - workflows, has_more = workflow_service.get_all_published_workflow( - app_model=app_model, - page=page, - limit=limit - ) + workflows, has_more = workflow_service.get_all_published_workflow(app_model=app_model, page=page, limit=limit) - return { - 'items': workflows, - 'page': page, - 'limit': limit, - 'has_more': has_more - } + return {"items": workflows, "page": page, "limit": limit, "has_more": has_more} api.add_resource(DraftWorkflowApi, "/apps//workflows/draft") diff --git a/api/fields/workflow_fields.py b/api/fields/workflow_fields.py index 7bd9fd5f0639b7..8e4de7d813aa7b 100644 --- a/api/fields/workflow_fields.py +++ b/api/fields/workflow_fields.py @@ -64,8 +64,8 @@ def format(self, value): } workflow_pagination_fields = { - 'data': fields.List(fields.Nested(workflow_fields), attribute="data"), - 'page': fields.Integer, + "data": fields.List(fields.Nested(workflow_fields), attribute="data"), + "page": fields.Integer, "limit": fields.Integer(attribute="limit"), "has_more": fields.Boolean(attribute="has_more"), }