From edd5fdb3aa963bee9296ad1518cd984b8c5b09e4 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 15 Feb 2024 09:39:13 +0700 Subject: [PATCH] add fields api master/list --- src/controllers/PositionController.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 61df770a..9be38242 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -33,6 +33,7 @@ import { OrgChild2 } from "../entities/OrgChild2"; import { OrgChild3 } from "../entities/OrgChild3"; import { OrgChild4 } from "../entities/OrgChild4"; import { Position } from "../entities/Position"; +import { Profile } from "../entities/Profile"; @Route("api/v1/org/pos") @Tags("Position") // @Security("bearerAuth") @@ -48,7 +49,7 @@ export class PositionController extends Controller { private posDictRepository = AppDataSource.getRepository(PosDict); private posMasterRepository = AppDataSource.getRepository(PosMaster); private positionRepository = AppDataSource.getRepository(Position); - + private profileRepository = AppDataSource.getRepository(Profile); private orgRevisionRepository = AppDataSource.getRepository(OrgRevision); private orgRootRepository = AppDataSource.getRepository(OrgRoot); private child1Repository = AppDataSource.getRepository(OrgChild1); @@ -887,6 +888,15 @@ export class PositionController extends Controller { }, relations: ["posLevel", "posType", "posExecutive"], }); + const profile = await this.profileRepository.findOne({ + where: { id: String(posMaster.next_holderId) } + }) + const type = await this.posTypeRepository.findOne({ + where: { id: String(profile?.posTypeId) } + }) + const level = await this.posLevelRepository.findOne({ + where: { id: String(profile?.posLevelId)} + }) let shortName = ""; @@ -953,6 +963,10 @@ export class PositionController extends Controller { ? null : `${posMaster.next_holder.prefix}${posMaster.next_holder.firstName} ${posMaster.next_holder.lastName}`, orgShortname: shortName, + isSit: posMaster.isSit, + positionNextHolder: profile == null || profile.position == null? null : profile.position, + postypeNextHolder: type == null || type.posTypeName == null ? null : type.posTypeName, + poslevelNextHolder: level == null || level.posLevelName == null ? null : level.posLevelName, positions: positions.map((position) => ({ id: position.id, positionName: position.positionName,