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;
|
}
|
|
}
|