import { Injectable } from '@nestjs/common';
import { IndexUserPrivilegeManager } from './managers/index-user-privilege.manager';
import { UserPrivilegeReadService } from '../../../data/service/user-privilege-read.service';
import { UserPrivilegeEntity } from '../../entities/user-privilege.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailUserPrivilegeManager } from './managers/detail-user-privilege.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class UserPrivilegeReadOrchestrator extends BaseReadOrchestrator<UserPrivilegeEntity> {
  constructor(
    private indexManager: IndexUserPrivilegeManager,
    private detailManager: DetailUserPrivilegeManager,
    private serviceData: UserPrivilegeReadService,
  ) {
    super();
  }

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

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