From cdceac85687d91c13ed4c71a3294193669b394d9 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:27:26 +0700 Subject: [PATCH] feat: add query string --- src/controllers/product-service-controller.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/controllers/product-service-controller.ts b/src/controllers/product-service-controller.ts index f81f813..0e278e0 100644 --- a/src/controllers/product-service-controller.ts +++ b/src/controllers/product-service-controller.ts @@ -12,6 +12,7 @@ export class ProductServiceController extends Controller { @Query() productTypeId?: string, @Query() page: number = 1, @Query() pageSize: number = 30, + @Query() registeredBranchId?: string, ) { const union = Prisma.sql` SELECT @@ -27,6 +28,7 @@ export class ProductServiceController extends Controller { "status", "statusOrder", "productTypeId", + "registeredBranchId", "createdByUserId", "createdAt", "updatedByUserId", @@ -47,6 +49,7 @@ export class ProductServiceController extends Controller { "status", "statusOrder", "productTypeId", + "registeredBranchId", "createdByUserId", "createdAt", "updatedByUserId", @@ -63,6 +66,11 @@ export class ProductServiceController extends Controller { if (productTypeId) { and.push(Prisma.sql`("productTypeId" = ${productTypeId})`); } + if (registeredBranchId) { + and.push( + Prisma.sql`("registeredBranchId" = ${registeredBranchId} OR "registeredBranchId" = null)`, + ); + } const where = Prisma.sql` ${or.length > 0 || and.length > 0 ? Prisma.sql`WHERE ` : Prisma.empty}