# ReportTypeEnum.java

    package cloud.wconnect.workperformance.cons.monthlyreport;

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

    import java.text.MessageFormat;
    import java.util.Arrays;
    import java.util.Optional;

    /**
     * 报告类型枚举类
     *
     * @author lichen
     * @date 2023/9/6
     */
    @AllArgsConstructor
    @Getter
    public enum ReportTypeEnum {

        /**
         * OPERATING STATEMENT 报告
         */
        OPERATING_STATEMENT(1);

        /**
         * 报告类型
         */
        private int reportType;

        /**
         * 校验报告类型是否合法
         *
         * @param reportType 报告类型
         * @return void
         * @author lichen
         * @date 2023/9/6
         */
        public static void verifyValidity(int reportType) {
            Optional<ReportTypeEnum> optional = Arrays.stream(ReportTypeEnum.values())
                    .filter(item -> item.getReportType() == reportType).findFirst();
            if (optional.isEmpty()) {
                throw new BadRequestException(BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getI18nCode(), BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(),
                        MessageFormat.format("The report type is invalid, reportType:{0}", reportType));
            }
        }
    }