gaoluyang
5 天以前 70ea74cfb981f812bfa4e3ef91843c5ad93f7b27
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
package cn.iocoder.yudao.module.erp.enums;
 
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
 
import java.util.Arrays;
import java.util.Objects;
 
/**
 * ERP 采购类型枚举(采购台账)
 *
 * 字典 {@link DictTypeConstants#PURCHASE_TYPE}
 */
@RequiredArgsConstructor
@Getter
public enum ErpPurchaseTypeEnum implements ArrayValuable<Integer> {
 
    PRODUCTION(1, "生产"),
    OFFICE(2, "办公用品"),
    OTHER(3, "其他");
 
    public static final Integer[] ARRAYS = Arrays.stream(values())
            .map(ErpPurchaseTypeEnum::getType).toArray(Integer[]::new);
 
    /**
     * 类型值
     */
    private final Integer type;
    /**
     * 类型名
     */
    private final String name;
 
    @Override
    public Integer[] array() {
        return ARRAYS;
    }
 
    /**
     * 判断类型值是否合法(为空视为未选择,合法)
     */
    public static boolean isValid(Integer type) {
        if (type == null) {
            return true;
        }
        return Arrays.stream(values()).anyMatch(item -> Objects.equals(item.getType(), type));
    }
 
}