package cn.axzo.workflow.common.enums;

import cn.axzo.framework.rocketmq.Event;

/**
 * 流程引擎自产自销事件枚举
 *
 * @author wangli
 * @since 2024/5/20 13:57
 */
public enum WorkflowEngineEventEnum {

    WORKFLOW_ENGINE_SERVER("workflow-engine", "workflow-engine-server", "引擎服务端事件"),
    WORKFLOW_ENGINE_STARTER("workflow-engine", "workflow-engine-starter-%s", "引擎客户端事件"),
    ;

    private final String module;
    private final String tag;
    private final String desc;
    private Event.EventCode eventCode;

    WorkflowEngineEventEnum(String module, String tag, String desc) {
        this.module = module;
        this.tag = tag;
        this.desc = desc;
        this.eventCode = Event.EventCode.builder()
                .module(module)
                .name(tag)
                .build();
    }

    public Event.EventCode getEventCode(String appName) {
        eventCode.setName(String.format(eventCode.getName(), appName));
        return eventCode;
    }

    public String getModule() {
        return module;
    }

    public String getTag() {
        return eventCode.getName();
    }

    public String getDesc() {
        return desc;
    }

}
