import { Injectable } from '@nestjs/common';
import { IndexItemQueueManager } from './managers/index-item-queue.manager';
import { ItemQueueReadService } from '../../data/services/item-queue-read.service';
import { ItemQueueEntity } from '../entities/item-queue.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailItemQueueManager } from './managers/detail-item-queue.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class ItemQueueReadOrchestrator extends BaseReadOrchestrator<ItemQueueEntity> {
  constructor(
    private indexManager: IndexItemQueueManager,
    private detailManager: DetailItemQueueManager,
    private serviceData: ItemQueueReadService,
  ) {
    super();
  }

  async index(params): Promise<PaginationResponse<ItemQueueEntity>> {
    this.indexManager.setFilterParam(params);
    this.indexManager.setService(this.serviceData, TABLE_NAME.ITEM_QUEUE);
    await this.indexManager.execute();
    return this.indexManager.getResult();
  }

  async list(): Promise<ItemQueueEntity[]> {
    const items = await this.serviceData.list();
    return items;
  }

  async detail(dataId: string): Promise<ItemQueueEntity> {
    this.detailManager.setData(dataId);
    this.detailManager.setService(this.serviceData, TABLE_NAME.ITEM_QUEUE);
    await this.detailManager.execute();
    return this.detailManager.getResult();
  }
}
