diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 0814d8a2..3a03f56a 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -4792,7 +4792,16 @@ export class OrganizationDotnetController extends Controller { async getProfileByKeycloak(@Path() keycloakId: string) { const profile = await this.profileRepo.findOne({ where: { keycloak: keycloakId }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); @@ -4807,11 +4816,16 @@ export class OrganizationDotnetController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง"); } - const root = - profile.current_holders == null || - profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == null + const holder = + profile.current_holders == null ? null - : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot; + : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) ?? null; + + const root = holder?.orgRoot ?? null; + const child1 = holder?.orgChild1 ?? null; + const child2 = holder?.orgChild2 ?? null; + const child3 = holder?.orgChild3 ?? null; + const child4 = holder?.orgChild4 ?? null; const _profile: any = { profileId: profile.id, @@ -4828,6 +4842,10 @@ export class OrganizationDotnetController extends Controller { root: root == null ? null : root.orgRootName, rootShortName: root == null ? null : root.orgRootShortName, rootDnaId: root == null ? null : root.ancestorDNA, + child1DnaId: child1 == null ? null : child1.ancestorDNA, + child2DnaId: child2 == null ? null : child2.ancestorDNA, + child3DnaId: child3 == null ? null : child3.ancestorDNA, + child4DnaId: child4 == null ? null : child4.ancestorDNA, }; return new HttpSuccess(_profile); }