From c6487b242c60004c61a390cadb1380c63e53bf59 Mon Sep 17 00:00:00 2001 From: Bright Date: Fri, 20 Jun 2025 15:12:57 +0700 Subject: [PATCH] fix issue #132 --- src/controllers/ProfileController.ts | 43 +++++++++++++++++++++------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index a6bd6535..91793701 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -84,7 +84,7 @@ import { OrgChild3 } from "../entities/OrgChild3"; import { OrgChild4 } from "../entities/OrgChild4"; import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory"; import { ProfileAssistance } from "../entities/ProfileAssistance"; - +import { CommandRecive } from "../entities/CommandRecive"; @Route("api/v1/org/profile") @Tags("Profile") @Security("bearerAuth") @@ -136,6 +136,7 @@ export class ProfileController extends Controller { private profileAbilityRepo = AppDataSource.getRepository(ProfileAbility); private permissionProflileRepository = AppDataSource.getRepository(PermissionProfile); private profileAssistanceRepository = AppDataSource.getRepository(ProfileAssistance); + private commandReciveRepository = AppDataSource.getRepository(CommandRecive); /** * report ประวัติแบบย่อ ข้าราชการ @@ -7806,17 +7807,39 @@ export class ProfileController extends Controller { const data = await Promise.all( profile.profileActpositions .filter(x => x.status) - .map((item, idx) => { + .map(async (item) => { + const commandRef = await this.commandReciveRepository.findOne({ + where: { commandId: item.commandId } + }); + const posMasterActs = await this.posMasterActRepository.findOne({ + where: { + id: commandRef?.refId, + posMaster: { + orgRevisionId: orgRevisionPublish.id, + } + }, + relations: [ + "posMaster", + "posMaster.current_holder" + ], + }); + const _profileAct = await this.profileRepo.findOne({ + where: { id: posMasterActs?.posMaster.current_holderId ?? "" }, + relations: [ + "posLevel", + "posType" + ] + }) return { id: item.id, - posMasterOrder: idx+1, - profileId: item.profileId ?? null, - citizenId: profile.citizenId ?? null, - prefix: profile.prefix ?? null, - firstName: profile.firstName ?? null, - lastName: profile.lastName ?? null, - posLevel: profile.posLevel.posLevelName ?? null, - posType: profile.posType.posTypeName ?? null, + posMasterOrder: posMasterActs?.posMasterOrder, + profileId: _profileAct?.id ?? null, + citizenId: _profileAct?.citizenId ?? null, + prefix: _profileAct?.prefix ?? null, + firstName: _profileAct?.firstName ?? null, + lastName: _profileAct?.lastName ?? null, + posLevel: _profileAct?.posLevel.posLevelName ?? null, + posType: _profileAct?.posType.posTypeName ?? null, position: item.position ?? null, posNo: item.posNo ?? null, }