昨天 684e4306a08feeae188070f264148e6765da8dcf
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
package com.ruoyi.account.enums;
 
import com.ruoyi.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
 
/**
 * 往来方类型枚举,对应 payment_record.party_type
 */
@Getter
@AllArgsConstructor
public enum PartyTypeEnum implements BaseEnum<Integer> {
 
    CUSTOMER(1, "客户"),
    SUPPLIER(2, "供应商"),
    OUTSOURCING_PARTNER(3, "合作商");
 
    private final Integer value;
    private final String label;
 
    @Override
    public Integer getCode() {
        return value;
    }
 
    @Override
    public String getValue() {
        return label;
    }
 
    public static PartyTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PartyTypeEnum partyType : values()) {
            if (partyType.getCode().equals(code)) {
                return partyType;
            }
        }
        return null;
    }
 
    public static String getLabelByCode(Integer code) {
        PartyTypeEnum partyType = getByCode(code);
        return partyType == null ? "未知类型" : partyType.getValue();
    }
}