gaoluyang
3 天以前 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
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
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#SALES_TYPE}
 */
@RequiredArgsConstructor
@Getter
public enum ErpSaleTypeEnum implements ArrayValuable<Integer> {
 
    DOMESTIC(1, "内销"),
    EXPORT(2, "外销"),
    SAMPLE(3, "样品"),
    OTHER(4, "其他");
 
    public static final Integer[] ARRAYS = Arrays.stream(values())
            .map(ErpSaleTypeEnum::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));
    }
 
}