import { Injectable } from '@nestjs/common';
import { IndexGateManager } from './managers/index-gate.manager';
import { GateReadService } from '../../data/services/gate-read.service';
import { GateEntity } from '../entities/gate.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailGateManager } from './managers/detail-gate.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class GateReadOrchestrator extends BaseReadOrchestrator<GateEntity> {
  constructor(
    private indexManager: IndexGateManager,
    private detailManager: DetailGateManager,
    private serviceData: GateReadService,
  ) {
    super();
  }

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

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