From 557254eb1996fee9d858427d435d577e0ec8ed32 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 24 Jul 2024 14:42:21 +0700 Subject: [PATCH] refactor: reorder endpoints (affect swagger) --- src/controllers/quotation-controller.ts | 56 ++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/controllers/quotation-controller.ts b/src/controllers/quotation-controller.ts index c572660..6bbbdc3 100644 --- a/src/controllers/quotation-controller.ts +++ b/src/controllers/quotation-controller.ts @@ -176,6 +176,34 @@ function globalAllow(roles?: string[]) { @Route("/api/v1/quotation") @Tags("Quotation") export class QuotationController extends Controller { + @Get() + @Security("keycloak") + 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 }; + } + @Get("{quotationId}") @Security("keycloak") async getQuotationById(@Path() quotationId: string) { @@ -206,34 +234,6 @@ export class QuotationController extends Controller { return record; } - @Get() - @Security("keycloak") - 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", MANAGE_ROLES) async createQuotation(@Request() req: RequestWithUser, @Body() body: QuotationCreate) {