package com.engine.salary.enums.salaryarchive;

import com.engine.salary.enums.BaseEnum;
import com.engine.salary.util.SalaryI18nUtil;

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

/**
 * 薪资项目的字段类型
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
public enum SalaryArchiveFieldTypeEnum implements BaseEnum<String> {
    NUMBER("number", "数值", 87625),
    STRING("string", "字符", 105093),
    ;

    private String value;

    private String defaultLabel;

    private int labelId;

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

    @Override
    public String getValue() {
        return this.value;
    }

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

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

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

    public static String getNameByValue(String value) {
        Optional<SalaryArchiveFieldTypeEnum> optional = Arrays.stream(SalaryArchiveFieldTypeEnum.values()).filter(r->r.getValue().equals(value)).findFirst();
        return optional.map(Enum::name).orElse("");
    }
}
