【代码优化】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.trade.enums.aftersale;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -18,7 +18,7 @@ import static cn.hutool.core.util.ArrayUtil.firstMatch;
*/
@AllArgsConstructor
@Getter
public enum AfterSaleStatusEnum implements IntArrayValuable {
public enum AfterSaleStatusEnum implements ArrayValuable<Integer> {
/**
* 【申请售后】
@@ -54,7 +54,7 @@ public enum AfterSaleStatusEnum implements IntArrayValuable {
SELLER_REFUSE(63,"卖家拒绝收货", "商家拒绝收货"), // 有赞的状态提示:商家拒绝收货,不同意退款
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleStatusEnum::getStatus).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(AfterSaleStatusEnum::getStatus).toArray(Integer[]::new);
/**
* 进行中的售后状态
@@ -84,7 +84,7 @@ public enum AfterSaleStatusEnum implements IntArrayValuable {
private final String content;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.trade.enums.aftersale;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -13,12 +13,12 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum AfterSaleTypeEnum implements IntArrayValuable {
public enum AfterSaleTypeEnum implements ArrayValuable<Integer> {
IN_SALE(10, "售中退款"), // 交易完成前买家申请退款
AFTER_SALE(20, "售后退款"); // 交易完成后买家申请退款
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(AfterSaleTypeEnum::getType).toArray(Integer[]::new);
/**
* 类型
@@ -30,7 +30,7 @@ public enum AfterSaleTypeEnum 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.trade.enums.aftersale;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -13,12 +13,12 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum AfterSaleWayEnum implements IntArrayValuable {
public enum AfterSaleWayEnum implements ArrayValuable<Integer> {
REFUND(10, "仅退款"),
RETURN_AND_REFUND(20, "退货退款");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AfterSaleWayEnum::getWay).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(AfterSaleWayEnum::getWay).toArray(Integer[]::new);
/**
* 方式
@@ -30,7 +30,7 @@ public enum AfterSaleWayEnum 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.trade.enums.brokerage;
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;
*/
@AllArgsConstructor
@Getter
public enum BrokerageBindModeEnum implements IntArrayValuable {
public enum BrokerageBindModeEnum implements ArrayValuable<Integer> {
/**
* 只要用户没有推广人,随时都可以绑定分销关系
@@ -29,7 +29,7 @@ public enum BrokerageBindModeEnum implements IntArrayValuable {
OVERRIDE(3, "覆盖绑定"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageBindModeEnum::getMode).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(BrokerageBindModeEnum::getMode).toArray(Integer[]::new);
/**
* 模式
@@ -41,7 +41,7 @@ public enum BrokerageBindModeEnum 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.trade.enums.brokerage;
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;
*/
@AllArgsConstructor
@Getter
public enum BrokerageEnabledConditionEnum implements IntArrayValuable {
public enum BrokerageEnabledConditionEnum implements ArrayValuable<Integer> {
/**
* 所有用户都可以分销
@@ -25,7 +25,7 @@ public enum BrokerageEnabledConditionEnum implements IntArrayValuable {
ADMIN(2, "指定分销"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageEnabledConditionEnum::getCondition).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(BrokerageEnabledConditionEnum::getCondition).toArray(Integer[]::new);
/**
* 模式
@@ -37,7 +37,7 @@ public enum BrokerageEnabledConditionEnum 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.trade.enums.brokerage;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -13,14 +13,14 @@ import java.util.Arrays;
*/
@AllArgsConstructor
@Getter
public enum BrokerageRecordBizTypeEnum implements IntArrayValuable {
public enum BrokerageRecordBizTypeEnum implements ArrayValuable<Integer> {
ORDER(1, "获得推广佣金", "获得推广佣金 {}", true),
WITHDRAW(2, "提现申请", "提现申请扣除佣金 {}", false),
WITHDRAW_REJECT(3, "提现申请驳回", "提现申请驳回,返还佣金 {}", true),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordBizTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(BrokerageRecordBizTypeEnum::getType).toArray(Integer[]::new);
/**
* 类型
@@ -40,7 +40,7 @@ public enum BrokerageRecordBizTypeEnum implements IntArrayValuable {
private final boolean add;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.trade.enums.brokerage;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -13,14 +13,14 @@ import java.util.Arrays;
*/
@AllArgsConstructor
@Getter
public enum BrokerageRecordStatusEnum implements IntArrayValuable {
public enum BrokerageRecordStatusEnum implements ArrayValuable<Integer> {
WAIT_SETTLEMENT(0, "待结算"),
SETTLEMENT(1, "已结算"),
CANCEL(2, "已取消"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageRecordStatusEnum::getStatus).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(BrokerageRecordStatusEnum::getStatus).toArray(Integer[]::new);
/**
* 状态
@@ -32,7 +32,7 @@ public enum BrokerageRecordStatusEnum 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.trade.enums.brokerage;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -14,7 +14,7 @@ import java.util.Arrays;
*/
@AllArgsConstructor
@Getter
public enum BrokerageWithdrawStatusEnum implements IntArrayValuable {
public enum BrokerageWithdrawStatusEnum implements ArrayValuable<Integer> {
AUDITING(0, "审核中"),
AUDIT_SUCCESS(10, "审核通过"),
@@ -23,7 +23,7 @@ public enum BrokerageWithdrawStatusEnum implements IntArrayValuable {
WITHDRAW_FAIL(21, "提现失败"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawStatusEnum::getStatus).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(BrokerageWithdrawStatusEnum::getStatus).toArray(Integer[]::new);
/**
* 状态
@@ -35,7 +35,7 @@ public enum BrokerageWithdrawStatusEnum 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.trade.enums.brokerage;
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;
*/
@AllArgsConstructor
@Getter
public enum BrokerageWithdrawTypeEnum implements IntArrayValuable {
public enum BrokerageWithdrawTypeEnum implements ArrayValuable<Integer> {
WALLET(1, "钱包"),
BANK(2, "银行卡"),
@@ -22,7 +22,7 @@ public enum BrokerageWithdrawTypeEnum implements IntArrayValuable {
WECHAT_API(5, "微信零钱"), // 自动打款,通过微信转账 API
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageWithdrawTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(BrokerageWithdrawTypeEnum::getType).toArray(Integer[]::new);
/**
* 类型
@@ -34,7 +34,7 @@ public enum BrokerageWithdrawTypeEnum implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.trade.enums.delivery;
import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -14,13 +14,13 @@ import java.util.Arrays;
*/
@AllArgsConstructor
@Getter
public enum DeliveryExpressChargeModeEnum implements IntArrayValuable {
public enum DeliveryExpressChargeModeEnum implements ArrayValuable<Integer> {
COUNT(1, "按件"),
WEIGHT(2,"按重量"),
VOLUME(3, "按体积");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryExpressChargeModeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(DeliveryExpressChargeModeEnum::getType).toArray(Integer[]::new);
/**
* 类型
@@ -32,7 +32,7 @@ public enum DeliveryExpressChargeModeEnum implements IntArrayValuable {
private final String desc;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.trade.enums.delivery;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -13,12 +13,12 @@ import java.util.Arrays;
*/
@Getter
@AllArgsConstructor
public enum DeliveryTypeEnum implements IntArrayValuable {
public enum DeliveryTypeEnum implements ArrayValuable<Integer> {
EXPRESS(1, "快递发货"),
PICK_UP(2, "用户自提"),;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(DeliveryTypeEnum::getType).toArray(Integer[]::new);
/**
* 配送方式
@@ -30,7 +30,7 @@ public enum DeliveryTypeEnum 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.trade.enums.order;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -13,14 +13,14 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum TradeOrderCancelTypeEnum implements IntArrayValuable {
public enum TradeOrderCancelTypeEnum implements ArrayValuable<Integer> {
PAY_TIMEOUT(10, "超时未支付"),
AFTER_SALE_CLOSE(20, "退款关闭"),
MEMBER_CANCEL(30, "买家取消"),
COMBINATION_CLOSE(40, "拼团关闭");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderCancelTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeOrderCancelTypeEnum::getType).toArray(Integer[]::new);
/**
* 关闭类型
@@ -32,7 +32,7 @@ public enum TradeOrderCancelTypeEnum implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.trade.enums.order;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -14,13 +14,13 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum TradeOrderItemAfterSaleStatusEnum implements IntArrayValuable {
public enum TradeOrderItemAfterSaleStatusEnum implements ArrayValuable<Integer> {
NONE(0, "未售后"),
APPLY(10, "售后中"),
SUCCESS(20, "售后成功");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderItemAfterSaleStatusEnum::getStatus).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeOrderItemAfterSaleStatusEnum::getStatus).toArray(Integer[]::new);
/**
* 状态值
@@ -32,7 +32,7 @@ public enum TradeOrderItemAfterSaleStatusEnum 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.trade.enums.order;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -13,13 +13,13 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum TradeOrderRefundStatusEnum implements IntArrayValuable {
public enum TradeOrderRefundStatusEnum implements ArrayValuable<Integer> {
NONE(0, "未退款"),
PART(10, "部分退款"),
ALL(20, "全部退款");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderRefundStatusEnum::getStatus).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeOrderRefundStatusEnum::getStatus).toArray(Integer[]::new);
/**
* 状态值
@@ -31,7 +31,7 @@ public enum TradeOrderRefundStatusEnum implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.trade.enums.order;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -15,7 +15,7 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum TradeOrderStatusEnum implements IntArrayValuable {
public enum TradeOrderStatusEnum implements ArrayValuable<Integer> {
UNPAID(0, "待支付"),
UNDELIVERED(10, "待发货"),
@@ -23,7 +23,7 @@ public enum TradeOrderStatusEnum implements IntArrayValuable {
COMPLETED(30, "已完成"),
CANCELED(40, "已取消");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderStatusEnum::getStatus).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeOrderStatusEnum::getStatus).toArray(Integer[]::new);
/**
* 状态值
@@ -35,7 +35,7 @@ public enum TradeOrderStatusEnum implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}

View File

@@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.trade.enums.order;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import cn.iocoder.yudao.framework.common.core.ArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -14,7 +14,7 @@ import java.util.Arrays;
*/
@RequiredArgsConstructor
@Getter
public enum TradeOrderTypeEnum implements IntArrayValuable {
public enum TradeOrderTypeEnum implements ArrayValuable<Integer> {
NORMAL(0, "普通订单"),
SECKILL(1, "秒杀订单"),
@@ -23,7 +23,7 @@ public enum TradeOrderTypeEnum implements IntArrayValuable {
POINT(4, "积分商城"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TradeOrderTypeEnum::getType).toArray();
public static final Integer[] ARRAYS = Arrays.stream(values()).map(TradeOrderTypeEnum::getType).toArray(Integer[]::new);
/**
* 类型
@@ -35,7 +35,7 @@ public enum TradeOrderTypeEnum implements IntArrayValuable {
private final String name;
@Override
public int[] array() {
public Integer[] array() {
return ARRAYS;
}