import { Injectable } from '@nestjs/common';
import { Index{{pascalCase name}}Manager } from './managers/index-{{dashCase name}}.manager';
import { {{pascalCase name}}ReadService } from '../../data/services/{{dashCase name}}-read.service';
import { {{pascalCase name}}Entity } from '../entities/{{dashCase name}}.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { Detail{{pascalCase name}}Manager } from './managers/detail-{{dashCase name}}.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class {{pascalCase name}}ReadOrchestrator extends BaseReadOrchestrator<{{pascalCase name}}Entity> {
  constructor(
    private indexManager: Index{{pascalCase name}}Manager,
    private detailManager: Detail{{pascalCase name}}Manager,
    private serviceData: {{pascalCase name}}ReadService,
  ) {
    super();
  }

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

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