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

@Injectable()
export class BannerReadOrchestrator extends BaseReadOrchestrator<BannerEntity> {
  constructor(
    private indexManager: IndexBannerManager,
    private detailManager: DetailBannerManager,
    private serviceData: BannerReadService,
  ) {
    super();
  }

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

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