From a2dbaf29fb1201603b71cc4c6429d25b3fe51568 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:46:28 +0700 Subject: [PATCH] feat: add quotation list endpoint (no query) --- src/controllers/quotation-controller.ts | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/controllers/quotation-controller.ts b/src/controllers/quotation-controller.ts index f3622df..dfa1554 100644 --- a/src/controllers/quotation-controller.ts +++ b/src/controllers/quotation-controller.ts @@ -169,7 +169,31 @@ export class QuotationController extends Controller { @Get() @Security("keycloak") - async getQuotationList(@Query() page: number = 1, @Query() pageSize: number = 30) {} + async getQuotationList(@Query() page: number = 1, @Query() pageSize: number = 30) { + const [result, total] = await prisma.$transaction([ + prisma.quotation.findMany({ + include: { + worker: true, + service: { + include: { + _count: { select: { work: true } }, + work: { + include: { + _count: { select: { productOnWork: true } }, + productOnWork: { + include: { product: true }, + }, + }, + }, + }, + }, + }, + }), + prisma.quotation.count(), + ]); + + return { result: result, page, pageSize, total }; + } @Post() @Security("keycloak")