package com.engine.salary.enums.salarysend;

import com.engine.salary.enums.BaseEnum;
import com.engine.salary.util.SalaryI18nUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@AllArgsConstructor
@Getter
public enum SalarySendRangeTypeEnum implements BaseEnum<Integer> {

    INCLUDE_OBJ(1, "对象", 90396),
    EXCLUDE_OBJ(2, "对象中排除", 142728);

    private final int value;

    private final String defaultLabel;

    private final int labelId;

    @Override
    public Integer getLabelId() {
        return labelId;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getDefaultLabel() {
        return defaultLabel;
    }

    public static String getDefaultLabelByValue(Integer value, Long employeeId, String tenantKey) {
        Optional<SalarySendRangeTypeEnum> optional = Arrays.stream(SalarySendRangeTypeEnum.values()).filter(r->Integer.valueOf(r.getValue()).equals(value)).findFirst();
        return optional.isPresent()? SalaryI18nUtil.getI18nLabel(optional.get().getLabelId(),  optional.get().getDefaultLabel()):"";
    }

    public static SalarySendRangeTypeEnum fromValue(int value) {
        for (SalarySendRangeTypeEnum salarySendRangeTypeEnum : values()) {
            boolean equals = salarySendRangeTypeEnum.getValue().equals(value);
            if (equals) {
                return salarySendRangeTypeEnum;
            }
        }
        return null;
    }
}
