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() productTypeId?: string,
|
||||||
@Query() page: number = 1,
|
@Query() page: number = 1,
|
||||||
@Query() pageSize: number = 30,
|
@Query() pageSize: number = 30,
|
||||||
|
@Query() registeredBranchId?: string,
|
||||||
) {
|
) {
|
||||||
const union = Prisma.sql`
|
const union = Prisma.sql`
|
||||||
SELECT
|
SELECT
|
||||||
|
|
@ -27,6 +28,7 @@ export class ProductServiceController extends Controller {
|
||||||
"status",
|
"status",
|
||||||
"statusOrder",
|
"statusOrder",
|
||||||
"productTypeId",
|
"productTypeId",
|
||||||
|
"registeredBranchId",
|
||||||
"createdByUserId",
|
"createdByUserId",
|
||||||
"createdAt",
|
"createdAt",
|
||||||
"updatedByUserId",
|
"updatedByUserId",
|
||||||
|
|
@ -47,6 +49,7 @@ export class ProductServiceController extends Controller {
|
||||||
"status",
|
"status",
|
||||||
"statusOrder",
|
"statusOrder",
|
||||||
"productTypeId",
|
"productTypeId",
|
||||||
|
"registeredBranchId",
|
||||||
"createdByUserId",
|
"createdByUserId",
|
||||||
"createdAt",
|
"createdAt",
|
||||||
"updatedByUserId",
|
"updatedByUserId",
|
||||||
|
|
@ -63,6 +66,11 @@ export class ProductServiceController extends Controller {
|
||||||
if (productTypeId) {
|
if (productTypeId) {
|
||||||
and.push(Prisma.sql`("productTypeId" = ${productTypeId})`);
|
and.push(Prisma.sql`("productTypeId" = ${productTypeId})`);
|
||||||
}
|
}
|
||||||
|
if (registeredBranchId) {
|
||||||
|
and.push(
|
||||||
|
Prisma.sql`("registeredBranchId" = ${registeredBranchId} OR "registeredBranchId" = null)`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const where = Prisma.sql`
|
const where = Prisma.sql`
|
||||||
${or.length > 0 || and.length > 0 ? Prisma.sql`WHERE ` : Prisma.empty}
|
${or.length > 0 || and.length > 0 ? Prisma.sql`WHERE ` : Prisma.empty}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue