-- =====================================================
-- 修复 workflow_node_definition 表的初始化数据
-- =====================================================

-- 删除注释，添加正确的节点定义数据
INSERT INTO workflow_node_definition (
    node_type, node_code, node_name, description, category,
    ui_variables, panel_variables_schema, local_variables_schema, 
    form_variables_schema, enabled,
    create_time, create_by, update_time, update_by, version, deleted
) VALUES 
-- 开始节点
(
    'START_EVENT', 'START_EVENT', '开始节点', '工作流的起点', 'EVENT',
    '{
        "shape": "circle",
        "size": {"width": 40, "height": 40},
        "style": {
            "fill": "#e8f7ff",
            "stroke": "#1890ff", 
            "strokeWidth": 2,
            "icon": "play-circle",
            "iconColor": "#1890ff"
        },
        "ports": {
            "groups": {
                "out": {
                    "position": "right",
                    "attrs": {
                        "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"}
                    }
                }
            }
        }
    }',
    '{
        "type": "object",
        "properties": {
            "code": {"type": "string", "title": "节点Code"},
            "name": {"type": "string", "title": "节点名称"},
            "description": {"type": "string", "title": "节点描述"}
        },
        "required": ["code", "name"]
    }',
    '{}',
    '{"formItems": []}',
    1,
    NOW(), 'system', NOW(), 'system', 1, 0
),
-- 结束节点  
(
    'END_EVENT', 'END_EVENT', '结束节点', '工作流的终点', 'EVENT',
    '{
        "shape": "circle",
        "size": {"width": 40, "height": 40},
        "style": {
            "fill": "#fff1f0",
            "stroke": "#ff4d4f",
            "strokeWidth": 2, 
            "icon": "stop",
            "iconColor": "#ff4d4f"
        },
        "ports": {
            "groups": {
                "in": {
                    "position": "left",
                    "attrs": {
                        "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"}
                    }
                }
            }
        }
    }',
    '{
        "type": "object",
        "properties": {
            "code": {"type": "string", "title": "节点Code"},
            "name": {"type": "string", "title": "节点名称"}, 
            "description": {"type": "string", "title": "节点描述"}
        },
        "required": ["code", "name"]
    }',
    '{}',
    '{"formItems": []}',
    1,
    NOW(), 'system', NOW(), 'system', 1, 0
),
-- 脚本任务节点
(
    'SCRIPT_TASK', 'SCRIPT_TASK', '脚本任务', '脚本执行任务', 'TASK',
    '{
        "shape": "rect",
        "size": {"width": 120, "height": 60},
        "style": {
            "fill": "#ffffff",
            "stroke": "#1890ff",
            "strokeWidth": 2,
            "icon": "code", 
            "iconColor": "#1890ff"
        },
        "ports": {
            "groups": {
                "in": {
                    "position": "left",
                    "attrs": {
                        "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"}
                    }
                },
                "out": {
                    "position": "right", 
                    "attrs": {
                        "circle": {"r": 4, "fill": "#ffffff", "stroke": "#1890ff"}
                    }
                }
            }
        }
    }',
    '{
        "type": "object",
        "properties": {
            "code": {"type": "string", "title": "节点Code"},
            "name": {"type": "string", "title": "节点名称"},
            "description": {"type": "string", "title": "节点描述"},
            "script": {
                "type": "string",
                "title": "脚本内容",
                "format": "textarea"
            },
            "language": {
                "type": "string", 
                "title": "脚本语言",
                "default": "shell",
                "enum": ["shell", "python", "javascript"],
                "enumNames": ["Shell脚本", "Python脚本", "JavaScript脚本"]
            },
            "workingDirectory": {
                "type": "string",
                "title": "工作目录", 
                "default": "/tmp"
            },
            "delegate": {
                "type": "string",
                "title": "执行委派者",
                "default": "${shellTaskDelegate}"
            }
        },
        "required": ["code", "name", "script", "language", "delegate"]
    }',
    '{
        "environment": {"type": "object", "additionalProperties": {"type": "string"}}
    }',
    '{"formItems": []}',
    1,
    NOW(), 'system', NOW(), 'system', 1, 0
);
