# BookingStatusEnum.java

    package cloud.wconnect.rateshop.cons.rateshop;

    import cloud.wconnect.commonlib.cons.BaseConstant;
    import lombok.AllArgsConstructor;
    import lombok.Getter;

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

    /**
     * 枚举类: 预定状态
     *
     * @author zc
     * @date 2024/03/23
     */
    @Getter
    @AllArgsConstructor
    public enum BookingStatusEnum {

        DEFINITE(1, "DEF", "rate-shop.booking-status.definite"),
        TENTATIVE(2, "TEN", "rate-shop.booking-status.tentative"),
        PROSPECT(3, "PRO", "rate-shop.booking-status.prospect"),
        CANCELLED(4, "CAN", "rate-shop.booking-status.cancelled");

        private final int code;

        private final String symbol;

        private final String i18nCode;

        /**
         * 获取 code
         *
         * @param symbol 标识
         * @return code
         * @author zc
         * @date 2024/3/23
         */
        public static int getCodeBySymbol(String symbol) {
            Optional<BookingStatusEnum> optional = Arrays.stream(BookingStatusEnum.values())
                    .filter(item -> item.getSymbol().equals(symbol)).findFirst();
            return optional.map(BookingStatusEnum::getCode).orElse(BaseConstant.ZERO);
        }
    }