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

@Injectable()
export class DataSchedulingReadOrchestrator extends BaseReadOrchestrator<DataSchedulingEntity> {
  constructor(
    private indexManager: IndexDataSchedulingManager,
    private detailManager: DetailDataSchedulingManager,
    private serviceData: DataSchedulingReadService,
  ) {
    super();
  }

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

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