import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

// ORM Entities
import { UserORM } from '../infrastructure/database/postgres/entities/user.orm';
import { UserProfileORM } from '../infrastructure/database/postgres/entities/user-profile.orm';
import { UserContactORM } from '../infrastructure/database/postgres/entities/user-contact.orm';

// Repository Interfaces
import { USER_REPOSITORY } from '../domain/repositories/user.repository.interface';
import { USER_PROFILE_REPOSITORY } from '../domain/repositories/user-profile.repository.interface';
import { USER_CONTACT_REPOSITORY } from '../domain/repositories/user-contact.repository.interface';

// Repository Implementations
import { UserPostgresRepository } from '../adapters/outbound/persistence/user-postgres.repository';
import { UserProfilePostgresRepository } from '../adapters/outbound/persistence/user-profile-postgres.repository';
import { UserContactPostgresRepository } from '../adapters/outbound/persistence/user-contact-postgres.repository';

// Services
import { UserService } from '../application/services/user.service';
import { UserProfileService } from '../application/services/user-profile.service';
import { UserContactService } from '../application/services/user-contact.service';

// Controllers
import { UserController } from '../adapters/inbound/user.controller';
import { AdminUserController } from '../adapters/inbound/admin-user.controller';
import { UserProfileController } from '../adapters/inbound/user-profile.controller';
import { UserContactController } from '../adapters/inbound/user-contact.controller';

@Module({
  imports: [
    TypeOrmModule.forFeature([UserORM, UserProfileORM, UserContactORM]),
  ],
  controllers: [
    UserController,
    AdminUserController,
    UserProfileController,
    UserContactController,
  ],
  providers: [
    UserService,
    UserProfileService,
    UserContactService,
    {
      provide: USER_REPOSITORY,
      useClass: UserPostgresRepository,
    },
    {
      provide: USER_PROFILE_REPOSITORY,
      useClass: UserProfilePostgresRepository,
    },
    {
      provide: USER_CONTACT_REPOSITORY,
      useClass: UserContactPostgresRepository,
    },
  ],
  exports: [
    UserService,
    UserProfileService,
    UserContactService,
    USER_REPOSITORY,
    USER_PROFILE_REPOSITORY,
    USER_CONTACT_REPOSITORY,
  ],
})
export class UserModule {}
