package cn.axzo.msg.center.service.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author xudawei@axzo.cn
 * @date 2024/12/12
 * @desc 系统类型按钮
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum SystemButtonEnum {

    BPMN_APPROVE("BPMN_APPROVE", "同意", RouterCategoryEnum.JUMP),
    BPMN_REJECT("BPMN_REJECT", "驳回", RouterCategoryEnum.JUMP),
    BPMN_REVOCATION("BPMN_REVOCATION", "撤回", RouterCategoryEnum.ACTION),
    BPMN_TRANSFER("BPMN_TRANSFER", "转交", RouterCategoryEnum.JUMP),
    BPMN_COUNTERSIGN("BPMN_COUNTERSIGN", "加签", RouterCategoryEnum.JUMP),
    BPMN_COMMENT("BPMN_COMMENT", "评论", RouterCategoryEnum.JUMP),
    BPMN_ROLLBACK("BPMN_ROLLBACK", "回退", RouterCategoryEnum.JUMP),
        ;
    /**
     * 编码
     */
    private String code;
    /**
     * 名称
     */
    private String name;
    /**
     * 类型
     */
    private RouterCategoryEnum category;

    /**
     * 名称Map
     */
    private static Map<String, SystemButtonEnum> nameMap = Arrays.stream(values()).collect(Collectors.toMap(SystemButtonEnum::getName, Function.identity()));
    /**
     * code的开始字符
     */
    public static String CODE_START = "BPMN_";

    /**
     * 通过名称获取枚举
     * @param name 名称
     * @return 枚举
     */
    public static SystemButtonEnum getByName(String name) {
        return nameMap.get(name);
    }
}
