ปรับเงื่อนไข admin ให้เห็นข้อมูลทั้งสังกัด (#186)

This commit is contained in:
AdisakKanthawilang 2025-10-07 17:18:54 +07:00 committed by GitHub
parent 564d7d96c3
commit e0e850b4c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -499,49 +499,9 @@ export class KeycloakController extends Controller {
},
},
});
if (
profile?.current_holders[0]?.orgRootId &&
profile?.current_holders[0]?.orgChild1Id == null
) {
checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
and current_holders.orgChild1Id IS NULL
and current_holders.orgChild2Id IS NULL
and current_holders.orgChild3Id IS NULL
and current_holders.orgChild4Id IS NULL`;
} else if (
profile?.current_holders[0]?.orgChild1Id &&
profile?.current_holders[0]?.orgChild2Id == null
) {
checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
and current_holders.orgChild2Id IS NULL
and current_holders.orgChild3Id IS NULL
and current_holders.orgChild4Id IS NULL`;
} else if (
profile?.current_holders[0]?.orgChild2Id &&
profile?.current_holders[0]?.orgChild3Id == null
) {
checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}'
and current_holders.orgChild3Id IS NULL
and current_holders.orgChild4Id IS NULL`;
} else if (
profile?.current_holders[0]?.orgChild3Id &&
profile?.current_holders[0]?.orgChild4Id == null
) {
checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}'
and current_holders.orgChild3Id = '${profile?.current_holders[0]?.orgChild3Id}'
and current_holders.orgChild4Id IS NULL`;
} else if (profile?.current_holders[0]?.orgChild4Id) {
checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'
and current_holders.orgChild1Id = '${profile?.current_holders[0]?.orgChild1Id}'
and current_holders.orgChild2Id = '${profile?.current_holders[0]?.orgChild2Id}'
and current_holders.orgChild3Id = '${profile?.current_holders[0]?.orgChild3Id}'
and current_holders.orgChild4Id = '${profile?.current_holders[0]?.orgChild4Id}'`;
//ADMIN เห็นทั้งหน่วยงานที่สังกัด
if (profile?.current_holders[0]?.orgRootId) {
checkChildFromRole = `current_holders.orgRootId = '${profile?.current_holders[0]?.orgRootId}'`;
}
}