import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { SearchModule } from '@modules/search';
import { CreateIndustrialParkHandler } from './application/commands/create-industrial-park/create-industrial-park.handler';
import { UpdateIndustrialParkHandler } from './application/commands/update-industrial-park/update-industrial-park.handler';
import { CompareIndustrialParksHandler } from './application/queries/compare-industrial-parks/compare-industrial-parks.handler';
import { GetIndustrialParkHandler } from './application/queries/get-industrial-park/get-industrial-park.handler';
import { IndustrialMarketHandler } from './application/queries/industrial-market/industrial-market.handler';
import { IndustrialParkStatsHandler } from './application/queries/industrial-park-stats/industrial-park-stats.handler';
import { ListIndustrialParksHandler } from './application/queries/list-industrial-parks/list-industrial-parks.handler';
import { INDUSTRIAL_PARK_REPOSITORY } from './domain/repositories/industrial-park.repository';
import { PrismaIndustrialParkRepository } from './infrastructure/repositories/prisma-industrial-park.repository';
import { TypesenseIndustrialService } from './infrastructure/services/typesense-industrial.service';
import { IndustrialParksController } from './presentation/controllers/industrial-parks.controller';

const CommandHandlers = [
  CreateIndustrialParkHandler,
  UpdateIndustrialParkHandler,
];

const QueryHandlers = [
  GetIndustrialParkHandler,
  ListIndustrialParksHandler,
  CompareIndustrialParksHandler,
  IndustrialParkStatsHandler,
  IndustrialMarketHandler,
];

@Module({
  imports: [CqrsModule, SearchModule],
  controllers: [IndustrialParksController],
  providers: [
    { provide: INDUSTRIAL_PARK_REPOSITORY, useClass: PrismaIndustrialParkRepository },
    TypesenseIndustrialService,
    ...CommandHandlers,
    ...QueryHandlers,
  ],
  exports: [INDUSTRIAL_PARK_REPOSITORY, TypesenseIndustrialService],
})
export class IndustrialModule {}
