fix: condition
This commit is contained in:
parent
f0414b7487
commit
ebdd5924a6
2 changed files with 12 additions and 8 deletions
|
|
@ -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([
|
||||
|
|
|
|||
|
|
@ -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([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue