package com.qqchen.deploy.backend.workflow.enums;


import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * 工作流节点分类枚举
 */
@Getter
public enum WorkflowCategoryEnum {
    // 1. 脚本执行类
    SCRIPT_EXECUTION(
        "脚本执行",
        "用于执行各类脚本的流程",
        Arrays.asList(WorkflowTriggerTypeEnum.MANUAL, WorkflowTriggerTypeEnum.SCHEDULED)
    ),

    // 2. 部署类
    DEPLOYMENT(
        "应用部署",
        "用于应用部署的流程",
        Arrays.asList(WorkflowTriggerTypeEnum.MANUAL, WorkflowTriggerTypeEnum.SCHEDULED, WorkflowTriggerTypeEnum.APPROVAL)
    ),

    // 3. 数据同步类
    DATA_SYNC(
        "数据同步",
        "用于第三方系统数据同步的流程",
        Arrays.asList(WorkflowTriggerTypeEnum.MANUAL, WorkflowTriggerTypeEnum.SCHEDULED)
    ),

    // 4. 配置同步类
    CONFIG_SYNC(
        "配置同步",
        "用于配置中心数据同步的流程",
        Arrays.asList(WorkflowTriggerTypeEnum.MANUAL, WorkflowTriggerTypeEnum.APPROVAL)
    ),

    // 5. 审批流程类
    APPROVAL(
        "审批流程",
        "纯审批流程",
        Arrays.asList(WorkflowTriggerTypeEnum.MANUAL)
    ),

    // 6. 其他类型（用于扩展）
    OTHER(
        "其他",
        "其他类型流程",
        Arrays.asList(WorkflowTriggerTypeEnum.MANUAL)
    );

    private final String label;        // 显示名称

    private final String description;  // 描述

    private final List<WorkflowTriggerTypeEnum> supportedTriggers;  // 支持的触发方式

    WorkflowCategoryEnum(String label, String description, List<WorkflowTriggerTypeEnum> supportedTriggers) {
        this.label = label;
        this.description = description;
        this.supportedTriggers = supportedTriggers;
    }

    // 判断是否支持某种触发方式
    public boolean supportsTriggerType(WorkflowTriggerTypeEnum triggerType) {
        return supportedTriggers.contains(triggerType);
    }
}