api check keycloak for process check in
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m7s

This commit is contained in:
harid 2026-05-15 14:58:13 +07:00
parent b103e15788
commit 7985125882

View file

@ -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
*