import { Injectable } from '@nestjs/common';
import { IndexItemCategoryManager } from './managers/index-item-category.manager';
import { ItemCategoryReadService } from '../../data/services/item-category-read.service';
import { ItemCategoryEntity } from '../entities/item-category.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailItemCategoryManager } from './managers/detail-item-category.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class ItemCategoryReadOrchestrator extends BaseReadOrchestrator<ItemCategoryEntity> {
  constructor(
    private indexManager: IndexItemCategoryManager,
    private detailManager: DetailItemCategoryManager,
    private serviceData: ItemCategoryReadService,
  ) {
    super();
  }

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

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