import { Global, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CONNECTION_NAME } from 'src/core/strings/constants/base.constants';
import { ItemDataService } from './data/services/item-data.service';
import { ItemReadService } from './data/services/item-read.service';
import {
  ItemReadController,
  // ItemReadQueueController,
} from './infrastructure/item-read.controller';
import { ItemReadOrchestrator } from './domain/usecases/item-read.orchestrator';
import { ItemDataController } from './infrastructure/item-data.controller';
import { ItemDataOrchestrator } from './domain/usecases/item-data.orchestrator';
import { CreateItemManager } from './domain/usecases/managers/create-item.manager';
import { CqrsModule } from '@nestjs/cqrs';
import { IndexItemManager } from './domain/usecases/managers/index-item.manager';
import { DeleteItemManager } from './domain/usecases/managers/delete-item.manager';
import { UpdateItemManager } from './domain/usecases/managers/update-item.manager';
import { ActiveItemManager } from './domain/usecases/managers/active-item.manager';
import { ConfirmItemManager } from './domain/usecases/managers/confirm-item.manager';
import { InactiveItemManager } from './domain/usecases/managers/inactive-item.manager';
import { DetailItemManager } from './domain/usecases/managers/detail-item.manager';
import { BatchDeleteItemManager } from './domain/usecases/managers/batch-delete-item.manager';
import { BatchActiveItemManager } from './domain/usecases/managers/batch-active-item.manager';
import { BatchConfirmItemManager } from './domain/usecases/managers/batch-confirm-item.manager';
import { BatchInactiveItemManager } from './domain/usecases/managers/batch-inactive-item.manager';
import { ItemModel } from './data/models/item.model';
import { ItemRateModel } from '../item-rate/data/models/item-rate.model';
import { ItemRateReadService } from '../item-rate/data/services/item-rate-read.service';
import { IndexItemRatesManager } from './domain/usecases/managers/index-item-rates.manager';
import { UpdateItemRatePriceManager } from './domain/usecases/managers/update-item-rate-price.manager';
import { IndexItemQueueManager } from './domain/usecases/managers/index-queue-item.manager';

@Global()
@Module({
  imports: [
    ConfigModule.forRoot(),
    TypeOrmModule.forFeature(
      [ItemModel, ItemRateModel],
      CONNECTION_NAME.DEFAULT,
    ),
    CqrsModule,
  ],
  controllers: [
    ItemDataController,
    ItemReadController,
    // ItemReadQueueController,
  ],
  providers: [
    IndexItemManager,
    IndexItemQueueManager,
    IndexItemRatesManager,
    DetailItemManager,
    CreateItemManager,
    DeleteItemManager,
    UpdateItemManager,
    ActiveItemManager,
    ConfirmItemManager,
    InactiveItemManager,
    BatchDeleteItemManager,
    BatchActiveItemManager,
    BatchConfirmItemManager,
    BatchInactiveItemManager,
    UpdateItemRatePriceManager,

    ItemDataService,
    ItemReadService,
    ItemRateReadService,

    ItemDataOrchestrator,
    ItemReadOrchestrator,
  ],
  exports: [
    IndexItemManager,
    IndexItemQueueManager,
    IndexItemRatesManager,
    DetailItemManager,
    CreateItemManager,
    DeleteItemManager,
    UpdateItemManager,
    ActiveItemManager,
    ConfirmItemManager,
    InactiveItemManager,
    BatchDeleteItemManager,
    BatchActiveItemManager,
    BatchConfirmItemManager,
    BatchInactiveItemManager,

    ItemRateReadService,
    ItemDataService,
    ItemReadService,

    ItemDataOrchestrator,
    ItemReadOrchestrator,
  ],
})
export class ItemModule {}
