liulin
2025-07-02 b9f0f641b85bbbfe74fc23efe4f4965586d9e3af
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.lunhan.water.entity.enums;
 
import java.util.Arrays;
import java.util.Objects;
 
public enum EPayType {
    CASH_PAY("现金", 1),
    WX_PAY("微信", 2),
    ALI_PAY("支付宝", 3),
    BALANCE("余额", 4)
    ;
 
    /**
     * 枚举描述
     */
    private String desc;
    /**
     * 枚举值
     */
    private Integer value;
 
    public Integer getValue() {
        return value;
    }
    public String getDesc() {
        return desc;
    }
 
    /**
     * 构造方法
     * @param desc 枚举描述
     * @param value 枚举值
     */
    EPayType(String desc, Integer value) {
        this.desc = desc;
        this.value = value;
    }
 
    /**
     * 根据值获取枚举
     *
     * @param value 枚举值
     */
    public static EPayType getByValue(Integer value) {
        return Arrays.stream(EPayType.values())
                .filter(e -> Objects.equals(e.getValue(), value))
                .findAny()
                .orElse(null);
    }
 
    @Override
    public String toString() {
        return "EPayType{" +
                "desc='" + desc + '\'' +
                ", value=" + value +
                '}';
    }
}