From f8bb9e7cab6d90cc5f88ce054cbadf1c9e075ee4 Mon Sep 17 00:00:00 2001 From: harid Date: Wed, 4 Mar 2026 17:41:37 +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=A5=E0=B8=94=E0=B9=8C=E0=B8=97=E0=B8=B5?= =?UTF-8?q?=E0=B9=88=E0=B8=97=E0=B8=B3=E0=B9=83=E0=B8=AB=E0=B9=89=E0=B8=A3?= =?UTF-8?q?=E0=B8=B9=E0=B9=89=E0=B8=A7=E0=B9=88=E0=B8=B2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=A3=E0=B9=89=E0=B8=AD=E0=B8=87=E0=B8=82=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=E0=B8=B5=E0=B9=89=E0=B8=A1=E0=B8=B2=E0=B8=88=E0=B8=B2?= =?UTF-8?q?=E0=B8=81=E0=B8=AA=E0=B8=B3=E0=B8=99=E0=B8=B1=E0=B8=81=E0=B8=9B?= =?UTF-8?q?=E0=B8=A5=E0=B8=B1=E0=B8=94=20#2222?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileEditController.ts | 19 +++++++++++++++++++ .../ProfileEditEmployeeController.ts | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index a1e081f3..35f26786 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -24,6 +24,7 @@ import CallAPI from "../interfaces/call-api"; import permission from "../interfaces/permission"; import { OrgRevision } from "../entities/OrgRevision"; import { OrgRoot } from "../entities/OrgRoot"; +import { PosMaster } from "../entities/PosMaster"; @Route("api/v1/org/profile/edit") @Tags("ProfileEdit") @Security("bearerAuth") @@ -32,6 +33,7 @@ export class ProfileEditController extends Controller { private profileEditRepo = AppDataSource.getRepository(ProfileEdit); private orgRevisionRepository = AppDataSource.getRepository(OrgRevision); private orgRootRepo = AppDataSource.getRepository(OrgRoot); + private posMasterRepo = AppDataSource.getRepository(PosMaster); @Get("user") public async detailProfileEditUser( @@ -272,6 +274,22 @@ export class ProfileEditController extends Controller { if (!getProfileEdit) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } + let orgRoot: OrgRoot | null = null; + if(getProfileEdit.profile) { + const empPosMaster = await this.posMasterRepo.findOne({ + where: { + current_holderId: getProfileEdit.profile.id, + orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false } + }, + relations: { orgRevision: true } + }); + if(empPosMaster) { + orgRoot = await this.orgRootRepo.findOne({ + select: { isDeputy: true }, + where: { id: empPosMaster.orgRootId ?? "" } + }); + } + } const _data = { id: getProfileEdit.id, topic: getProfileEdit.topic, @@ -289,6 +307,7 @@ export class ProfileEditController extends Controller { (getProfileEdit?.profile?.firstName ?? "") + " " + (getProfileEdit?.profile?.lastName ?? ""), + isDeputy: orgRoot?.isDeputy ?? false }; return new HttpSuccess(_data); } diff --git a/src/controllers/ProfileEditEmployeeController.ts b/src/controllers/ProfileEditEmployeeController.ts index 87bba20a..2cdd9fde 100644 --- a/src/controllers/ProfileEditEmployeeController.ts +++ b/src/controllers/ProfileEditEmployeeController.ts @@ -28,6 +28,7 @@ import permission from "../interfaces/permission"; import { OrgRevision } from "../entities/OrgRevision"; import { OrgRoot } from "../entities/OrgRoot"; import CallAPI from "../interfaces/call-api"; +import { EmployeePosMaster } from "../entities/EmployeePosMaster"; @Route("api/v1/org/profile-employee/edit") @Tags("ProfileEmployeeEdit") @Security("bearerAuth") @@ -36,6 +37,7 @@ export class ProfileEditEmployeeController extends Controller { private profileEditRepository = AppDataSource.getRepository(ProfileEdit); private orgRevisionRepository = AppDataSource.getRepository(OrgRevision); private orgRootRepo = AppDataSource.getRepository(OrgRoot); + private empPosMasterRepo = AppDataSource.getRepository(EmployeePosMaster); @Get("user") public async detailProfileEditUserEmp( @@ -271,6 +273,22 @@ export class ProfileEditEmployeeController extends Controller { if (!getProfileEdit) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } + let orgRoot: OrgRoot | null = null; + if(getProfileEdit.profileEmployee) { + const empPosMaster = await this.empPosMasterRepo.findOne({ + where: { + current_holderId: getProfileEdit.profileEmployee.id, + orgRevision: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false } + }, + relations: { orgRevision: true } + }); + if(empPosMaster) { + orgRoot = await this.orgRootRepo.findOne({ + select: { isDeputy: true }, + where: { id: empPosMaster.orgRootId ?? "" } + }); + } + } const _data = { id: getProfileEdit.id, topic: getProfileEdit.topic, @@ -288,6 +306,7 @@ export class ProfileEditEmployeeController extends Controller { (getProfileEdit?.profileEmployee?.firstName ?? "") + " " + (getProfileEdit?.profileEmployee?.lastName ?? ""), + isDeputy: orgRoot?.isDeputy ?? false }; return new HttpSuccess(_data); }