From b15a07d16a82077d6213907649156b409c38458b Mon Sep 17 00:00:00 2001 From: Supan Adit Pratama Date: Sat, 26 Oct 2024 23:23:46 +0700 Subject: [PATCH] wip: executor --- libs/prisma/src/executors/prisma.executor.ts | 18 +++++++++++++++++ libs/prisma/src/prisma-crud.controller.ts | 9 ++++++++- libs/skeleton/src/skeleton-crud.controller.ts | 20 +++++++++---------- 3 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 libs/prisma/src/executors/prisma.executor.ts diff --git a/libs/prisma/src/executors/prisma.executor.ts b/libs/prisma/src/executors/prisma.executor.ts new file mode 100644 index 0000000..8b74f46 --- /dev/null +++ b/libs/prisma/src/executors/prisma.executor.ts @@ -0,0 +1,18 @@ +import { ISkeletonProcess } from '@autocrud/skeleton/interfaces/skeleton-process.interface'; + +export class PrismaExecutor { + constructor(private process: ISkeletonProcess) {} + + async execute(): Promise { + this.process.initialization(); + this.process.before(); + this.process.begin(); + this.process.process(); + this.process.end(); + this.process.after(); + } + + getResult(): any { + return this.process.result(); + } +} diff --git a/libs/prisma/src/prisma-crud.controller.ts b/libs/prisma/src/prisma-crud.controller.ts index 6703728..eb79123 100644 --- a/libs/prisma/src/prisma-crud.controller.ts +++ b/libs/prisma/src/prisma-crud.controller.ts @@ -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 { + const executor = new PrismaExecutor(this.createProcess); + await executor.execute(); + return executor.getResult(); + } +} diff --git a/libs/skeleton/src/skeleton-crud.controller.ts b/libs/skeleton/src/skeleton-crud.controller.ts index 8d403f2..c209cfd 100644 --- a/libs/skeleton/src/skeleton-crud.controller.ts +++ b/libs/skeleton/src/skeleton-crud.controller.ts @@ -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()