# CaseActionEnum.java

    package cloud.wconnect.finance.cons.chargeback;

    import lombok.AllArgsConstructor;
    import lombok.Getter;

    import java.util.Arrays;
    import java.util.Objects;
    import java.util.Optional;

    /**
     * @author yyt
     * 2023/8/29
     */
    @AllArgsConstructor
    @Getter
    public enum CaseActionEnum {

        /**
         * accept
         */
        ACCEPT(1, "chargeback.accept"),

        /**
         * dispute
         */
        DISPUTE(2, "chargeback.dispute");

        private final int code;
        private final String desc;

        /**
         * excel 中显示 action
         */
        public static String getActionDesc(Integer action) {
            Optional<CaseActionEnum> optional = Arrays.stream(values()).filter(item -> item.code == action).findFirst();
            return optional.isPresent() ? optional.get().getDesc() : "";
        }

        /**
         * 邮件中显示 action
         */
        public static String getActionDescForEmail(Integer action) {
            if(Objects.isNull(action)){
                return "--";
            }
            Optional<CaseActionEnum> optional = Arrays.stream(values()).filter(item -> item.code == action).findFirst();
            return optional.isPresent() ? optional.get().getDesc() : "--";
        }

    }