From a1610880f03610accf8d379d84cd67708f51e7c1 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 15 Feb 2024 12:13:34 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A=20api=20ma?= =?UTF-8?q?ster/list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PositionController.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index eae9dadf..08be12d2 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -849,9 +849,21 @@ export class PositionController extends Controller { }, relations: ["posLevel", "posType", "posExecutive"], }); - const profile = await this.profileRepository.findOne({ - where: { id: String(posMaster.next_holderId) }, - }); + + let profile: any; + const chkRevision = await this.orgRevisionRepository.findOne({ + where: { id: posMaster.orgRevisionId } + }) + if(chkRevision?.orgRevisionIsCurrent && !chkRevision?.orgRevisionIsDraft){ + profile = await this.profileRepository.findOne({ + where: { id: String(posMaster.current_holderId) }, + }); + } + else if(!chkRevision?.orgRevisionIsCurrent && chkRevision?.orgRevisionIsDraft){ + profile = await this.profileRepository.findOne({ + where: { id: String(posMaster.next_holderId) }, + }); + } const type = await this.posTypeRepository.findOne({ where: { id: String(profile?.posTypeId) }, }); @@ -925,10 +937,11 @@ export class PositionController extends Controller { : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, orgShortname: shortName, isSit: posMaster.isSit, - positionNextHolder: + profilePosition: profile == null || profile.position == null ? null : profile.position, - postypeNextHolder: type == null || type.posTypeName == null ? null : type.posTypeName, - poslevelNextHolder: + profilePostype: + type == null || type.posTypeName == null ? null : type.posTypeName, + profilePoslevel: level == null || level.posLevelName == null ? null : level.posLevelName, positions: positions.map((position) => ({ id: position.id,