瀏覽代碼

feat: 添加网站位置字段到工具库和自动接入任务

在工具库和自动接入任务的相关页面和接口中添加网站位置字段
包括列表展示、详情页、新增和编辑功能
后端数据库表也相应添加该字段支持
max_liu 4 天之前
父節點
當前提交
8340555971

+ 9 - 5
server/routes/autoAccessTasks.js

@@ -29,7 +29,7 @@ router.get("/", async (req, res) => {
     const sql = `
       SELECT access_task_id, search_task_id, tools_name, tools_function_name,
              access_type, tools_function_desc, api_doc, api_class_name, api_provider,
-             operate_path_data, origin_content_link, status, fail_reason,
+             operate_path_data, origin_content_link, website_location, status, fail_reason,
              create_time, update_time
       FROM tools_auto_access_task
       ${whereClause}
@@ -64,7 +64,7 @@ router.get("/:id", async (req, res) => {
     const sql = `
       SELECT access_task_id, search_task_id, tools_name, tools_function_name,
              access_type, tools_function_desc, api_doc, api_class_name, api_provider,
-             operate_path_data, origin_content_link, status, fail_reason,
+             operate_path_data, origin_content_link, website_location, status, fail_reason,
              create_time, update_time
       FROM tools_auto_access_task
       WHERE access_task_id = ?
@@ -97,6 +97,7 @@ router.put("/:id", async (req, res) => {
       api_provider,
       operate_path_data,
       origin_content_link,
+      website_location,
       status,
       fail_reason,
     } = req.body;
@@ -106,7 +107,7 @@ router.put("/:id", async (req, res) => {
       SET search_task_id = ?, tools_name = ?, tools_function_name = ?,
           access_type = ?, tools_function_desc = ?, api_doc = ?,
           api_class_name = ?, api_provider = ?, operate_path_data = ?, origin_content_link = ?,
-          status = ?, fail_reason = ?, update_time = NOW()
+          website_location = ?, status = ?, fail_reason = ?, update_time = NOW()
       WHERE access_task_id = ?
     `;
 
@@ -121,6 +122,7 @@ router.put("/:id", async (req, res) => {
       api_provider ?? null,
       operate_path_data ?? null,
       origin_content_link ?? null,
+      website_location ?? null,
       status ?? null,
       fail_reason ?? null,
       id,
@@ -144,6 +146,7 @@ router.post("/", async (req, res) => {
       api_provider,
       api_doc,
       operate_path_data,
+      website_location,
     } = req.body;
 
     // 验证必填字段
@@ -167,9 +170,9 @@ router.post("/", async (req, res) => {
     const sql = `
       INSERT INTO tools_auto_access_task (
         access_task_id, tools_name, tools_function_name, tools_function_desc,
-        access_type, api_provider, api_doc, operate_path_data,
+        access_type, api_provider, api_doc, operate_path_data, website_location,
         create_time, update_time
-      ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())
+      ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())
     `;
 
     // 保证 operate_path_data 为字符串(可能传入对象)
@@ -185,6 +188,7 @@ router.post("/", async (req, res) => {
       api_provider || null,
       api_doc || null,
       operatePathValue || null,
+      website_location || null,
     ]);
 
     res.status(201).json({

+ 5 - 2
server/routes/toolsLibrary.js

@@ -35,7 +35,7 @@ router.get("/", async (req, res) => {
     const sql = `
       SELECT tools_id, tools_name, tools_function_name, mcp_tools_name, tools_full_name,
              tools_desc, tools_version, access_task_id, status, call_type,
-             api_provider, api_url_path, create_time, update_time
+             api_provider, api_url_path, website_location, create_time, update_time
       FROM tools_library
       ${whereClause}
       ORDER BY create_time DESC
@@ -71,7 +71,7 @@ router.get("/:id", async (req, res) => {
     const sql = `
       SELECT tools_id, tools_name, tools_function_name, mcp_tools_name, tools_full_name,
              tools_desc, tools_version, access_task_id, status, call_type,
-             api_provider, api_url_path, operate_path_data, params_definition,
+             api_provider, api_url_path, website_location, operate_path_data, params_definition,
              response_desc, create_time, update_time
       FROM tools_library
       WHERE tools_id = ?
@@ -105,6 +105,7 @@ router.put("/:id", async (req, res) => {
       call_type,
       api_provider,
       api_url_path,
+      website_location,
       operate_path_data,
       params_definition,
       response_desc,
@@ -115,6 +116,7 @@ router.put("/:id", async (req, res) => {
       SET tools_name = ?, tools_function_name = ?, mcp_tools_name = ?, tools_full_name = ?,
           tools_desc = ?, tools_version = ?, access_task_id = ?,
           status = ?, call_type = ?, api_provider = ?, api_url_path = ?,
+          website_location = ?,
           operate_path_data = ?, params_definition = ?, response_desc = ?,
           update_time = NOW()
       WHERE tools_id = ?
@@ -133,6 +135,7 @@ router.put("/:id", async (req, res) => {
       call_type ?? null,
       api_provider ?? null,
       api_url_path ?? null,
+      website_location ?? null,
       operate_path_data ?? null,
       params_definition ?? null,
       response_desc ?? null,

+ 19 - 0
src/pages/AutoAccessTaskAdd.js

@@ -4,6 +4,7 @@ import { ArrowLeftOutlined, SaveOutlined } from "@ant-design/icons";
 import { useNavigate } from "react-router-dom";
 import { autoAccessTasksApi } from "../services/api";
 import { generateSearchTaskId } from "./PendingToolsAdd";
+import { WEBSITE_LOCATION_OPTIONS } from "./ToolsLibraryDetail";
 
 const { TextArea } = Input;
 const { Option } = Select;
@@ -37,6 +38,7 @@ const AutoAccessTaskAdd = () => {
         api_provider: values.apiProvider || null,
         api_doc: values.apiDoc || null,
         operate_path_data: values.operatePathData || null,
+        website_location: values.websiteLocation || null,
       };
 
       await autoAccessTasksApi.create(submitData);
@@ -175,6 +177,23 @@ const AutoAccessTaskAdd = () => {
             </Form.Item>
           )}
 
+          <Form.Item
+            label="网站位置"
+            name="websiteLocation"
+            rules={[{ max: 200, message: "网站位置不能超过200个字符" }]}
+          >
+            <Select placeholder="请选择网站位置">
+              {WEBSITE_LOCATION_OPTIONS.map((option) => (
+                <Option
+                  key={option.value}
+                  value={option.value}
+                >
+                  {option.label}
+                </Option>
+              ))}
+            </Select>
+          </Form.Item>
+
           <Form.Item
             label="工具功能名称"
             name="toolsFunctionName"

+ 22 - 0
src/pages/AutoAccessTaskDetail.js

@@ -6,6 +6,7 @@ import { autoAccessTasksApi } from "../services/api";
 import moment from "moment";
 import { STATUS_MAP, STATUS_TAG_COLOR } from "./AutoAccessTaskList";
 import { ACCESS_PROVIDER_OPTIONS } from "./AutoAccessTaskAdd";
+import { WEBSITE_LOCATION_OPTIONS } from "./ToolsLibraryDetail";
 
 const { TextArea } = Input;
 const { Option } = Select;
@@ -225,6 +226,26 @@ const AutoAccessTaskDetail = () => {
               </Col>
             </Row>
 
+            <Row gutter={24}>
+              <Col span={12}>
+                <Form.Item
+                  label="网站位置"
+                  name="website_location"
+                >
+                  <Select>
+                    {WEBSITE_LOCATION_OPTIONS.map((option) => (
+                      <Option
+                        key={option.value}
+                        value={option.value}
+                      >
+                        {option.label}
+                      </Option>
+                    ))}
+                  </Select>
+                </Form.Item>
+              </Col>
+            </Row>
+
             <Row gutter={24}>
               <Col span={12}>
                 <Form.Item
@@ -341,6 +362,7 @@ const AutoAccessTaskDetail = () => {
             </Descriptions.Item>
             <Descriptions.Item label="API类名">{data.api_class_name}</Descriptions.Item>
             <Descriptions.Item label="API提供方">{data.api_provider}</Descriptions.Item>
+            <Descriptions.Item label="网站位置">{data.website_location || "无"}</Descriptions.Item>
             <Descriptions.Item
               label="补充ApiKey"
               span={2}

+ 12 - 0
src/pages/AutoAccessTaskList.js

@@ -108,6 +108,18 @@ const AutoAccessTaskList = () => {
         </Tooltip>
       ),
     },
+    {
+      title: "网站位置",
+      dataIndex: "website_location",
+      key: "website_location",
+      width: 200,
+      ellipsis: true,
+      render: (text) => (
+        <Tooltip title={text}>
+          <span className="cursor-pointer">{text || "无"}</span>
+        </Tooltip>
+      ),
+    },
     {
       title: "工具功能描述",
       dataIndex: "tools_function_desc",

+ 24 - 0
src/pages/ToolsLibraryDetail.js

@@ -11,6 +11,10 @@ const STATUS_OPTIONS = [
   { value: "offline", label: "已下线" },
   { value: "unpublished", label: "待发布" },
 ];
+export const WEBSITE_LOCATION_OPTIONS = [
+  { value: "国内", label: "国内" },
+  { value: "国外", label: "国外" },
+];
 const { TextArea } = Input;
 const { Option } = Select;
 
@@ -225,6 +229,25 @@ const ToolsLibraryDetail = () => {
                 </Form.Item>
               </Col>
             </Row>
+            <Row gutter={24}>
+              <Col span={12}>
+                <Form.Item
+                  label="网站位置"
+                  name="website_location"
+                >
+                  <Select>
+                    {WEBSITE_LOCATION_OPTIONS.map((option) => (
+                      <Option
+                        key={option.value}
+                        value={option.value}
+                      >
+                        {option.label}
+                      </Option>
+                    ))}
+                  </Select>
+                </Form.Item>
+              </Col>
+            </Row>
             <Form.Item
               label="MCP工具名称"
               name="mcp_tools_name"
@@ -309,6 +332,7 @@ const ToolsLibraryDetail = () => {
               <Tag color="purple">{getApiProviderText(data.api_provider)}</Tag>
             </Descriptions.Item>
             <Descriptions.Item label="API路径">{data.api_url_path}</Descriptions.Item>
+            <Descriptions.Item label="网站位置">{data.website_location || "无"}</Descriptions.Item>
 
             <Descriptions.Item
               label="MCP工具名称"

+ 12 - 0
src/pages/ToolsLibraryList.js

@@ -169,6 +169,18 @@ const ToolsLibraryList = () => {
         </Tooltip>
       ),
     },
+    {
+      title: "网站位置",
+      dataIndex: "website_location",
+      key: "website_location",
+      width: 200,
+      ellipsis: true,
+      render: (text) => (
+        <Tooltip title={text}>
+          <span className="cursor-pointer">{text || "无"}</span>
+        </Tooltip>
+      ),
+    },
     {
       title: "创建时间",
       dataIndex: "create_time",