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

    PERSONAL(10, "人员"),

    DEPT(20, "部门");

    private final Integer value;

    private final String name;

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

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

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

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

}
