import { Module } from '@nestjs/common';
import { ScheduleModule } from '@nestjs/schedule';
import { InfrastructureModule } from '../infrastructure/infrastructure.module';

// Event Handlers
import { UserSyncedHandler } from './event-handlers/user-synced.handler';
import { ReferralSyncedHandler } from './event-handlers/referral-synced.handler';
import { AdoptionSyncedHandler } from './event-handlers/adoption-synced.handler';
import { CDCEventDispatcher } from './event-handlers/cdc-event-dispatcher';
// [2026-02-19] 纯新增：转让所有权事件处理器
import { TransferOwnershipHandler } from './event-handlers/transfer-ownership.handler';

// Services
import { ContributionCalculationService } from './services/contribution-calculation.service';
import { ContributionDistributionPublisherService } from './services/contribution-distribution-publisher.service';
import { ContributionRateService } from './services/contribution-rate.service';
import { BonusClaimService } from './services/bonus-claim.service';
import { SnapshotService } from './services/snapshot.service';
// [2026-02-19] 纯新增：转让算力调整服务
import { TransferAdjustmentService } from './services/transfer-adjustment.service';

// Queries
import { GetContributionAccountQuery } from './queries/get-contribution-account.query';
import { GetContributionStatsQuery } from './queries/get-contribution-stats.query';
import { GetContributionRankingQuery } from './queries/get-contribution-ranking.query';
import { GetPlantingLedgerQuery } from './queries/get-planting-ledger.query';
import { GetTeamTreeQuery } from './queries/get-team-tree.query';

// Schedulers
import { ContributionScheduler } from './schedulers/contribution.scheduler';

@Module({
  imports: [
    ScheduleModule.forRoot(),
    InfrastructureModule,
  ],
  providers: [
    // Event Handlers
    UserSyncedHandler,
    ReferralSyncedHandler,
    AdoptionSyncedHandler,
    CDCEventDispatcher,
    TransferOwnershipHandler, // [2026-02-19] 纯新增：转让所有权事件处理器

    // Services
    ContributionCalculationService,
    ContributionDistributionPublisherService,
    ContributionRateService,
    BonusClaimService,
    SnapshotService,
    TransferAdjustmentService, // [2026-02-19] 纯新增：转让算力调整服务

    // Queries
    GetContributionAccountQuery,
    GetContributionStatsQuery,
    GetContributionRankingQuery,
    GetPlantingLedgerQuery,
    GetTeamTreeQuery,

    // Schedulers
    ContributionScheduler,
  ],
  exports: [
    ContributionCalculationService,
    ContributionRateService,
    SnapshotService,
    GetContributionAccountQuery,
    GetContributionStatsQuery,
    GetContributionRankingQuery,
    GetPlantingLedgerQuery,
    GetTeamTreeQuery,
  ],
})
export class ApplicationModule {}
