# TrendSourceDatasourceEnum.java

    package cloud.wconnect.rateshop.cons.rateshop;

    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;

    /**
     * 需求趋势源枚举类
     *
     * @author lichen
     * @date 2024/6/7
     */
    @Getter
    @AllArgsConstructor
    public enum TrendSourceDatasourceEnum {

        AGODA(1, "www.agoda.com");

        /**
         * 数据源id
         */
        private int datasourceId;

        /**
         * 域名
         */
        private String domainName;

        /**
         * 校验datasourceId是否合法
         *
         * @param datasourceId 数据源id
         * @return void
         * @author lichen
         * @date 2024/6/7
         */
        public static void checkDatasourceId(int datasourceId) {
            List<Integer> datasourceIds = Arrays.stream(TrendSourceDatasourceEnum.values()).map(TrendSourceDatasourceEnum::getDatasourceId).toList();
            if (!datasourceIds.contains(datasourceId)) {
                throw new BadRequestException(BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getI18nCode(),
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "The datasourceId must between in [1:www.agoda.com]");
            }
        }
    }