【代码优化】InEnum 不必须指定 int 类型,通过泛型指定
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.product.enums.comment;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -13,13 +13,13 @@ import java.util.Arrays;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProductCommentAuditStatusEnum implements IntArrayValuable {
|
||||
public enum ProductCommentAuditStatusEnum implements ArrayValuable<Integer> {
|
||||
|
||||
NONE(1, "待审核"),
|
||||
APPROVE(2, "审批通过"),
|
||||
REJECT(2, "审批不通过"),;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentAuditStatusEnum::getStatus).toArray();
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(ProductCommentAuditStatusEnum::getStatus).toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
* 审批状态
|
||||
@@ -31,7 +31,7 @@ public enum ProductCommentAuditStatusEnum implements IntArrayValuable {
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.product.enums.comment;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Arrays;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProductCommentScoresEnum implements IntArrayValuable {
|
||||
public enum ProductCommentScoresEnum implements ArrayValuable<Integer> {
|
||||
|
||||
ONE(1, "1星"),
|
||||
TWO(2, "2星"),
|
||||
@@ -21,7 +21,7 @@ public enum ProductCommentScoresEnum implements IntArrayValuable {
|
||||
FOUR(4, "4星"),
|
||||
FIVE(5, "5星");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductCommentScoresEnum::getScores).toArray();
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(ProductCommentScoresEnum::getScores).toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
* 星级
|
||||
@@ -34,7 +34,7 @@ public enum ProductCommentScoresEnum implements IntArrayValuable {
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.module.product.enums.spu;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -13,13 +13,13 @@ import java.util.Arrays;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ProductSpuStatusEnum implements IntArrayValuable {
|
||||
public enum ProductSpuStatusEnum implements ArrayValuable<Integer> {
|
||||
|
||||
RECYCLE(-1, "回收站"),
|
||||
DISABLE(0, "下架"),
|
||||
ENABLE(1, "上架");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductSpuStatusEnum::getStatus).toArray();
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(ProductSpuStatusEnum::getStatus).toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
* 状态
|
||||
@@ -31,7 +31,7 @@ public enum ProductSpuStatusEnum implements IntArrayValuable {
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user