/**
 * 基础设施模块
 * [2026-01-04] 更新：新增 WalletServiceClient, RewardServiceClient 用于系统账户报表统计
 * 回滚方式：删除 HttpModule 导入及 WalletServiceClient, RewardServiceClient 的注册
 */
import { Module } from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import { PrismaService } from './persistence/prisma/prisma.service';
import { ReportDefinitionRepository } from './persistence/repositories/report-definition.repository.impl';
import { ReportSnapshotRepository } from './persistence/repositories/report-snapshot.repository.impl';
import { ReportFileRepository } from './persistence/repositories/report-file.repository.impl';
import { DashboardStatsSnapshotRepository } from './persistence/repositories/dashboard-stats-snapshot.repository.impl';
import { DashboardTrendDataRepository } from './persistence/repositories/dashboard-trend-data.repository.impl';
import { SystemActivityRepository } from './persistence/repositories/system-activity.repository.impl';
import { RealtimeStatsRepository } from './persistence/repositories/realtime-stats.repository.impl';
import { GlobalStatsRepository } from './persistence/repositories/global-stats.repository.impl';
import {
  REPORT_DEFINITION_REPOSITORY,
  REPORT_SNAPSHOT_REPOSITORY,
  REPORT_FILE_REPOSITORY,
  DASHBOARD_STATS_SNAPSHOT_REPOSITORY,
  DASHBOARD_TREND_DATA_REPOSITORY,
  SYSTEM_ACTIVITY_REPOSITORY,
  REALTIME_STATS_REPOSITORY,
  GLOBAL_STATS_REPOSITORY,
} from '../domain/repositories';
import { LeaderboardServiceClient } from './external/leaderboard-service/leaderboard-service.client';
import { PlantingServiceClient } from './external/planting-service/planting-service.client';
import { AuthorizationServiceClient } from './external/authorization-service/authorization-service.client';
import { IdentityServiceClient } from './external/identity-service/identity-service.client';
// [2026-01-04] 新增：系统账户报表统计 HTTP 客户端
import { WalletServiceClient } from './external/wallet-service/wallet-service.client';
import { RewardServiceClient } from './external/reward-service/reward-service.client';
import { ExportModule } from './export/export.module';
import { RedisModule } from './redis/redis.module';

@Module({
  imports: [
    // [2026-01-04] 新增：HttpModule 用于系统账户报表统计的 HTTP 调用
    HttpModule.register({
      timeout: 30000,
      maxRedirects: 5,
    }),
    ExportModule,
    RedisModule,
  ],
  providers: [
    PrismaService,
    {
      provide: REPORT_DEFINITION_REPOSITORY,
      useClass: ReportDefinitionRepository,
    },
    {
      provide: REPORT_SNAPSHOT_REPOSITORY,
      useClass: ReportSnapshotRepository,
    },
    {
      provide: REPORT_FILE_REPOSITORY,
      useClass: ReportFileRepository,
    },
    {
      provide: DASHBOARD_STATS_SNAPSHOT_REPOSITORY,
      useClass: DashboardStatsSnapshotRepository,
    },
    {
      provide: DASHBOARD_TREND_DATA_REPOSITORY,
      useClass: DashboardTrendDataRepository,
    },
    {
      provide: SYSTEM_ACTIVITY_REPOSITORY,
      useClass: SystemActivityRepository,
    },
    {
      provide: REALTIME_STATS_REPOSITORY,
      useClass: RealtimeStatsRepository,
    },
    {
      provide: GLOBAL_STATS_REPOSITORY,
      useClass: GlobalStatsRepository,
    },
    LeaderboardServiceClient,
    PlantingServiceClient,
    AuthorizationServiceClient,
    IdentityServiceClient,
    // [2026-01-04] 新增：系统账户报表统计 HTTP 客户端
    WalletServiceClient,
    RewardServiceClient,
  ],
  exports: [
    PrismaService,
    REPORT_DEFINITION_REPOSITORY,
    REPORT_SNAPSHOT_REPOSITORY,
    REPORT_FILE_REPOSITORY,
    DASHBOARD_STATS_SNAPSHOT_REPOSITORY,
    DASHBOARD_TREND_DATA_REPOSITORY,
    SYSTEM_ACTIVITY_REPOSITORY,
    REALTIME_STATS_REPOSITORY,
    GLOBAL_STATS_REPOSITORY,
    LeaderboardServiceClient,
    PlantingServiceClient,
    AuthorizationServiceClient,
    IdentityServiceClient,
    // [2026-01-04] 新增：系统账户报表统计 HTTP 客户端
    WalletServiceClient,
    RewardServiceClient,
    ExportModule,
    RedisModule,
  ],
})
export class InfrastructureModule {}
