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 HttpStatus from "../interfaces/http-status";
|
||||||
import { isSystem } from "../utils/keycloak";
|
import { isSystem } from "../utils/keycloak";
|
||||||
import {
|
import {
|
||||||
|
branchActiveOnlyCond,
|
||||||
branchRelationPermInclude,
|
branchRelationPermInclude,
|
||||||
createPermCheck,
|
createPermCheck,
|
||||||
createPermCondition,
|
createPermCondition,
|
||||||
|
|
@ -193,6 +194,7 @@ export class CustomerBranchController extends Controller {
|
||||||
@Query() query: string = "",
|
@Query() query: string = "",
|
||||||
@Query() page: number = 1,
|
@Query() page: number = 1,
|
||||||
@Query() pageSize: number = 30,
|
@Query() pageSize: number = 30,
|
||||||
|
@Query() activeRegisBranchOnly?: boolean,
|
||||||
) {
|
) {
|
||||||
const where = {
|
const where = {
|
||||||
OR: queryOrNot<Prisma.CustomerBranchWhereInput[]>(query, [
|
OR: queryOrNot<Prisma.CustomerBranchWhereInput[]>(query, [
|
||||||
|
|
@ -209,11 +211,16 @@ export class CustomerBranchController extends Controller {
|
||||||
]),
|
]),
|
||||||
AND: {
|
AND: {
|
||||||
customer: isSystem(req.user)
|
customer: isSystem(req.user)
|
||||||
? { registeredBranchId }
|
? {
|
||||||
|
registeredBranchId,
|
||||||
|
registeredBranch: branchActiveOnlyCond(activeRegisBranchOnly),
|
||||||
|
}
|
||||||
: {
|
: {
|
||||||
registeredBranch: {
|
registeredBranch: {
|
||||||
AND: { id: registeredBranchId },
|
AND: { id: registeredBranchId },
|
||||||
OR: company ? permissionCondCompany(req.user) : permissionCond(req.user),
|
OR: company
|
||||||
|
? permissionCondCompany(req.user, { activeOnly: activeRegisBranchOnly })
|
||||||
|
: permissionCond(req.user, { activeOnly: activeRegisBranchOnly }),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
customerId,
|
customerId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue