diff --git a/src/controllers/product/product-controller.ts b/src/controllers/product/product-controller.ts index 0c28c47..c2e6e88 100644 --- a/src/controllers/product/product-controller.ts +++ b/src/controllers/product/product-controller.ts @@ -104,7 +104,7 @@ export class ProductController extends Controller { @Query() query: string = "", @Query() page: number = 1, @Query() pageSize: number = 30, - @Query() branchId?: string, + @Query() registeredBranchId?: string, ) { const filterStatus = (val?: Status) => { if (!val) return {}; @@ -119,9 +119,11 @@ export class ProductController extends Controller { { name: { contains: query }, productTypeId, ...filterStatus(status) }, { detail: { contains: query }, productTypeId, ...filterStatus(status) }, ], - AND: { - OR: [{ registeredBranchId: branchId }, { registeredBranchId: null }], - }, + AND: registeredBranchId + ? { + OR: [{ registeredBranchId: registeredBranchId }, { registeredBranchId: null }], + } + : undefined, } satisfies Prisma.ProductWhereInput; const [result, total] = await prisma.$transaction([ diff --git a/src/controllers/service/service-controller.ts b/src/controllers/service/service-controller.ts index 1170ab7..cb1b4c5 100644 --- a/src/controllers/service/service-controller.ts +++ b/src/controllers/service/service-controller.ts @@ -93,7 +93,7 @@ export class ServiceController extends Controller { @Query() pageSize: number = 30, @Query() status?: Status, @Query() productTypeId?: string, - @Query() branchId?: string, + @Query() registeredBranchId?: string, ) { const filterStatus = (val?: Status) => { if (!val) return {}; @@ -108,9 +108,11 @@ export class ServiceController extends Controller { { name: { contains: query }, productTypeId, ...filterStatus(status) }, { detail: { contains: query }, productTypeId, ...filterStatus(status) }, ], - AND: { - OR: [{ registeredBranchId: branchId }, { registeredBranchId: null }], - }, + AND: registeredBranchId + ? { + OR: [{ registeredBranchId: registeredBranchId }, { registeredBranchId: null }], + } + : undefined, } satisfies Prisma.ServiceWhereInput; const [result, total] = await prisma.$transaction([