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",
|
||||
positionLeaveName: positionLeaveName,
|
||||
posExecutiveName: position == null || position.posExecutive == null
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
? null
|
||||
: position.posExecutive.posExecutiveName,
|
||||
oc: oc,
|
||||
};
|
||||
|
||||
|
|
@ -1345,9 +1345,9 @@ export class OrganizationDotnetController extends Controller {
|
|||
|
||||
const positionLeaveName =
|
||||
profile.posType &&
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||
: profile.posLevel?.posLevelName ?? null;
|
||||
|
||||
|
|
@ -1549,9 +1549,9 @@ export class OrganizationDotnetController extends Controller {
|
|||
* ========================================= */
|
||||
const positionLeaveName =
|
||||
profile.posType &&
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||
: profile.posLevel?.posLevelName ?? null;
|
||||
|
||||
|
|
@ -1808,9 +1808,9 @@ export class OrganizationDotnetController extends Controller {
|
|||
* ========================================= */
|
||||
const positionLeaveName =
|
||||
profile.posType &&
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||
: profile.posLevel?.posLevelName ?? null;
|
||||
|
||||
|
|
@ -1849,7 +1849,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
||||
|
||||
posLevel: profile.posLevel?.posLevelName ?? null,
|
||||
posType: profile.posType?.posTypeName ?? null,
|
||||
posExecutiveName: position?.posExecutive?.posExecutiveName ?? null,
|
||||
|
|
@ -1876,6 +1876,86 @@ export class OrganizationDotnetController extends Controller {
|
|||
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
|
||||
*
|
||||
|
|
@ -4132,7 +4212,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
// "current_holders.orgChild3",
|
||||
// "current_holders.orgChild4",
|
||||
// ],
|
||||
relations:{
|
||||
relations: {
|
||||
posType: true,
|
||||
posLevel: true,
|
||||
current_holders: {
|
||||
|
|
@ -6887,9 +6967,9 @@ export class OrganizationDotnetController extends Controller {
|
|||
|
||||
@Post("profile-leave/keycloak")
|
||||
async GetProfileLeaveReportByKeycloakIdAsync(
|
||||
@Body() body: {
|
||||
keycloakId: string,
|
||||
report?: string
|
||||
@Body() body: {
|
||||
keycloakId: string,
|
||||
report?: string
|
||||
}
|
||||
) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -7002,14 +7082,14 @@ export class OrganizationDotnetController extends Controller {
|
|||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
birthDate: profile.birthDate,
|
||||
retireDate: profile.birthDate
|
||||
? calculateRetireLaw(profile.birthDate)
|
||||
retireDate: profile.birthDate
|
||||
? calculateRetireLaw(profile.birthDate)
|
||||
: null,
|
||||
govAge: profile.dateAppoint
|
||||
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
||||
govAge: profile.dateAppoint
|
||||
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
||||
: null,
|
||||
age: profile.birthDate
|
||||
? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET")
|
||||
age: profile.birthDate
|
||||
? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET")
|
||||
: null,
|
||||
dateAppoint: profile.dateAppoint,
|
||||
dateCurrent: new Date(),
|
||||
|
|
@ -7078,9 +7158,9 @@ export class OrganizationDotnetController extends Controller {
|
|||
* ========================================= */
|
||||
const positionLeaveName =
|
||||
profile.posType &&
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
profile.posLevel &&
|
||||
(profile.posType.posTypeName === "บริหาร" ||
|
||||
profile.posType.posTypeName === "อำนวยการ")
|
||||
? `${profile.posType.posTypeName}${profile.posLevel.posLevelName}`
|
||||
: profile.posLevel?.posLevelName ?? null;
|
||||
|
||||
|
|
@ -7142,14 +7222,14 @@ export class OrganizationDotnetController extends Controller {
|
|||
lastName: profile.lastName,
|
||||
citizenId: profile.citizenId,
|
||||
birthDate: profile.birthDate,
|
||||
retireDate: profile.birthDate
|
||||
? calculateRetireLaw(profile.birthDate)
|
||||
retireDate: profile.birthDate
|
||||
? calculateRetireLaw(profile.birthDate)
|
||||
: null,
|
||||
govAge: profile.dateAppoint
|
||||
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
||||
govAge: profile.dateAppoint
|
||||
? `${Extension.CalculateGovAge(profile.dateAppoint, 0, 0)} ปี`
|
||||
: null,
|
||||
age: profile.birthDate
|
||||
? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET")
|
||||
age: profile.birthDate
|
||||
? Extension.CalculateAgeStrV2(profile.birthDate, 0, 0, "GET")
|
||||
: null,
|
||||
dateAppoint: profile.dateAppoint,
|
||||
dateCurrent: new Date(),
|
||||
|
|
@ -7182,7 +7262,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
child3: currentHolder?.orgChild3?.orgChild3Name ?? null,
|
||||
child4: currentHolder?.orgChild4?.orgChild4Name ?? null,
|
||||
oc: oc,
|
||||
|
||||
|
||||
positions: _positions,
|
||||
educations: _educations,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue