From d89c61e9ffb19fc3fc408fc0e5743ba42384daae Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 25 Sep 2024 10:58:28 +0700 Subject: [PATCH] add field salary(Current) --- src/controllers/ProfileController.ts | 10 +++++++++- src/controllers/ProfileEmployeeController.ts | 12 ++++++++++-- src/controllers/ProfileEmployeeTempController.ts | 10 +++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index da3f5903..b4edbbcc 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -3190,7 +3190,12 @@ export class ProfileController extends Controller { async getProfileByKeycloak(@Request() request: { user: Record }) { const profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileSalary"], + order: { + profileSalary: { + order: "DESC", + } + } }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); @@ -3299,6 +3304,9 @@ export class ProfileController extends Controller { child4ShortName: child4 == null ? null : child4.orgChild4ShortName, node: null, nodeId: null, + salary: profile && profile.profileSalary.length > 0 + ? profile.profileSalary[0].amount + : null }; if (_profile.child4Id != null) { diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 164e9004..5d0c29eb 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1741,7 +1741,12 @@ export class ProfileEmployeeController extends Controller { async getProfileByKeycloak(@Request() request: { user: Record }) { const profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileSalarys"], + order: { + profileSalarys: { + order: "DESC", + } + } }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); @@ -1840,7 +1845,10 @@ export class ProfileEmployeeController extends Controller { ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 .orgChild4Name, - }; + salary: profile && profile.profileSalarys.length > 0 + ? profile.profileSalarys[0].amount + : null +}; return new HttpSuccess(_profile); } diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 96bea029..90ff2976 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -1538,7 +1538,12 @@ export class ProfileEmployeeTempController extends Controller { async getProfileByKeycloak(@Request() request: { user: Record }) { const profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot","profileSalarys"], + order: { + profileSalarys: { + order: "DESC", + } + } }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); @@ -1637,6 +1642,9 @@ export class ProfileEmployeeTempController extends Controller { ? null : profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4 .orgChild4Name, + salary: profile && profile.profileSalarys.length > 0 + ? profile.profileSalarys[0].amount + : null }; return new HttpSuccess(_profile); }