diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 9bfad0f8..0592c8ca 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2599,7 +2599,7 @@ export class ProfileController extends Controller { } else if (node === 4 && nodeId) { nodeCondition = "current_holders.orgChild4Id = :nodeId"; } - // let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER"); + let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_OFFICER"); const [record, total] = await this.profileRepo .createQueryBuilder("profile") .leftJoinAndSelect("profile.posLevel", "posLevel") @@ -2612,46 +2612,46 @@ export class ProfileController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") - // .andWhere( - // _data.root != undefined && _data.root != null - // ? `current_holders.orgRootId IN (:...node)` - // : "1=1", - // { - // node: _data.root, - // }, - // ) - // .andWhere( - // _data.child1 != undefined && _data.child1 != null - // ? `current_holders.orgChild1Id IN (:...node)` - // : "1=1", - // { - // node: _data.child1, - // }, - // ) - // .andWhere( - // _data.child2 != undefined && _data.child2 != null - // ? `current_holders.orgChild2Id IN (:...node)` - // : "1=1", - // { - // node: _data.child2, - // }, - // ) - // .andWhere( - // _data.child3 != undefined && _data.child3 != null - // ? `current_holders.orgChild3Id IN (:...node)` - // : "1=1", - // { - // node: _data.child3, - // }, - // ) - // .andWhere( - // _data.child4 != undefined && _data.child4 != null - // ? `current_holders.orgChild4Id IN (:...node)` - // : "1=1", - // { - // node: _data.child4, - // }, - // ) + .andWhere( + _data.root != undefined && _data.root != null + ? `current_holders.orgRootId IN (:...root)` + : "1=1", + { + root: _data.root, + }, + ) + .andWhere( + _data.child1 != undefined && _data.child1 != null + ? `current_holders.orgChild1Id IN (:...child1)` + : "1=1", + { + child1: _data.child1, + }, + ) + .andWhere( + _data.child2 != undefined && _data.child2 != null + ? `current_holders.orgChild2Id IN (:...child2)` + : "1=1", + { + child2: _data.child2, + }, + ) + .andWhere( + _data.child3 != undefined && _data.child3 != null + ? `current_holders.orgChild3Id IN (:...child3)` + : "1=1", + { + child3: _data.child3, + }, + ) + .andWhere( + _data.child4 != undefined && _data.child4 != null + ? `current_holders.orgChild4Id IN (:...child4)` + : "1=1", + { + child4: _data.child4, + }, + ) .andWhere( posType != undefined && posType != null && posType != "" ? "posType.posTypeName LIKE :keyword1" diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index be37ed8a..746511aa 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1079,6 +1079,7 @@ export class ProfileEmployeeController extends Controller { */ @Get() async listProfile( + @Request() request: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position", @@ -1097,6 +1098,7 @@ export class ProfileEmployeeController extends Controller { } else if (searchField == "position") { queryLike = "profileEmployee.position LIKE :keyword"; } + let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_EMP"); const [record, total] = await this.profileRepo .createQueryBuilder("profileEmployee") .leftJoinAndSelect("profileEmployee.posLevel", "posLevel") @@ -1109,6 +1111,46 @@ export class ProfileEmployeeController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") + .andWhere( + _data.root != undefined && _data.root != null + ? `current_holders.orgRootId IN (:...root)` + : "1=1", + { + root: _data.root, + }, + ) + .andWhere( + _data.child1 != undefined && _data.child1 != null + ? `current_holders.orgChild1Id IN (:...child1)` + : "1=1", + { + child1: _data.child1, + }, + ) + .andWhere( + _data.child2 != undefined && _data.child2 != null + ? `current_holders.orgChild2Id IN (:...child2)` + : "1=1", + { + child2: _data.child2, + }, + ) + .andWhere( + _data.child3 != undefined && _data.child3 != null + ? `current_holders.orgChild3Id IN (:...child3)` + : "1=1", + { + child3: _data.child3, + }, + ) + .andWhere( + _data.child4 != undefined && _data.child4 != null + ? `current_holders.orgChild4Id IN (:...child4)` + : "1=1", + { + child4: _data.child4, + }, + ) .andWhere( searchKeyword != undefined && searchKeyword != null && searchKeyword != "" ? queryLike diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 88cec120..9b678ca2 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -1078,6 +1078,7 @@ export class ProfileEmployeeTempController extends Controller { */ @Get() async listProfile( + @Request() request: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query() searchField?: "firstName" | "lastName" | "fullName" | "citizenId" | "position", @@ -1096,6 +1097,7 @@ export class ProfileEmployeeTempController extends Controller { } else if (searchField == "position") { queryLike = "profileEmployee.position LIKE :keyword"; } + let _data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_TEMP"); const [record, total] = await this.profileRepo .createQueryBuilder("profileEmployee") .leftJoinAndSelect("profileEmployee.posLevel", "posLevel") @@ -1108,6 +1110,46 @@ export class ProfileEmployeeTempController extends Controller { .leftJoinAndSelect("current_holders.orgChild2", "orgChild2") .leftJoinAndSelect("current_holders.orgChild3", "orgChild3") .leftJoinAndSelect("current_holders.orgChild4", "orgChild4") + .andWhere( + _data.root != undefined && _data.root != null + ? `current_holders.orgRootId IN (:...root)` + : "1=1", + { + root: _data.root, + }, + ) + .andWhere( + _data.child1 != undefined && _data.child1 != null + ? `current_holders.orgChild1Id IN (:...child1)` + : "1=1", + { + child1: _data.child1, + }, + ) + .andWhere( + _data.child2 != undefined && _data.child2 != null + ? `current_holders.orgChild2Id IN (:...child2)` + : "1=1", + { + child2: _data.child2, + }, + ) + .andWhere( + _data.child3 != undefined && _data.child3 != null + ? `current_holders.orgChild3Id IN (:...child3)` + : "1=1", + { + child3: _data.child3, + }, + ) + .andWhere( + _data.child4 != undefined && _data.child4 != null + ? `current_holders.orgChild4Id IN (:...child4)` + : "1=1", + { + child4: _data.child4, + }, + ) .andWhere( searchKeyword != undefined && searchKeyword != null && searchKeyword != "" ? queryLike