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 HttpStatus from "../interfaces/http-status";
|
||||||
import { isSystem } from "../utils/keycloak";
|
import { isSystem } from "../utils/keycloak";
|
||||||
import {
|
import {
|
||||||
|
branchActiveOnlyCond,
|
||||||
branchRelationPermInclude,
|
branchRelationPermInclude,
|
||||||
createPermCheck,
|
createPermCheck,
|
||||||
createPermCondition,
|
createPermCondition,
|
||||||
|
|
@ -88,6 +89,7 @@ export class ProductGroup extends Controller {
|
||||||
@Query() status?: Status,
|
@Query() status?: Status,
|
||||||
@Query() page: number = 1,
|
@Query() page: number = 1,
|
||||||
@Query() pageSize: number = 30,
|
@Query() pageSize: number = 30,
|
||||||
|
@Query() activeOnly?: boolean,
|
||||||
) {
|
) {
|
||||||
const where = {
|
const where = {
|
||||||
OR: queryOrNot<Prisma.ProductGroupWhereInput[]>(query, [
|
OR: queryOrNot<Prisma.ProductGroupWhereInput[]>(query, [
|
||||||
|
|
@ -97,8 +99,10 @@ export class ProductGroup extends Controller {
|
||||||
]),
|
]),
|
||||||
AND: [
|
AND: [
|
||||||
{
|
{
|
||||||
...filterStatus(status),
|
...filterStatus(activeOnly ? Status.ACTIVE : status),
|
||||||
registeredBranch: isSystem(req.user) ? undefined : { OR: permissionCond(req.user) },
|
registeredBranch: isSystem(req.user)
|
||||||
|
? branchActiveOnlyCond(activeOnly)
|
||||||
|
: { OR: permissionCond(req.user, { activeOnly }) },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
} satisfies Prisma.ProductGroupWhereInput;
|
} satisfies Prisma.ProductGroupWhereInput;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue