api check keycloak for process check in
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s
This commit is contained in:
parent
b103e15788
commit
7985125882
1 changed files with 117 additions and 0 deletions
|
|
@ -2350,6 +2350,123 @@ export class OrganizationDotnetController extends Controller {
|
|||
return new HttpSuccess(mapProfile);
|
||||
}
|
||||
|
||||
/**
|
||||
* API Get Profile For Process Check In
|
||||
* @summary API Get Profile For Process Check In
|
||||
* @param {string} keycloakId keycloakId profile
|
||||
*/
|
||||
@Get("check-keycloak/{keycloakId}")
|
||||
async GetProfileForProcessCheckInAsync(@Path() keycloakId: string) {
|
||||
/* =========================
|
||||
* 1. Load profile (Officer)
|
||||
* ========================= */
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { keycloak: keycloakId },
|
||||
relations: {
|
||||
current_holders: {
|
||||
orgRevision: true,
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
orgChild3: true,
|
||||
orgChild4: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Employee
|
||||
if (!profile) {
|
||||
const profile = await this.profileEmpRepo.findOne({
|
||||
where: { keycloak: keycloakId },
|
||||
relations: {
|
||||
current_holders: {
|
||||
orgRevision: true,
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
orgChild3: true,
|
||||
orgChild4: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
const currentHolder = profile.current_holders?.find(
|
||||
(x) =>
|
||||
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||
);
|
||||
|
||||
const mapProfile = {
|
||||
profileType: "EMPLOYEE",
|
||||
id: profile.id,
|
||||
keycloak: profile.keycloak,
|
||||
prefix: profile.prefix,
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
gender: profile.gender,
|
||||
|
||||
root: currentHolder?.orgRoot?.orgRootName ?? null,
|
||||
rootId: currentHolder?.orgRootId ?? null,
|
||||
rootDnaId: currentHolder?.orgRoot?.ancestorDNA ?? null,
|
||||
child1: currentHolder?.orgChild1?.orgChild1Name ?? null,
|
||||
child1Id: currentHolder?.orgChild1Id ?? null,
|
||||
child1DnaId: currentHolder?.orgChild1?.ancestorDNA ?? null,
|
||||
child2: currentHolder?.orgChild2?.orgChild2Name ?? null,
|
||||
child2Id: currentHolder?.orgChild2Id ?? null,
|
||||
child2DnaId: currentHolder?.orgChild2?.ancestorDNA ?? null,
|
||||
child3: currentHolder?.orgChild3?.orgChild3Name ?? null,
|
||||
child3Id: currentHolder?.orgChild3Id ?? null,
|
||||
child3DnaId: currentHolder?.orgChild3?.ancestorDNA ?? null,
|
||||
child4: currentHolder?.orgChild4?.orgChild4Name ?? null,
|
||||
child4Id: currentHolder?.orgChild4Id ?? null,
|
||||
child4DnaId: currentHolder?.orgChild4?.ancestorDNA ?? null,
|
||||
};
|
||||
|
||||
return new HttpSuccess(mapProfile);
|
||||
}
|
||||
|
||||
/* =========================================
|
||||
* 2. current holder (Officer)
|
||||
* ========================================= */
|
||||
const currentHolder = profile.current_holders?.find(
|
||||
(x) =>
|
||||
x.orgRevision?.orgRevisionIsDraft === false && x.orgRevision?.orgRevisionIsCurrent === true,
|
||||
);
|
||||
|
||||
/* =========================================
|
||||
* 6. map response
|
||||
* ========================================= */
|
||||
const mapProfile = {
|
||||
profileType: "OFFICER",
|
||||
id: profile.id,
|
||||
keycloak: profile.keycloak,
|
||||
prefix: profile.prefix,
|
||||
firstName: profile.firstName,
|
||||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
gender: profile.gender,
|
||||
|
||||
root: currentHolder?.orgRoot?.orgRootName ?? null,
|
||||
rootId: currentHolder?.orgRootId ?? null,
|
||||
rootDnaId: currentHolder?.orgRoot?.ancestorDNA ?? null,
|
||||
child1: currentHolder?.orgChild1?.orgChild1Name ?? null,
|
||||
child1Id: currentHolder?.orgChild1Id ?? null,
|
||||
child1DnaId: currentHolder?.orgChild1?.ancestorDNA ?? null,
|
||||
child2: currentHolder?.orgChild2?.orgChild2Name ?? null,
|
||||
child2Id: currentHolder?.orgChild2Id ?? null,
|
||||
child2DnaId: currentHolder?.orgChild2?.ancestorDNA ?? null,
|
||||
child3: currentHolder?.orgChild3?.orgChild3Name ?? null,
|
||||
child3Id: currentHolder?.orgChild3Id ?? null,
|
||||
child3DnaId: currentHolder?.orgChild3?.ancestorDNA ?? null,
|
||||
child4: currentHolder?.orgChild4?.orgChild4Name ?? null,
|
||||
child4Id: currentHolder?.orgChild4Id ?? null,
|
||||
child4DnaId: currentHolder?.orgChild4?.ancestorDNA ?? null,
|
||||
};
|
||||
|
||||
return new HttpSuccess(mapProfile);
|
||||
}
|
||||
|
||||
/**
|
||||
* API Get Profile For Logs
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue