【代码优化】InEnum 不必须指定 int 类型,通过泛型指定

This commit is contained in:
puhui999
2025-01-24 17:31:41 +08:00
parent e89e3c946d
commit d83b7cd5b9
87 changed files with 366 additions and 365 deletions

View File

@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.erp.enums;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -15,12 +15,12 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum ErpAuditStatus implements IntArrayValuable {
public enum ErpAuditStatus implements ArrayValuable<Integer> {
PROCESS(10, "未审核"), // 审核中
APPROVE(20, "已审核"); // 审核通过
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpAuditStatus::getStatus).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(ErpAuditStatus::getStatus).toArray(Integer[]::new);
/**
* 状态
@@ -32,7 +32,7 @@ public enum ErpAuditStatus implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.erp.enums.common;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -13,7 +13,7 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum ErpBizTypeEnum implements IntArrayValuable {
public enum ErpBizTypeEnum implements ArrayValuable<Integer> {
PURCHASE_ORDER(10, "采购订单"),
PURCHASE_IN(11, "采购入库"),
@@ -24,7 +24,7 @@ public enum ErpBizTypeEnum implements IntArrayValuable {
SALE_RETURN(22, "销售退货"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpBizTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(ErpBizTypeEnum::getType).toArray(Integer[]::new);
/**
* 类型
@@ -36,7 +36,7 @@ public enum ErpBizTypeEnum implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.erp.enums.stock;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -13,7 +13,7 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum ErpStockRecordBizTypeEnum implements IntArrayValuable {
public enum ErpStockRecordBizTypeEnum implements ArrayValuable<Integer> {
OTHER_IN(10, "其它入库"),
OTHER_IN_CANCEL(11, "其它入库(作废)"),
@@ -44,7 +44,7 @@ public enum ErpStockRecordBizTypeEnum implements IntArrayValuable {
PURCHASE_RETURN_CANCEL(81, "采购退货出库(作废)"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpStockRecordBizTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(ErpStockRecordBizTypeEnum::getType).toArray(Integer[]::new);
/**
* 类型
@@ -56,7 +56,7 @@ public enum ErpStockRecordBizTypeEnum implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}