郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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
package com.gk.hotwork.Domain.Enum;
 
import com.gk.hotwork.Domain.Exception.BusinessException;
 
public enum Etype {
 
    E_60(1, "60吨位"),
    E_130(2, "130吨位"),
 
    ;
 
 
    int code;
    String msg;
 
    Etype(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
 
    public static Etype parse(Integer code) {
        if (code == null) throw new BusinessException("参数为空");
        for (Etype etype : Etype.values()) {
            if (etype.code == code) {
                return etype;
            }
        }
        throw new BusinessException("找不到对应类型");
    }
 
}