no message
This commit is contained in:
parent
dc6e157ffe
commit
9db1ca7492
1 changed files with 41 additions and 37 deletions
|
|
@ -436,57 +436,61 @@ export class KeycloakController extends Controller {
|
|||
let condition: any = {};
|
||||
|
||||
if (req.user.role.includes("ADMIN")) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations:[
|
||||
"current_holders",
|
||||
"current_holders.orgRevision",
|
||||
],
|
||||
where: {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
relations: ["current_holders", "current_holders.orgRevision"],
|
||||
where: {
|
||||
keycloak: req.user.sub,
|
||||
current_holders:{
|
||||
orgRevision:{
|
||||
current_holders: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false
|
||||
}
|
||||
}
|
||||
}
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if(profile?.current_holders[0].orgRootId && profile?.current_holders[0].orgChild1Id == null){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
if (
|
||||
profile?.current_holders[0]?.orgRootId &&
|
||||
profile?.current_holders[0]?.orgChild1Id == null
|
||||
) {
|
||||
condition = `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){
|
||||
condition =
|
||||
`current_holders.orgRootId = '${profile?.current_holders[0].orgRootId}'
|
||||
and current_holders.orgChild1Id '${profile?.current_holders[0].orgChild1Id}'
|
||||
} else if (
|
||||
profile?.current_holders[0]?.orgChild1Id &&
|
||||
profile?.current_holders[0]?.orgChild2Id == null
|
||||
) {
|
||||
condition = `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){
|
||||
condition =
|
||||
`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}'
|
||||
} else if (
|
||||
profile?.current_holders[0]?.orgChild2Id &&
|
||||
profile?.current_holders[0]?.orgChild3Id == null
|
||||
) {
|
||||
condition = `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){
|
||||
condition =
|
||||
`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}'
|
||||
} else if (
|
||||
profile?.current_holders[0]?.orgChild3Id &&
|
||||
profile?.current_holders[0]?.orgChild4Id == null
|
||||
) {
|
||||
condition = `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){
|
||||
condition =
|
||||
`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}'`;
|
||||
} else if (profile?.current_holders[0]?.orgChild4Id) {
|
||||
condition = `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}'`;
|
||||
}
|
||||
}
|
||||
let profiles: any = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue