From 2217355dea7da6f5b509e2915d03961ca87166c6 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 8 May 2024 11:43:01 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A7=20=E0=B8=95=E0=B8=B3=E0=B9=81?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=E0=B8=97=E0=B8=B2=E0=B8=87?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9A=E0=B8=A3=E0=B8=B4=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index cd3c7dfb..e1d76c73 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -33,6 +33,7 @@ import { PosLevel } from "../entities/PosLevel"; import { PosType } from "../entities/PosType"; import { calculateAge, calculateRetireDate, calculateRetireYear } from "../interfaces/utils"; import { RequestWithUser } from "../middlewares/user"; +import { Position } from "../entities/Position"; @Route("api/v1/org/profile") @Tags("Profile") @@ -50,6 +51,7 @@ export class ProfileController extends Controller { private posLevelRepo = AppDataSource.getRepository(PosLevel); private posTypeRepo = AppDataSource.getRepository(PosType); private orgRevisionRepository = AppDataSource.getRepository(OrgRevision); + private positionRepository = AppDataSource.getRepository(Position); /** * @@ -752,6 +754,14 @@ export class ProfileController extends Controller { profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id) == null ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id); + + const position = await this.positionRepository.findOne({ + relations: ["posExecutive"], + where: { + posMasterId: posMaster?.id + } + }); + const _profile: any = { profileId: profile.id, prefix: profile.prefix, @@ -767,6 +777,15 @@ export class ProfileController extends Controller { posTypeName: profile.posType == null ? null : profile.posType.posTypeName, posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank, posTypeId: profile.posType == null ? null : profile.posType.id, + posExecutiveName: position == null || position.posExecutive == null + ? null + : position.posExecutive.posExecutiveName, + posExecutivePriority: position == null || position.posExecutive == null + ? null + : position.posExecutive.posExecutivePriority, + posExecutiveId: position == null || position.posExecutive == null + ? null + : position.posExecutive.id, rootId: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgRoot == @@ -1911,6 +1930,19 @@ export class ProfileController extends Controller { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); } + const posMaster = await this.posMasterRepo.findOne({ + where: { + current_holderId: profile.id, + orgRevisionId: revisionId + } + }); + const position = await this.positionRepository.findOne({ + relations: ["posExecutive"], + where: { + posMasterId: posMaster?.id + } + }); + const _profile = { profileId: profile.id, prefix: profile.prefix, @@ -1925,6 +1957,15 @@ export class ProfileController extends Controller { posTypeName: profile.posType == null ? null : profile.posType.posTypeName, posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank, posTypeId: profile.posType == null ? null : profile.posType.id, + posExecutiveName: position == null || position.posExecutive == null + ? null + : position.posExecutive.posExecutiveName, + posExecutivePriority: position == null || position.posExecutive == null + ? null + : position.posExecutive.posExecutivePriority, + posExecutiveId: position == null || position.posExecutive == null + ? null + : position.posExecutive.id, rootId: profile.current_holders == null || profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||