Merge branch 'develop' into adiDev
This commit is contained in:
commit
039b11d1c3
2 changed files with 155 additions and 9 deletions
|
|
@ -2863,4 +2863,45 @@ export class OrganizationController extends Controller {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API หาสำนักทั้งหมด by revision
|
||||||
|
*
|
||||||
|
* @summary หาสำนักทั้งหมด by revision
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("active/root/{revisionId}")
|
||||||
|
async GetActiveRootByRevision(@Path() revisionId: string) {
|
||||||
|
try {
|
||||||
|
const data = await this.orgRootRepository.find({
|
||||||
|
where: { orgRevisionId: revisionId },
|
||||||
|
relations: [
|
||||||
|
"orgRevision",
|
||||||
|
"orgChild1s",
|
||||||
|
"orgChild1s.orgChild2s",
|
||||||
|
"orgChild1s.orgChild2s.orgChild3s",
|
||||||
|
"orgChild1s.orgChild2s.orgChild3s.orgChild4s",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
return new HttpSuccess(data);
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* API หา revision ล่าสุด
|
||||||
|
*
|
||||||
|
* @summary หา revision ล่าสุด
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("revision/latest")
|
||||||
|
async salaryGen() {
|
||||||
|
const findRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { orgRevisionIsCurrent: true },
|
||||||
|
});
|
||||||
|
if (!findRevision) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบโครงสร้างล่าสุด");
|
||||||
|
}
|
||||||
|
return new HttpSuccess(findRevision.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -991,19 +991,19 @@ export class ProfileController extends Controller {
|
||||||
}
|
}
|
||||||
const posExecutive =
|
const posExecutive =
|
||||||
item.positions == null ||
|
item.positions == null ||
|
||||||
item.positions?.find((position) => position.positionIsSelected ==true) == null ||
|
item.positions?.find((position) => position.positionIsSelected == true) == null ||
|
||||||
item.positions?.find((position) => position.positionIsSelected ==true)?.posExecutive == null ||
|
item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive ==
|
||||||
item.positions?.find((position) => position.positionIsSelected ==true)?.posExecutive?.posExecutiveName == null
|
null ||
|
||||||
|
item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
|
?.posExecutiveName == null
|
||||||
? null
|
? null
|
||||||
: item.positions?.find((position) => position.positionIsSelected ==true)?.posExecutive
|
: item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
|
||||||
.posExecutiveName;
|
.posExecutiveName;
|
||||||
|
|
||||||
|
|
||||||
const amount =
|
const amount =
|
||||||
item.current_holder == null ||
|
item.current_holder == null || item.current_holder.profileSalary.length == 0
|
||||||
item.current_holder.profileSalary.length == 0
|
? null
|
||||||
? null
|
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
|
||||||
: item.current_holder.profileSalary.sort((a:any, b:any) => b.date - a.date)[0].amount;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
prefix: item.current_holder.prefix,
|
prefix: item.current_holder.prefix,
|
||||||
|
|
@ -1019,6 +1019,7 @@ export class ProfileController extends Controller {
|
||||||
posLevelId: item.current_holder.posLevelId,
|
posLevelId: item.current_holder.posLevelId,
|
||||||
posExecutive: posExecutive,
|
posExecutive: posExecutive,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
|
revisionId: item.orgRevisionId,
|
||||||
rootId: item.orgRootId,
|
rootId: item.orgRootId,
|
||||||
root: item.orgRoot?.orgRootName,
|
root: item.orgRoot?.orgRootName,
|
||||||
child1Id: item.orgChild1Id,
|
child1Id: item.orgChild1Id,
|
||||||
|
|
@ -1039,4 +1040,108 @@ export class ProfileController extends Controller {
|
||||||
|
|
||||||
return new HttpSuccess(formattedData);
|
return new HttpSuccess(formattedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ข้อมูลทะเบียนประวัติตาม keycloak by revisionId
|
||||||
|
*
|
||||||
|
* @summary ข้อมูลทะเบียนประวัติตาม keycloak by revisionId (ADMIN)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("keycloak/position/{revisionId}")
|
||||||
|
async getProfileByKeycloakByRevision(
|
||||||
|
@Path() revisionId: string,
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
const profile = await this.profileRepository.findOne({
|
||||||
|
where: { keycloak: request.user.sub },
|
||||||
|
relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"],
|
||||||
|
});
|
||||||
|
if (!profile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ");
|
||||||
|
}
|
||||||
|
|
||||||
|
const _profile = {
|
||||||
|
profileId: profile.id,
|
||||||
|
prefix: profile.prefix,
|
||||||
|
firstName: profile.firstName,
|
||||||
|
lastName: profile.lastName,
|
||||||
|
citizenId: profile.citizenId,
|
||||||
|
position: profile.position,
|
||||||
|
posLevelName: profile.posLevel == null ? null : profile.posLevel.posLevelName,
|
||||||
|
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
|
||||||
|
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
|
||||||
|
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
|
||||||
|
posTypeRank: profile.posType == null ? null : profile.posType.posTypeRank,
|
||||||
|
posTypeId: profile.posType == null ? null : profile.posType.id,
|
||||||
|
rootId:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRootId,
|
||||||
|
root:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgRoot.orgRootName,
|
||||||
|
child1Id:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1Id,
|
||||||
|
child1:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild1
|
||||||
|
.orgChild1Name,
|
||||||
|
child2Id:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2Id,
|
||||||
|
child2:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild2
|
||||||
|
.orgChild2Name,
|
||||||
|
child3Id:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3Id,
|
||||||
|
child3:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild3
|
||||||
|
.orgChild3Name,
|
||||||
|
child4Id:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4Id,
|
||||||
|
child4:
|
||||||
|
profile.current_holders == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId) == null ||
|
||||||
|
profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4 == null
|
||||||
|
? null
|
||||||
|
: profile.current_holders.find((x) => x.orgRevisionId == revisionId)?.orgChild4
|
||||||
|
.orgChild4Name,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return new HttpSuccess(_profile);
|
||||||
|
} catch (error: any) {
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue