Просмотр исходного кода

fix(自动任务路由): 修复operate_path_data类型处理并添加status字段

确保operate_path_data在插入数据库前被正确转换为字符串,同时为请求体添加status字段默认值
max_liu 7 часов назад
Родитель
Сommit
8f6069ee68
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      server/routes/autoAccessTasks.js

+ 7 - 1
server/routes/autoAccessTasks.js

@@ -144,6 +144,7 @@ router.post("/", async (req, res) => {
       api_provider,
       api_doc,
       operate_path_data,
+      status,
     } = req.body;
 
     // 验证必填字段
@@ -172,6 +173,10 @@ router.post("/", async (req, res) => {
       ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())
     `;
 
+    // 保证 operate_path_data 为字符串(可能传入对象)
+    const operatePathValue =
+      typeof operate_path_data === "object" ? JSON.stringify(operate_path_data) : operate_path_data;
+
     await executeQuery(sql, [
       access_task_id,
       tools_name,
@@ -180,7 +185,8 @@ router.post("/", async (req, res) => {
       access_type,
       api_provider || null,
       api_doc || null,
-      operate_path_data || null,
+      operatePathValue || null,
+      status || null,
     ]);
 
     res.status(201).json({