pos-be/src/modules/queue/domain/queue-admin.orchestrator.ts

47 lines
1.6 KiB
TypeScript

import { Injectable } from '@nestjs/common';
import { QueueDataService, QueueService } from '../data/services/queue.service';
import { IndexQueueManager } from './usecases/index-queue.manager';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { Queue } from './entities/queue.entity';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import {
CallQueueManager,
DoneQueueManager,
} from './usecases/call-queue.manager';
import {
ORDER_TYPE,
QUEUE_STATUS,
} from 'src/core/strings/constants/base.constants';
@Injectable()
export class QueueAdminOrchestrator {
constructor(
private readonly dataService: QueueDataService,
private readonly service: QueueService,
private indexManager: IndexQueueManager,
private callManager: CallQueueManager,
private doneManager: DoneQueueManager,
) {}
async index(params): Promise<PaginationResponse<Queue>> {
this.indexManager.setFilterParam({ order_type: ORDER_TYPE.ASC, ...params });
this.indexManager.setService(this.dataService, TABLE_NAME.QUEUE);
await this.indexManager.execute();
return this.indexManager.getResult();
}
async call(dataId): Promise<string> {
this.callManager.setData(dataId, QUEUE_STATUS.CALLED);
this.callManager.setService(this.service, TABLE_NAME.QUEUE);
await this.callManager.execute();
return this.callManager.getResult();
}
async done(dataId): Promise<string> {
this.doneManager.setData(dataId, QUEUE_STATUS.DONE);
this.doneManager.setService(this.service, TABLE_NAME.QUEUE);
await this.doneManager.execute();
return this.doneManager.getResult();
}
}