From ce504c60883c56bf36d1c0d6760af18cd0dcce6a Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 24 Jan 2025 16:36:14 +0700 Subject: [PATCH] no message --- src/controllers/ProfileController.ts | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 493ea4fa..3a38acb3 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -4215,9 +4215,7 @@ export class ProfileController extends Controller { @Query() yearLeave?: number, @Query() isProbation?: boolean, @Query() isRetire?: boolean, - @Query() node?: number, @Query() nodeId?: string, - @Query() isAll?: boolean, ) { let queryLike = "CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword"; @@ -4236,24 +4234,16 @@ export class ProfileController extends Controller { END LIKE :keyword `; } - let nodeCondition = "1=1"; - let nodeAll = ""; - if (node === 0 && nodeId) { - nodeCondition = "current_holders.orgRootId = :nodeId"; - if (isAll == false) nodeAll = " AND current_holders.orgChild1Id IS NULL"; - } else if (node === 1 && nodeId) { - nodeCondition = "current_holders.orgChild1Id = :nodeId"; - if (isAll == false) nodeAll = " AND current_holders.orgChild2Id IS NULL"; - } else if (node === 2 && nodeId) { - nodeCondition = "current_holders.orgChild2Id = :nodeId"; - if (isAll == false) nodeAll = " AND current_holders.orgChild3Id IS NULL"; - } else if (node === 3 && nodeId) { - nodeCondition = "current_holders.orgChild3Id = :nodeId"; - if (isAll == false) nodeAll = " AND current_holders.orgChild4Id IS NULL"; - } else if (node === 4 && nodeId) { - nodeCondition = "current_holders.orgChild4Id = :nodeId"; + let posMaster = await this.posMasterRepo.findOne({ + where: { + current_holder: { keycloak: request.user.sub }, + orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true }, + }, + }); + if (nodeId == null) { + if (posMaster != null) nodeId = posMaster.orgRootId ?? ""; } - nodeCondition = nodeCondition + nodeAll; + let nodeCondition = "current_holders.orgRootId = :nodeId"; const findRevision = await this.orgRevisionRepo.findOne({ where: { orgRevisionIsCurrent: true }, });