เพิ่มฟิลด์ที่ทำให้รู้ว่าการร้องขอนี้มาจากสำนักปลัด #2222
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m27s

This commit is contained in:
harid 2026-03-04 17:41:37 +07:00
parent f59a5eec80
commit f8bb9e7cab
2 changed files with 38 additions and 0 deletions

View file

@ -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);
}

View file

@ -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);
}