yanghb
2024-12-17 1287337fd0b0c156ec79712f9a600ebeffefe3a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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 "";
    }
}