package com.engine.salary.enums.taxagent;

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 TaxAgentRangeTypeEnum {

    TAXAGENT(1, "个税扣缴义务人", 86184),
    SUBADMIN(2, "分管理员", 106283);

    private int value;

    private String defaultLabel;

    private int labelId;

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

    public int getValue() {
        return value;
    }

    public String getDefaultLabel() {
        return defaultLabel;
    }

    public int getLabelId() {
        return labelId;
    }

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