Browse Source

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

确保operate_path_data在插入数据库前被正确转换为字符串,同时为请求体添加status字段默认值
max_liu 18 hours ago
parent
commit
8f6069ee68
1 changed files with 7 additions and 1 deletions
  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_provider,
       api_doc,
       api_doc,
       operate_path_data,
       operate_path_data,
+      status,
     } = req.body;
     } = req.body;
 
 
     // 验证必填字段
     // 验证必填字段
@@ -172,6 +173,10 @@ router.post("/", async (req, res) => {
       ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())
       ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())
     `;
     `;
 
 
+    // 保证 operate_path_data 为字符串(可能传入对象)
+    const operatePathValue =
+      typeof operate_path_data === "object" ? JSON.stringify(operate_path_data) : operate_path_data;
+
     await executeQuery(sql, [
     await executeQuery(sql, [
       access_task_id,
       access_task_id,
       tools_name,
       tools_name,
@@ -180,7 +185,8 @@ router.post("/", async (req, res) => {
       access_type,
       access_type,
       api_provider || null,
       api_provider || null,
       api_doc || null,
       api_doc || null,
-      operate_path_data || null,
+      operatePathValue || null,
+      status || null,
     ]);
     ]);
 
 
     res.status(201).json({
     res.status(201).json({