feat: add active branch only for customer
This commit is contained in:
parent
9630d02924
commit
1b9c71ef6c
1 changed files with 6 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { isSystem } from "../utils/keycloak";
|
||||
import {
|
||||
branchActiveOnlyCond,
|
||||
branchRelationPermInclude,
|
||||
createPermCheck,
|
||||
createPermCondition,
|
||||
|
|
@ -163,6 +164,7 @@ export class CustomerController extends Controller {
|
|||
@Query() pageSize: number = 30,
|
||||
@Query() includeBranch: boolean = false,
|
||||
@Query() company: boolean = false,
|
||||
@Query() activeBranchOnly?: boolean,
|
||||
) {
|
||||
const where = {
|
||||
OR: queryOrNot<Prisma.CustomerWhereInput[]>(query, [
|
||||
|
|
@ -179,9 +181,11 @@ export class CustomerController extends Controller {
|
|||
customerType,
|
||||
...filterStatus(status),
|
||||
registeredBranch: isSystem(req.user)
|
||||
? undefined
|
||||
? branchActiveOnlyCond(activeBranchOnly)
|
||||
: {
|
||||
OR: company ? permissionCondCompany(req.user) : permissionCond(req.user),
|
||||
OR: company
|
||||
? permissionCondCompany(req.user, { activeOnly: activeBranchOnly })
|
||||
: permissionCond(req.user, { activeOnly: activeBranchOnly }),
|
||||
},
|
||||
},
|
||||
} satisfies Prisma.CustomerWhereInput;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue