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

    START(10, "发起"),

    PROCESSING(20, "审批"),

    COPY(30, "抄送"),

    CONSUL(40, "征询"),

    HANDLE(50, "办理");

    private final Integer code;

    private final String name;

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

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

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

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