feat: add active branch only for customer branch
This commit is contained in:
parent
1b9c71ef6c
commit
78e39ae16e
1 changed files with 9 additions and 2 deletions
|
|
@ -19,6 +19,7 @@ import prisma from "../db";
|
|||
import HttpStatus from "../interfaces/http-status";
|
||||
import { isSystem } from "../utils/keycloak";
|
||||
import {
|
||||
branchActiveOnlyCond,
|
||||
branchRelationPermInclude,
|
||||
createPermCheck,
|
||||
createPermCondition,
|
||||
|
|
@ -193,6 +194,7 @@ export class CustomerBranchController extends Controller {
|
|||
@Query() query: string = "",
|
||||
@Query() page: number = 1,
|
||||
@Query() pageSize: number = 30,
|
||||
@Query() activeRegisBranchOnly?: boolean,
|
||||
) {
|
||||
const where = {
|
||||
OR: queryOrNot<Prisma.CustomerBranchWhereInput[]>(query, [
|
||||
|
|
@ -209,11 +211,16 @@ export class CustomerBranchController extends Controller {
|
|||
]),
|
||||
AND: {
|
||||
customer: isSystem(req.user)
|
||||
? { registeredBranchId }
|
||||
? {
|
||||
registeredBranchId,
|
||||
registeredBranch: branchActiveOnlyCond(activeRegisBranchOnly),
|
||||
}
|
||||
: {
|
||||
registeredBranch: {
|
||||
AND: { id: registeredBranchId },
|
||||
OR: company ? permissionCondCompany(req.user) : permissionCond(req.user),
|
||||
OR: company
|
||||
? permissionCondCompany(req.user, { activeOnly: activeRegisBranchOnly })
|
||||
: permissionCond(req.user, { activeOnly: activeRegisBranchOnly }),
|
||||
},
|
||||
},
|
||||
customerId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue