package com.zzg.common.enums;
|
|
import lombok.AllArgsConstructor;
|
import lombok.Getter;
|
|
import java.util.Objects;
|
|
@Getter
|
@AllArgsConstructor
|
public enum CompensationSubTypeEnum {
|
|
PRICE(1, "单价"),
|
RANGE(2, "区间"),
|
|
|
;
|
private final int code;
|
private final String description;
|
|
public static int getCode(String description) {
|
for (CompensationSubTypeEnum type : CompensationSubTypeEnum.values()) {
|
if (type.getDescription().equalsIgnoreCase(description)) {
|
return type.getCode();
|
}
|
}
|
return 0;
|
}
|
public static String getDescription(Integer key) {
|
if (Objects.isNull(key)) {
|
return "";
|
}
|
for (CompensationSubTypeEnum v : CompensationSubTypeEnum.values()) {
|
if (v.getCode() == key) {
|
return v.getDescription();
|
}
|
}
|
return "";
|
}
|
}
|