import { Module, OnModuleInit } from '@nestjs/common';
import { InfrastructureModule } from '../infrastructure/infrastructure.module';
import { AuthService } from './services/auth.service';
import { ConfigManagementService } from './services/config.service';
import { DashboardService } from './services/dashboard.service';
import { UsersService } from './services/users.service';
import { SystemAccountsService } from './services/system-accounts.service';
import { DailyReportService } from './services/daily-report.service';
import { ManualMiningService } from './services/manual-mining.service';
import { PendingContributionsService } from './services/pending-contributions.service';
import { BatchMiningService } from './services/batch-mining.service';
import { VersionService } from './services/version.service';
import { CapabilityAdminService } from './services/capability-admin.service';
import { NotificationService } from './services/notification.service';
// [2026-03-04] 新增：预种卖出限制管理（代理接口 + 审计日志）
import { PrePlantingRestrictionService } from './services/pre-planting-restriction.service';

@Module({
  imports: [InfrastructureModule],
  providers: [
    AuthService,
    ConfigManagementService,
    DashboardService,
    UsersService,
    SystemAccountsService,
    DailyReportService,
    ManualMiningService,
    PendingContributionsService,
    BatchMiningService,
    VersionService,
    CapabilityAdminService,
    NotificationService,
    PrePlantingRestrictionService, // 预种卖出限制管理
  ],
  exports: [
    AuthService,
    ConfigManagementService,
    DashboardService,
    UsersService,
    SystemAccountsService,
    DailyReportService,
    ManualMiningService,
    PendingContributionsService,
    BatchMiningService,
    VersionService,
    CapabilityAdminService,
    NotificationService,
    PrePlantingRestrictionService,
  ],
})
export class ApplicationModule implements OnModuleInit {
  constructor(private readonly authService: AuthService) {}

  async onModuleInit() {
    await this.authService.createDefaultAdmin();
  }
}
