package com.yhy.module.core.enums.quota;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 定额调整类型枚举
 */
@Getter
@AllArgsConstructor
public enum QuotaAdjustmentTypeEnum {

    PERCENTAGE(1, "percentage", "百分比调整"),
    FIXED_VALUE(2, "fixed_value", "固定值调整"),
    FORMULA(3, "formula", "公式计算"),
    CONDITIONAL(4, "conditional", "条件调整"),
    MATERIAL_ADJUSTMENT(5, "material_adjustment", "增减材料消耗量"),
    DYNAMIC_ADJUSTMENT(6, "dynamic_adjustment", "动态调整人才机消耗量"),
    COEFFICIENT_ADJUSTMENT(7, "coefficient_adjustment", "调整人才机消耗量"),
    DYNAMIC_MERGE_QUOTA(8, "dynamic_merge_quota", "动态合并定额");

    private final Integer type;
    private final String code;
    private final String name;

    public static QuotaAdjustmentTypeEnum valueOf(Integer type) {
        return Arrays.stream(values())
                .filter(e -> e.getType().equals(type))
                .findFirst()
                .orElse(null);
    }

    public static QuotaAdjustmentTypeEnum valueOfCode(String code) {
        return Arrays.stream(values())
                .filter(e -> e.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
