package cn.stylefeng.workflow.api.enums;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.rule.base.ReadableEnum;
import lombok.Getter;

@Getter
public enum SelectScopeEnum implements ReadableEnum<SelectScopeEnum> {

    DEPT(10, "指定部门"),

    SUBMIT_DEPT(20, "发起人所在部门"),

    SUBMIT_COMPANY(30, "发起人所在公司");

    private final Integer value;

    private final String name;

    SelectScopeEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    @Override
    public Object getKey() {
        return value;
    }

    @Override
    public Object getName() {
        return name;
    }

    @Override
    public SelectScopeEnum parseToEnum(String originValue) {
        if (ObjectUtil.isEmpty(originValue)) {
            return null;
        }
        for (SelectScopeEnum value : SelectScopeEnum.values()) {
            if (value.value.equals(Convert.toInt(originValue))) {
                return value;
            }
        }
        return null;
    }

}
