puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
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
package com.stylefeng.guns.modular.system.enums;
 
 
 
/**
 * @Description 优惠券状态枚举
 * @Author xiaochen
 * @Date 2023/02/15 9:42
 */
public enum CouponStatusEnum {
 
    UNISSUED(1, "未发放"),
    NOT_USED(2, "未使用"),
    USED(3, "已使用"),
    EXPIRED(4,"已过期");
 
    private String desc;
 
 
    private int code;
 
 
    CouponStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }
 
    public String getDesc() {
        return desc;
    }
 
    public int getCode() {
        return code;
    }
 
    /**
     * 通过code获取枚举
     *
     * @param code
     * @return
     */
    public static CouponStatusEnum fromCode(Integer code) {
        CouponStatusEnum[] resultTypes = CouponStatusEnum.values();
        for (CouponStatusEnum resultType : resultTypes) {
            if (code.equals(resultType.getCode())) {
                return resultType;
            }
        }
        return null;
    }
 
}