API Get Profile For Logs
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m0s
@Get("user-logs/{keycloakId}")
This commit is contained in:
parent
ecd002456e
commit
b64a8bb26d
1 changed files with 112 additions and 32 deletions
|
|
@ -1201,8 +1201,8 @@ export class OrganizationDotnetController extends Controller {
|
||||||
profileType: "OFFICER",
|
profileType: "OFFICER",
|
||||||
positionLeaveName: positionLeaveName,
|
positionLeaveName: positionLeaveName,
|
||||||
posExecutiveName: position == null || position.posExecutive == null
|
posExecutiveName: position == null || position.posExecutive == null
|
||||||
? null
|
? null
|
||||||
: position.posExecutive.posExecutiveName,
|
: position.posExecutive.posExecutiveName,
|
||||||
oc: oc,
|
oc: oc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1345,9 +1345,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
|
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" ||
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
profile.posType.posTypeName === "อำนวยการ")
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: profile.posLevel?.posLevelName ?? null;
|
||||||
|
|
||||||
|
|
@ -1549,9 +1549,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" ||
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
profile.posType.posTypeName === "อำนวยการ")
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: profile.posLevel?.posLevelName ?? null;
|
||||||
|
|
||||||
|
|
@ -1808,9 +1808,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" ||
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
profile.posType.posTypeName === "อำนวยการ")
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: profile.posLevel?.posLevelName ?? null;
|
||||||
|
|
||||||
|
|
@ -1876,6 +1876,86 @@ export class OrganizationDotnetController extends Controller {
|
||||||
return new HttpSuccess(mapProfile);
|
return new HttpSuccess(mapProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API Get Profile For Logs
|
||||||
|
*
|
||||||
|
* @summary API Get Profile For Logs
|
||||||
|
*
|
||||||
|
* @param {string} keycloakId keycloakId profile
|
||||||
|
*/
|
||||||
|
@Get("user-logs/{keycloakId}")
|
||||||
|
async UserLogs(@Path() keycloakId: string) {
|
||||||
|
/* =========================
|
||||||
|
* 1. Load profile
|
||||||
|
* ========================= */
|
||||||
|
const profile = await this.profileRepo.findOne({
|
||||||
|
where: { keycloak: keycloakId },
|
||||||
|
relations: {
|
||||||
|
current_holders: {
|
||||||
|
orgRevision: true,
|
||||||
|
orgRoot: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Employee
|
||||||
|
if (!profile) {
|
||||||
|
const profile = await this.profileEmpRepo.findOne({
|
||||||
|
where: { keycloak: keycloakId },
|
||||||
|
relations: {
|
||||||
|
current_holders: {
|
||||||
|
orgRevision: true,
|
||||||
|
orgRoot: 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 = {
|
||||||
|
profileId: profile.id,
|
||||||
|
keycloak: profile.keycloak,
|
||||||
|
prefix: profile.prefix,
|
||||||
|
firstName: profile.firstName,
|
||||||
|
lastName: profile.lastName,
|
||||||
|
citizenId: profile.citizenId,
|
||||||
|
rootId: currentHolder?.orgRootId ?? null,
|
||||||
|
rootDnaId: currentHolder?.orgRoot?.ancestorDNA ?? null,
|
||||||
|
};
|
||||||
|
|
||||||
|
return new HttpSuccess(mapProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =========================================
|
||||||
|
* 2. current holder
|
||||||
|
* ========================================= */
|
||||||
|
const currentHolder = profile.current_holders?.find(
|
||||||
|
x =>
|
||||||
|
x.orgRevision?.orgRevisionIsDraft === false &&
|
||||||
|
x.orgRevision?.orgRevisionIsCurrent === true,
|
||||||
|
);
|
||||||
|
|
||||||
|
/* =========================================
|
||||||
|
* 8. map response
|
||||||
|
* ========================================= */
|
||||||
|
const mapProfile = {
|
||||||
|
profileId: profile.id,
|
||||||
|
keycloak: profile.keycloak,
|
||||||
|
prefix: profile.prefix,
|
||||||
|
firstName: profile.firstName,
|
||||||
|
lastName: profile.lastName,
|
||||||
|
citizenId: profile.citizenId,
|
||||||
|
rootId: currentHolder?.orgRootId ?? null,
|
||||||
|
rootDnaId: currentHolder?.orgRoot?.ancestorDNA ?? null,
|
||||||
|
};
|
||||||
|
|
||||||
|
return new HttpSuccess(mapProfile);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 3. API Get Profile จาก profile id
|
* 3. API Get Profile จาก profile id
|
||||||
*
|
*
|
||||||
|
|
@ -4132,7 +4212,7 @@ export class OrganizationDotnetController extends Controller {
|
||||||
// "current_holders.orgChild3",
|
// "current_holders.orgChild3",
|
||||||
// "current_holders.orgChild4",
|
// "current_holders.orgChild4",
|
||||||
// ],
|
// ],
|
||||||
relations:{
|
relations: {
|
||||||
posType: true,
|
posType: true,
|
||||||
posLevel: true,
|
posLevel: true,
|
||||||
current_holders: {
|
current_holders: {
|
||||||
|
|
@ -7078,9 +7158,9 @@ export class OrganizationDotnetController extends Controller {
|
||||||
* ========================================= */
|
* ========================================= */
|
||||||
const positionLeaveName =
|
const positionLeaveName =
|
||||||
profile.posType &&
|
profile.posType &&
|
||||||
profile.posLevel &&
|
profile.posLevel &&
|
||||||
(profile.posType.posTypeName === "บริหาร" ||
|
(profile.posType.posTypeName === "บริหาร" ||
|
||||||
profile.posType.posTypeName === "อำนวยการ")
|
profile.posType.posTypeName === "อำนวยการ")
|
||||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||||
: profile.posLevel?.posLevelName ?? null;
|
: profile.posLevel?.posLevelName ?? null;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue