Fix API Listรายชื่อขรก. ตามสิทธิ์ admin

This commit is contained in:
Bright 2025-07-09 12:58:03 +07:00
parent ca5ab47ab0
commit 4fdd5e7d7d

View file

@ -4121,19 +4121,39 @@ export class OrganizationDotnetController extends Controller {
if (body.role === "OWNER" || body.role === "CHILD") { if (body.role === "OWNER" || body.role === "CHILD") {
switch (node) { switch (node) {
case 0: case 0:
typeCondition = { orgRootId: body.nodeId }; typeCondition = {
orgRoot: {
ancestorDNA: body.nodeId
}
};
break; break;
case 1: case 1:
typeCondition = { orgChild1Id: body.nodeId }; typeCondition = {
orgChild1: {
ancestorDNA: body.nodeId
}
};
break; break;
case 2: case 2:
typeCondition = { orgChild2Id: body.nodeId }; typeCondition = {
orgChild2: {
ancestorDNA: body.nodeId
}
};
break; break;
case 3: case 3:
typeCondition = { orgChild3Id: body.nodeId }; typeCondition = {
orgChild3: {
ancestorDNA: body.nodeId
}
};
break; break;
case 4: case 4:
typeCondition = { orgChild4Id: body.nodeId }; typeCondition = {
orgChild4: {
ancestorDNA: body.nodeId
}
};
break; break;
case null: case null:
typeCondition = {}; typeCondition = {};
@ -4150,26 +4170,41 @@ export class OrganizationDotnetController extends Controller {
switch (node) { switch (node) {
case 0: case 0:
typeCondition = { typeCondition = {
orgRootId: body.nodeId, orgRoot: {
orgChild1Id: IsNull(), ancestorDNA: body.nodeId
},
orgChild1: IsNull()
}; };
break; break;
case 1: case 1:
typeCondition = { typeCondition = {
orgChild1Id: body.nodeId, orgChild1: {
orgChild2Id: IsNull(), ancestorDNA: body.nodeId
},
orgChild2: IsNull()
}; };
break; break;
case 2: case 2:
typeCondition = { typeCondition = {
orgChild2Id: body.nodeId, orgChild2: {
orgChild3Id: IsNull(), ancestorDNA: body.nodeId
},
orgChild3: IsNull()
}; };
break; break;
case 3: case 3:
typeCondition = { typeCondition = {
orgChild3Id: body.nodeId, orgChild3: {
orgChild4Id: IsNull(), ancestorDNA: body.nodeId
},
orgChild4: IsNull()
};
break;
case 4:
typeCondition = {
orgChild4: {
ancestorDNA: body.nodeId
},
}; };
break; break;
default: default:
@ -4211,7 +4246,7 @@ export class OrganizationDotnetController extends Controller {
}); });
} }
let findRevision = await this.orgRevisionRepo.findOne({ let findRevision = await this.orgRevisionRepo.findOne({
where: { orgRevisionIsCurrent: true }, where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false },
}); });
if (body.revisionId) { if (body.revisionId) {
@ -4221,7 +4256,7 @@ export class OrganizationDotnetController extends Controller {
} }
const profile_ = await Promise.all( const profile_ = await Promise.all(
profile.map((item: Profile) => { profile.map(async(item: Profile) => {
const shortName = const shortName =
item.current_holders.length == 0 item.current_holders.length == 0
? null ? null
@ -4250,17 +4285,25 @@ export class OrganizationDotnetController extends Controller {
const Oc = const Oc =
item.current_holders.length == 0 item.current_holders.length == 0
? null ? null
: body.node == 4 && item.current_holders[0].orgChild4 != null : (node == 4 || node == null) && item.current_holders[0].orgChild4 != null
? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` ? `${item.current_holders[0].orgChild4.orgChild4Name}/${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
: body.node == 3 && item.current_holders[0].orgChild3 != null : (node == 3 || node == null) && item.current_holders[0].orgChild3 != null
? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` ? `${item.current_holders[0].orgChild3.orgChild3Name}/${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
: body.node == 2 && item.current_holders[0].orgChild2 != null : (node == 2 || node == null) && item.current_holders[0].orgChild2 != null
? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` ? `${item.current_holders[0].orgChild2.orgChild2Name}/${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
: body.node == 1 && item.current_holders[0].orgChild1 != null : (node == 1 || node == null) && item.current_holders[0].orgChild1 != null
? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}` ? `${item.current_holders[0].orgChild1.orgChild1Name}/${item.current_holders[0].orgRoot.orgRootName}`
: body.node == 0 && item.current_holders[0].orgRoot != null : (node == 0 || node == null) && item.current_holders[0].orgRoot != null
? `${item.current_holders[0].orgRoot.orgRootName}` ? `${item.current_holders[0].orgRoot.orgRootName}`
: null; : null;
let _posMaster = await this.posMasterRepository.findOne({
where: {
orgRevisionId: findRevision?.id,
current_holderId: item.id
}
});
return { return {
id: item.id, id: item.id,
prefix: item.prefix, prefix: item.prefix,
@ -4273,6 +4316,11 @@ export class OrganizationDotnetController extends Controller {
positionLevel: item.posLevel?.posLevelName ?? null, positionLevel: item.posLevel?.posLevelName ?? null,
positionType: item.posType?.posTypeName ?? null, positionType: item.posType?.posTypeName ?? null,
oc: Oc, oc: Oc,
orgRootId: _posMaster?.orgRootId,
orgChild1Id: _posMaster?.orgChild1Id,
orgChild2Id: _posMaster?.orgChild2Id,
orgChild3Id: _posMaster?.orgChild3Id,
orgChild4Id: _posMaster?.orgChild4Id
}; };
}), }),
); );