From 8d6da2f55e0e10f59e7a237a036ad65303cd572a Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Wed, 9 Apr 2025 16:21:06 +0700 Subject: [PATCH] add commanderPositionName --- .../OrganizationDotnetController.ts | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 06adcb71..a0cf74a7 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -303,6 +303,7 @@ export class OrganizationDotnetController extends Controller { }, }); let fullname = ""; + let commanderPositionName = ""; let commanderId = ""; let commanderKeycloak = ""; @@ -393,8 +394,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -417,8 +419,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -441,8 +444,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -465,8 +469,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -489,10 +494,12 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { fullname = ""; + commanderPositionName = ""; commanderId = ""; commanderKeycloak = ""; } @@ -633,6 +640,7 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4Id ?? null, commander: fullname, + commanderPositionName, commanderId, commanderKeycloak, posLevel: profile.posLevel?.posLevelName ?? null, @@ -703,8 +711,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -728,8 +737,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -753,8 +763,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -778,8 +789,9 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { let pos = await this.posMasterRepository.findOne({ relations: ["current_holder"], @@ -803,10 +815,12 @@ export class OrganizationDotnetController extends Controller { pos.current_holder.firstName + " " + pos.current_holder.lastName; - commanderId = pos.current_holder.id; - commanderKeycloak = pos.current_holder.keycloak; + commanderPositionName = pos.current_holder?.position; + commanderId = pos.current_holder?.id; + commanderKeycloak = pos.current_holder?.keycloak; } else { fullname = ""; + commanderPositionName = ""; commanderId = ""; commanderKeycloak = ""; } @@ -952,6 +966,7 @@ export class OrganizationDotnetController extends Controller { x.orgRevision?.orgRevisionIsCurrent == true, )?.orgChild4Id ?? null, commander: fullname, + commanderPositionName, commanderId, commanderKeycloak, posLevel: profile.posLevel?.posLevelName ?? null,