feat: active only product group param
This commit is contained in:
parent
369d0f4696
commit
e5ac580456
1 changed files with 6 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ import HttpError from "../interfaces/http-error";
|
|||
import HttpStatus from "../interfaces/http-status";
|
||||
import { isSystem } from "../utils/keycloak";
|
||||
import {
|
||||
branchActiveOnlyCond,
|
||||
branchRelationPermInclude,
|
||||
createPermCheck,
|
||||
createPermCondition,
|
||||
|
|
@ -88,6 +89,7 @@ export class ProductGroup extends Controller {
|
|||
@Query() status?: Status,
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
@Query() activeOnly?: boolean,
|
||||
) {
|
||||
const where = {
|
||||
OR: queryOrNot<Prisma.ProductGroupWhereInput[]>(query, [
|
||||
|
|
@ -97,8 +99,10 @@ export class ProductGroup extends Controller {
|
|||
]),
|
||||
AND: [
|
||||
{
|
||||
...filterStatus(status),
|
||||
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
|
||||
...filterStatus(activeOnly ? Status.ACTIVE : status),
|
||||
registeredBranch: isSystem(req.user)
|
||||
? branchActiveOnlyCond(activeOnly)
|
||||
: { OR: permissionCond(req.user, { activeOnly }) },
|
||||
},
|
||||
],
|
||||
} satisfies Prisma.ProductGroupWhereInput;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue