确保operate_path_data在插入数据库前被正确转换为字符串,同时为请求体添加status字段默认值
@@ -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({