From f06f7366b7a5184d57cbc60e6b2151de32e29f79 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 7 Nov 2024 14:12:31 +0700 Subject: [PATCH] refactor: urgent comes first as parameter --- src/controllers/05-quotation-controller.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index 2c9b317..8986757 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -189,6 +189,7 @@ export class QuotationController extends Controller { @Query() pageSize: number = 30, @Query() payCondition?: PayCondition, @Query() status?: QuotationStatus, + @Query() urgentFirst?: boolean, @Query() query = "", ) { const where = { @@ -231,7 +232,7 @@ export class QuotationController extends Controller { createdBy: true, updatedBy: true, }, - orderBy: [{ urgent: "desc" }, { createdAt: "desc" }], + orderBy: urgentFirst ? [{ urgent: "desc" }, { createdAt: "desc" }] : { createdAt: "desc" }, take: pageSize, skip: (page - 1) * pageSize, }),