import { Injectable } from '@nestjs/common';
import { CreateVipCodeManager } from './managers/create-vip-code.manager';
import { VipCodeDataService } from '../../data/services/vip-code-data.service';
import { VipCodeEntity } from '../entities/vip-code.entity';
import { BaseDataOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data.orchestrator';
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { GenerateVipCodeManager } from './managers/geneate-vip-code.manager';
import { VipCodeModel } from '../../data/models/vip-code.model';

@Injectable()
export class VipCodeDataOrchestrator extends BaseDataOrchestrator<VipCodeEntity> {
  constructor(
    private createManager: CreateVipCodeManager,
    private generateCodeManager: GenerateVipCodeManager,
    private serviceData: VipCodeDataService,
  ) {
    super();
  }

  update(dataId: string, data: VipCodeEntity): Promise<VipCodeEntity> {
    throw new Error('Method not implemented.');
  }
  delete(dataId: string): Promise<string> {
    throw new Error('Method not implemented.');
  }
  batchDelete(dataIds: string[]): Promise<BatchResult> {
    throw new Error('Method not implemented.');
  }

  async create(data): Promise<VipCodeEntity> {
    this.createManager.setData(data);
    this.createManager.setService(this.serviceData, TABLE_NAME.VIP_CODE);
    await this.createManager.execute();
    return this.createManager.getResult();
  }

  async generateCode(): Promise<string> {
    const data = new VipCodeModel();
    this.generateCodeManager.setData(data);
    this.generateCodeManager.setService(this.serviceData, TABLE_NAME.VIP_CODE);
    await this.generateCodeManager.execute();
    return this.generateCodeManager.getResult();
  }
}
