# CaseResultEnum.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 CaseResultEnum {

        /**
         * win
         */
        WIN(1, "chargeback.win"),

        /**
         * loss
         */
        LOSS(2, "chargeback.loss"),

        /**
         * frozen
         */
        FROZEN(3, "chargeback.frozen"),

        /**
         * processed
         */
        PROCESSED(4, "chargeback.processed");

        private final int code;

        private final String desc;

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

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

    }