1
dd
2025-10-21 8dcc757d17dd3bed804167a0aa640a978f10022c
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.ruoyi.system.domain;
 
/**
 * 资金操作类型枚举
 */
public enum OperationType {
 
    /**
     * 后台充值 - 1
     */
    ADMIN_RECHARGE(1, "后台充值"),
 
    /**
     * 后台扣款 - 2
     */
    ADMIN_DEDUCTION(2, "后台扣款"),
 
    /**
     * 用户下单 - 3
     */
    USER_ORDER(3, "用户下单"),
 
    /**
     * 退款 - 4
     */
    REFUND(4, "退款");
 
    private final int code;
    private final String description;
 
    OperationType(int code, String description) {
        this.code = code;
        this.description = description;
    }
 
    public int getCode() {
        return code;
    }
 
    public String getDescription() {
        return description;
    }
 
    /**
     * 根据代码获取操作类型枚举
     * @param code 操作类型代码
     * @return 对应的枚举值,如果不存在返回null
     */
    public static OperationType getByCode(int code) {
        for (OperationType type : values()) {
            if (type.getCode() == code) {
                return type;
            }
        }
        return null;
    }
 
    /**
     * 根据描述获取操作类型枚举
     * @param description 操作类型描述
     * @return 对应的枚举值,如果不存在返回null
     */
    public static OperationType getByDescription(String description) {
        for (OperationType type : values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        return null;
    }
 
}