package com.engine.salary.enums.salarysend;

import cn.hutool.core.util.StrUtil;

import java.util.Arrays;
import java.util.Objects;

public enum SalarySendGrantTypeEnum {
    GRANT("grant", "发放", 98590),
    WITHDRAW("withdraw", "撤回", 93351);

    private String value;

    private String defaultLabel;

    private int labelId;

    SalarySendGrantTypeEnum(String value, String defaultLabel, int labelId) {
        this.value = value;
        this.defaultLabel = defaultLabel;
        this.labelId = labelId;
    }

    public String getValue() {
        return value;
    }

    public String getDefaultLabel() {
        return defaultLabel;
    }

    public int getLabelId() {
        return labelId;
    }

    public static String getDefaultLabelByValue(String value, Long employeeId, String tenantKey) {
        return Arrays.stream(SalarySendGrantTypeEnum.values()).filter(r -> r.getValue().equals(value)).findFirst()
                .map(SalarySendGrantTypeEnum::getDefaultLabel)
                .orElse(StrUtil.EMPTY);
    }

    public SalarySendGrantTypeEnum fromValue(String value) {
        for (SalarySendGrantTypeEnum salarySendGrantTypeEnum : values()) {
            if (Objects.equals(salarySendGrantTypeEnum.getValue(), value)) {
                return salarySendGrantTypeEnum;
            }
        }
        return null;
    }
}