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));
|
}
|
|
}
|