import { Module } from '@nestjs/common';
import { ScheduleModule } from '@nestjs/schedule';

// Services
import { SystemAccountService } from './services/system-account.service';
import { PoolAccountService } from './services/pool-account.service';
import { UserWalletService } from './services/user-wallet.service';
import { ContributionWalletService } from './services/contribution-wallet.service';

// Schedulers
import { OutboxScheduler } from './schedulers/outbox.scheduler';
import { ContributionExpiryScheduler } from './schedulers/contribution-expiry.scheduler';

// Consumers (从 InfrastructureModule 移过来，因为依赖应用服务)
import { ContributionDistributionConsumer } from '../infrastructure/kafka/consumers/contribution-distribution.consumer';
import { UserRegisteredConsumer } from '../infrastructure/kafka/consumers/user-registered.consumer';
import { MiningDistributionConsumer } from '../infrastructure/kafka/consumers/mining-distribution.consumer';
import { BurnConsumer } from '../infrastructure/kafka/consumers/burn.consumer';
import { ManualMiningConsumer } from '../infrastructure/kafka/consumers/manual-mining.consumer';
import { PoolAccountDepositConsumer } from '../infrastructure/kafka/consumers/pool-account-deposit.consumer';

@Module({
  imports: [ScheduleModule.forRoot()],
  controllers: [
    // Kafka Consumers (微服务消息处理器需要是 Controller)
    ContributionDistributionConsumer,
    UserRegisteredConsumer,
    MiningDistributionConsumer,
    BurnConsumer,
    ManualMiningConsumer,
    PoolAccountDepositConsumer,
  ],
  providers: [
    // Services
    SystemAccountService,
    PoolAccountService,
    UserWalletService,
    ContributionWalletService,
    // Schedulers
    OutboxScheduler,
    ContributionExpiryScheduler,
  ],
  exports: [
    SystemAccountService,
    PoolAccountService,
    UserWalletService,
    ContributionWalletService,
  ],
})
export class ApplicationModule {}
