From 053eb8b04a9820a7da22b18b20c234b06bf17dda Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 18 Jul 2024 16:21:57 +0700 Subject: [PATCH] feat: add query param to include full detail in service --- src/controllers/service/service-controller.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/controllers/service/service-controller.ts b/src/controllers/service/service-controller.ts index cb1b4c5..2946add 100644 --- a/src/controllers/service/service-controller.ts +++ b/src/controllers/service/service-controller.ts @@ -94,6 +94,7 @@ export class ServiceController extends Controller { @Query() status?: Status, @Query() productTypeId?: string, @Query() registeredBranchId?: string, + @Query() fullDetail?: boolean, ) { const filterStatus = (val?: Status) => { if (!val) return {}; @@ -118,7 +119,17 @@ export class ServiceController extends Controller { const [result, total] = await prisma.$transaction([ prisma.service.findMany({ include: { - work: true, + work: fullDetail + ? { + orderBy: { order: "asc" }, + include: { + productOnWork: { + include: { product: true }, + orderBy: { order: "asc" }, + }, + }, + } + : true, createdBy: true, updatedBy: true, },