เพิ่มฟิลด์ที่ทำให้รู้ว่าการร้องขอนี้มาจากสำนักปลัด #2222
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m27s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m27s
This commit is contained in:
parent
f59a5eec80
commit
f8bb9e7cab
2 changed files with 38 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ import CallAPI from "../interfaces/call-api";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { OrgRoot } from "../entities/OrgRoot";
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
|
import { PosMaster } from "../entities/PosMaster";
|
||||||
@Route("api/v1/org/profile/edit")
|
@Route("api/v1/org/profile/edit")
|
||||||
@Tags("ProfileEdit")
|
@Tags("ProfileEdit")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -32,6 +33,7 @@ export class ProfileEditController extends Controller {
|
||||||
private profileEditRepo = AppDataSource.getRepository(ProfileEdit);
|
private profileEditRepo = AppDataSource.getRepository(ProfileEdit);
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||||
|
private posMasterRepo = AppDataSource.getRepository(PosMaster);
|
||||||
|
|
||||||
@Get("user")
|
@Get("user")
|
||||||
public async detailProfileEditUser(
|
public async detailProfileEditUser(
|
||||||
|
|
@ -272,6 +274,22 @@ export class ProfileEditController extends Controller {
|
||||||
if (!getProfileEdit) {
|
if (!getProfileEdit) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
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 = {
|
const _data = {
|
||||||
id: getProfileEdit.id,
|
id: getProfileEdit.id,
|
||||||
topic: getProfileEdit.topic,
|
topic: getProfileEdit.topic,
|
||||||
|
|
@ -289,6 +307,7 @@ export class ProfileEditController extends Controller {
|
||||||
(getProfileEdit?.profile?.firstName ?? "") +
|
(getProfileEdit?.profile?.firstName ?? "") +
|
||||||
" " +
|
" " +
|
||||||
(getProfileEdit?.profile?.lastName ?? ""),
|
(getProfileEdit?.profile?.lastName ?? ""),
|
||||||
|
isDeputy: orgRoot?.isDeputy ?? false
|
||||||
};
|
};
|
||||||
return new HttpSuccess(_data);
|
return new HttpSuccess(_data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import permission from "../interfaces/permission";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { OrgRoot } from "../entities/OrgRoot";
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
import CallAPI from "../interfaces/call-api";
|
import CallAPI from "../interfaces/call-api";
|
||||||
|
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||||
@Route("api/v1/org/profile-employee/edit")
|
@Route("api/v1/org/profile-employee/edit")
|
||||||
@Tags("ProfileEmployeeEdit")
|
@Tags("ProfileEmployeeEdit")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -36,6 +37,7 @@ export class ProfileEditEmployeeController extends Controller {
|
||||||
private profileEditRepository = AppDataSource.getRepository(ProfileEdit);
|
private profileEditRepository = AppDataSource.getRepository(ProfileEdit);
|
||||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
private orgRootRepo = AppDataSource.getRepository(OrgRoot);
|
||||||
|
private empPosMasterRepo = AppDataSource.getRepository(EmployeePosMaster);
|
||||||
|
|
||||||
@Get("user")
|
@Get("user")
|
||||||
public async detailProfileEditUserEmp(
|
public async detailProfileEditUserEmp(
|
||||||
|
|
@ -271,6 +273,22 @@ export class ProfileEditEmployeeController extends Controller {
|
||||||
if (!getProfileEdit) {
|
if (!getProfileEdit) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
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 = {
|
const _data = {
|
||||||
id: getProfileEdit.id,
|
id: getProfileEdit.id,
|
||||||
topic: getProfileEdit.topic,
|
topic: getProfileEdit.topic,
|
||||||
|
|
@ -288,6 +306,7 @@ export class ProfileEditEmployeeController extends Controller {
|
||||||
(getProfileEdit?.profileEmployee?.firstName ?? "") +
|
(getProfileEdit?.profileEmployee?.firstName ?? "") +
|
||||||
" " +
|
" " +
|
||||||
(getProfileEdit?.profileEmployee?.lastName ?? ""),
|
(getProfileEdit?.profileEmployee?.lastName ?? ""),
|
||||||
|
isDeputy: orgRoot?.isDeputy ?? false
|
||||||
};
|
};
|
||||||
return new HttpSuccess(_data);
|
return new HttpSuccess(_data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue