import { Injectable } from '@nestjs/common';
import { Create{{pascalCase name}}Manager } from './managers/create-{{dashCase name}}.manager';
import { {{pascalCase name}}DataService } from '../../data/services/{{dashCase name}}-data.service';
import { {{pascalCase name}}Entity } from '../entities/{{dashCase name}}.entity';
import { Delete{{pascalCase name}}Manager } from './managers/delete-{{dashCase name}}.manager';
import { Update{{pascalCase name}}Manager } from './managers/update-{{dashCase name}}.manager';
import { Base{{pascalCase orchestrator}}Orchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-{{dashCase orchestrator}}.orchestrator';
import { STATUS } from 'src/core/strings/constants/base.constants';
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
import { BatchDelete{{pascalCase name}}Manager } from './managers/batch-delete-{{dashCase name}}.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class {{pascalCase name}}DataOrchestrator extends Base{{pascalCase orchestrator}}Orchestrator<{{pascalCase name}}Entity> {
    constructor(
        private createManager: Create{{pascalCase name}}Manager,
        private updateManager: Update{{pascalCase name}}Manager,
        private deleteManager: Delete{{pascalCase name}}Manager,
        private batchDeleteManager: BatchDelete{{pascalCase name}}Manager,
        private serviceData: {{pascalCase name}}DataService,
    ) {
        super();
    }

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

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

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

    async batchDelete(dataIds: string[]): Promise<BatchResult> {
        this.batchDeleteManager.setData(dataIds);
        this.batchDeleteManager.setService(
            this.serviceData,
            TABLE_NAME.{{constantCase name}},
        );
        await this.batchDeleteManager.execute();
        return this.batchDeleteManager.getResult();
    }
}