package cn.stylefeng.workflow.api.enums.strategy;

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 EmptyApproverStrategyEnum implements ReadableEnum<EmptyApproverStrategyEnum> {

    JUMP(10, "自动跳过"),

    POINT_USER(20, "指定人员"),

    FLOW_CREATE_PERSON(30, "由流程创建人替代"),

    LEADER(40, "由上级主管代替审批"),

    TURN_TO_MANAGER(50, "转交给审批管理员"),

    SHOW_ERROR_TIP(60, "给出异常提示，待管理员指定");

    private final Integer code;

    private final String name;

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

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

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

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

}
