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 { 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 {
constructor(
private readonly createProcess,
private readonly readProcess,
private readonly readPaginationProcess,
private readonly readEntireProcess,
private readonly updatePartialProcess,
private readonly updateBatchProcess,
private readonly updateEntireProcess,
private readonly updateEntireBatchProcess,
private readonly deleteProcess,
private readonly deleteBatchProcess,
public readonly createProcess,
public readonly readProcess,
public readonly readPaginationProcess,
public readonly readEntireProcess,
public readonly updatePartialProcess,
public readonly updateBatchProcess,
public readonly updateEntireProcess,
public readonly updateEntireBatchProcess,
public readonly deleteProcess,
public readonly deleteBatchProcess,
) {}
@Post()