diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index a34c6272..d0b66b2e 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -3198,7 +3198,8 @@ export class PositionController extends Controller { }, ) { let typeCondition: any = {}; - let conditionA = "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel"; + let conditionA = + "positions.posTypeId LIKE :posType AND positions.posLevelId LIKE :posLevel AND positions.positionName LIKE :position"; let posType = await this.posTypeRepository.findOne({ where: { id: String(body.posType) }, @@ -3305,6 +3306,7 @@ export class PositionController extends Controller { qb.andWhere(typeCondition).andWhere(conditionA == null ? "1=1" : conditionA, { posType: posType == null ? `%%` : `${posType.id}`, posLevel: posLevel == null ? `%%` : `${posLevel.id}`, + position: body.position == null ? `%%` : `${body.position}`, }); }), ) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index b68cfbcd..c1f2d13a 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -3583,6 +3583,57 @@ export class ProfileController extends Controller { } return new HttpSuccess(_profile); } + /** + * API ข้อมูลทะเบียนประวัติตาม keycloak + * + * @summary ORG_065 - ข้อมูลทะเบียนประวัติตาม keycloak (ADMIN) #70 + * + */ + @Get("keycloak/position-act") + async getProfileByKeycloakAct( + @Request() request: { user: Record }, + @Query("revisionId") revisionId?: string, + ) { + if (!revisionId) { + let orgRevisionPublish = await this.orgRevisionRepo + .createQueryBuilder("orgRevision") + .where("orgRevision.orgRevisionIsDraft = false") + .andWhere("orgRevision.orgRevisionIsCurrent = true") + .getOne(); + if (!orgRevisionPublish) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบแบบร่างโครงสร้าง"); + } + revisionId = orgRevisionPublish.id; + } + const posMasters = await this.posMasterRepo.findOne({ + where: { + posMasterAssigns: { assignId: "SYS_PLACEMENT_PASS" }, + current_holder: { + keycloak: request.user.sub, + }, + orgRevisionId: revisionId, + }, + relations: ["orgChild1"], + }); + if (posMasters == null || posMasters.orgChild1 == null) { + return new HttpSuccess({ + isOfficer: null, + rootId: null, + child1Id: null, + child2Id: null, + child3Id: null, + child4Id: null, + }); + } + return new HttpSuccess({ + isOfficer: posMasters?.orgChild1?.isOfficer || null, + rootId: posMasters?.orgRootId || null, + child1Id: posMasters?.orgChild1Id || null, + child2Id: posMasters?.orgChild2Id || null, + child3Id: posMasters?.orgChild3Id || null, + child4Id: posMasters?.orgChild4Id || null, + }); + } /** * API เช็ค สกจ