# DailyRevenueUpdateFieldEnum.java

    package cloud.wconnect.rateshop.cons.revenue;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import lombok.AllArgsConstructor;
    import lombok.Getter;

    import java.util.Arrays;
    import java.util.List;

    /**
     * Daily Summary 更新的字段枚举类
     *
     * @author lichen
     * @date 2025/1/9
     */
    @AllArgsConstructor
    @Getter
    public enum DailyRevenueUpdateFieldEnum {

        PRICE(1, ""),
        TOTAL_ROOM_SOLD(2, "totalRoomsSold"),
        ROOM_AVAILABLE(3, "roomsAvailable"),
        OCC(4, "occ"),
        TA(5, "ta"),
        TRANSIENTPICKUP(6, "transientPickUp"),
        GROUPPICKUP(7, "groupPickUp"),
        OOOROOMS(8, "oooRooms"),
        NOSHOW(9, "noShow"),
        CANCELLED(10, "cancelled"),
        ADR(11, "adr"),
        MEPSGROUPTOTAL(12, "mepsGroupTotal");

        /**
         * 更新的字段ID
         */
        private int fieldId;

        /**
         * revenue_daily_summary_manual表字段名称(小驼峰形式)
         */
        private String fieldName;

        /**
         * 校验fieldId 是否正确
         *
         * @param updateFieldList 字段ID
         * @return void
         * @author lichen
         * @date 2025/1/9
         */
        public static void checkValid(List<Integer> updateFieldList) {
            List<Integer> fieldIds = Arrays.stream(DailyRevenueUpdateFieldEnum.values()).map(DailyRevenueUpdateFieldEnum::getFieldId).toList();
            if (updateFieldList.stream().anyMatch(updateField -> !fieldIds.contains(updateField))) {
                throw new BadRequestException(BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getI18nCode(),
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                        "The updateFields incorrect; updateFieldList:" + updateFieldList);
            }
        }

        /**
         * 获取字段名称
         *
         * @param fieldId 字段ID
         * @return java.lang.String
         * @author lichen
         * @date 2025/1/10
         */
        public static String getFieldNameById(Integer fieldId) {
            return Arrays.stream(DailyRevenueUpdateFieldEnum.values()).filter(item -> item.getFieldId() == fieldId)
                    .map(DailyRevenueUpdateFieldEnum::getFieldName)
                    .findFirst().orElse("");

        }
    }