# 工作流数据格式说明 ## 1. 节点类型数据示例 ```json { "id": 2003, "createTime": "2024-12-05 12:40:03", "createBy": "system", "updateTime": "2024-12-05 12:40:03", "updateBy": "system", "version": 1, "deleted": false, "extraData": null, "code": "SHELL", "name": "Shell脚本节点", "description": "执行Shell脚本的任务节点", "category": "TASK", "icon": "code", "color": "#1890ff", "executors": [ { "code": "SHELL", "name": "Shell脚本执行器", "description": "执行Shell脚本,支持配置超时时间和工作目录", "configSchema": "{\"type\":\"object\",\"required\":[\"script\"],\"properties\":{\"script\":{\"type\":\"string\",\"title\":\"脚本内容\",\"format\":\"shell\",\"description\":\"需要执行的Shell脚本内容\"},\"timeout\":{\"type\":\"number\",\"title\":\"超时时间\",\"description\":\"脚本执行的最大时间(秒)\",\"minimum\":1,\"maximum\":3600,\"default\":300},\"workingDir\":{\"type\":\"string\",\"title\":\"工作目录\",\"description\":\"脚本执行的工作目录\",\"default\":\"/tmp\"}}}", "defaultConfig": null } ], "configSchema": "{\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"title\": \"节点名称\",\n \"minLength\": 1,\n \"maxLength\": 50\n },\n \"description\": {\n \"type\": \"string\",\n \"title\": \"节点描述\",\n \"maxLength\": 200\n },\n \"executor\": {\n \"type\": \"string\",\n \"title\": \"执行器\",\n \"enum\": [\"SHELL\"],\n \"enumNames\": [\"Shell脚本执行器\"]\n },\n \"retryTimes\": {\n \"type\": \"number\",\n \"title\": \"重试次数\",\n \"minimum\": 0,\n \"maximum\": 3,\n \"default\": 0\n },\n \"retryInterval\": {\n \"type\": \"number\",\n \"title\": \"重试间隔(秒)\",\n \"minimum\": 1,\n \"maximum\": 300,\n \"default\": 60\n }\n },\n \"required\": [\"name\", \"executor\"]\n}", "defaultConfig": "{\"name\": \"Shell脚本\", \"executor\": \"SHELL\", \"retryTimes\": 0, \"retryInterval\": 60}", "enabled": true } ``` ## 2. 流程设计数据示例 ```json { "nodes": [ { "id": "node_1", "type": "START", "position": { "x": 100, "y": 100 }, "data": { "name": "开始", "description": "流程开始节点", "config": { "name": "开始", "description": "这是一个开始节点" } } } ], "edges": [ { "id": "edge_1", "source": "node_1", "target": "node_2", "type": "default", "data": { "condition": null } } ] } ``` ## 3. 关键字段说明 ### configSchema(节点配置模式) **用途**: 1. 前端动态生成配置表单 2. 后端验证配置数据的合法性 3. 提供配置项的约束和验证规则 ### defaultConfig(默认配置) **用途**: 1. 新建节点时的默认值 2. 重置配置时的参考值 3. 必须符合configSchema定义的格式 ### executors(执行器定义) **用途**: 1. 定义节点支持的执行器类型 2. 每个执行器的配置要求 3. 用于任务节点的具体执行逻辑 ## 4. 字段关系说明 1. configSchema定义节点的整体配置结构 2. defaultConfig提供符合configSchema的默认值 3. executors中的configSchema定义具体执行器的配置结构 4. 实际节点配置时,executorConfig需要符合选定执行器的configSchema ## 5. 设计优点 1. 配置灵活可扩展 2. 前端可以动态生成表单 3. 后端可以严格验证配置 4. 支持不同类型节点的差异化配置 5. 便于新增节点类型和执行器