import { Injectable } from '@nestjs/common';
import { IndexTermConditionManager } from './managers/index-term-condition.manager';
import { TermConditionReadService } from '../../data/services/term-condition-read.service';
import { TermConditionEntity } from '../entities/term-condition.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailTermConditionManager } from './managers/detail-term-condition.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class TermConditionReadOrchestrator extends BaseReadOrchestrator<TermConditionEntity> {
  constructor(
    private indexManager: IndexTermConditionManager,
    private detailManager: DetailTermConditionManager,
    private serviceData: TermConditionReadService,
  ) {
    super();
  }

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

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