wip: executor

This commit is contained in:
Supan Adit Pratama 2024-10-26 23:23:46 +07:00
parent 4d5ac919be
commit b15a07d16a
3 changed files with 36 additions and 11 deletions

View File

@ -0,0 +1,18 @@
import { ISkeletonProcess } from '@autocrud/skeleton/interfaces/skeleton-process.interface';
export class PrismaExecutor {
constructor(private process: ISkeletonProcess) {}
async execute(): Promise<void> {
this.process.initialization();
this.process.before();
this.process.begin();
this.process.process();
this.process.end();
this.process.after();
}
getResult(): any {
return this.process.result();
}
}

View File

@ -1,3 +1,10 @@
import { SkeletonCRUDController } from '@autocrud/skeleton'; import { SkeletonCRUDController } from '@autocrud/skeleton';
import { PrismaExecutor } from './executors/prisma.executor';
export class PrismaCRUDController extends SkeletonCRUDController {} export class PrismaCRUDController extends SkeletonCRUDController {
async create(): Promise<any> {
const executor = new PrismaExecutor(this.createProcess);
await executor.execute();
return executor.getResult();
}
}

View File

@ -3,16 +3,16 @@ import { ISkeletonCRUDController } from './interfaces/controller/skeleton-crud.c
export class SkeletonCRUDController implements ISkeletonCRUDController { export class SkeletonCRUDController implements ISkeletonCRUDController {
constructor( constructor(
private readonly createProcess, public readonly createProcess,
private readonly readProcess, public readonly readProcess,
private readonly readPaginationProcess, public readonly readPaginationProcess,
private readonly readEntireProcess, public readonly readEntireProcess,
private readonly updatePartialProcess, public readonly updatePartialProcess,
private readonly updateBatchProcess, public readonly updateBatchProcess,
private readonly updateEntireProcess, public readonly updateEntireProcess,
private readonly updateEntireBatchProcess, public readonly updateEntireBatchProcess,
private readonly deleteProcess, public readonly deleteProcess,
private readonly deleteBatchProcess, public readonly deleteBatchProcess,
) {} ) {}
@Post() @Post()