import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_FILTER } from '@nestjs/core';
import { InfrastructureModule } from './infrastructure/infrastructure.module';
import { DomainModule } from './domain/domain.module';
import { ApplicationModule } from './application/application.module';
import { ApiModule } from './api/api.module';
// [2026-02-17] 新增：3566 预种计划模块（纯新增，与现有 PlantingOrder 零耦合）
import { PrePlantingModule } from './pre-planting/pre-planting.module';
import { GlobalExceptionFilter } from './shared/filters/global-exception.filter';
import configs from './config';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: ['.env.development', '.env'],
      load: configs,
    }),
    InfrastructureModule,
    DomainModule,
    ApplicationModule,
    ApiModule,
    PrePlantingModule, // 预种计划：独立聚合根、独立 Kafka Topic、独立数据表
  ],
  providers: [
    {
      provide: APP_FILTER,
      useClass: GlobalExceptionFilter,
    },
  ],
})
export class AppModule {}
