import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ThrottlerModule } from '@nestjs/throttler';
import { PrismaModule } from './database/prisma.module';
import { AuthModule } from './modules/auth/auth.module';
import { CourseModule } from './modules/course/course.module';
import { TenantModule } from './modules/tenant/tenant.module';
import { CommonModule } from './modules/common/common.module';
import { FileUploadModule } from './modules/file-upload/file-upload.module';
import { TeacherCourseModule } from './modules/teacher-course/teacher-course.module';
import { LessonModule } from './modules/lesson/lesson.module';
import { SchoolModule } from './modules/school/school.module';
import { ResourceModule } from './modules/resource/resource.module';
import { GrowthModule } from './modules/growth/growth.module';
import { TaskModule } from './modules/task/task.module';
import { ParentModule } from './modules/parent/parent.module';
import { NotificationModule } from './modules/notification/notification.module';
import { ExportModule } from './modules/export/export.module';
import { AdminModule } from './modules/admin/admin.module';
// V2 新增模块
import { ThemeModule } from './modules/theme/theme.module';
import { CoursePackageModule } from './modules/course-package/course-package.module';
import { CourseLessonModule } from './modules/course-lesson/course-lesson.module';
import { SchoolCourseModule } from './modules/school-course/school-course.module';

@Module({
  imports: [
    // 配置模块
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: `.env.${process.env.NODE_ENV || 'development'}`,
    }),

    // 限流模块
    ThrottlerModule.forRoot([
      {
        ttl: 60000, // 60秒
        limit: 100, // 最多100个请求
      },
    ]),

    // Prisma数据库模块
    PrismaModule,

    // 业务模块
    AuthModule,
    CourseModule,
    TenantModule,
    CommonModule,
    FileUploadModule,
    TeacherCourseModule,
    LessonModule,
    SchoolModule,
    ResourceModule,
    GrowthModule,
    TaskModule,
    ParentModule,
    NotificationModule,
    ExportModule,
    AdminModule,
    // V2 新增模块
    ThemeModule,
    CoursePackageModule,
    CourseLessonModule,
    SchoolCourseModule,
  ],
})
export class AppModule {}
