feat: add query string
This commit is contained in:
parent
ebdd5924a6
commit
cdceac8568
1 changed files with 8 additions and 0 deletions
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue