From 450e264cb3fc3b955a48d7b75371acbc8f77ba96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E5=8D=9A?= <1016318004@qq.com> Date: Mon, 3 Mar 2025 12:05:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(mock):=20=E5=A2=9E=E5=8A=A0=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=20app=5Fid=20=E8=8E=B7=E5=8F=96=20flow=5Fid=20?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 mock_data 函数中添加了通过 AppCenterManager 获取 app 数据的逻辑 - 如果 post_body 中包含 app_id 但没有 flow_id,自动获取并设置第一个 flow 的 id - 这个改动解决了 App 能正常工作但 API 返回 400 错误的问题 --- apps/routers/mock.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/routers/mock.py b/apps/routers/mock.py index 5a578c6c..a0ebbaff 100644 --- a/apps/routers/mock.py +++ b/apps/routers/mock.py @@ -30,8 +30,10 @@ from apps.dependency import ( verify_csrf_token, verify_user, ) +from apps.entities.pool import AppPool from apps.entities.request_data import MockRequestData, RequestData from apps.entities.scheduler import CallError +from apps.manager.appcenter import AppCenterManager from apps.manager.flow import FlowManager from apps.scheduler.pool.loader.flow import FlowLoader from apps.scheduler.scheduler.context import save_data @@ -223,6 +225,10 @@ async def mock_data( session_id: str, ): try: + if post_body.app and post_body.app.app_id and not post_body.app.flow_id: + app = await AppCenterManager.fetch_app_data_by_id(post_body.app.app_id) + if type(app) is AppPool and type(app.flows) is list: + post_body.app.flow_id = app.flows[0].id # await Activity.set_active(user_sub) # # 生成group_id -- Gitee