From 43b6e42389b437c7dbfe3f483aae5a2ec7a44be6 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Mon, 24 Feb 2025 15:26:38 +0700 Subject: [PATCH 1/2] add path salary employee position --- .../ProfileSalaryEmployeeController.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index 5bd933f4..a0b561e5 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -59,6 +59,21 @@ export class ProfileSalaryEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("position/{profileId}") + public async getPositionSalaryEmployee( + @Path() profileId: string, + @Request() req: RequestWithUser, + ) { + let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP"); + if (_workflow == false) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); + const record = await this.salaryRepo.find({ + where: { profileEmployeeId: profileId }, + order: { order: "ASC" }, + }); + return new HttpSuccess(record); + } + @Get("admin/{profileId}") public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE"); From d88ac804bebf9fe8ab064ac81ab9a8f363e874f9 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Mon, 24 Feb 2025 16:21:33 +0700 Subject: [PATCH 2/2] add path salary position of user --- src/controllers/ProfileSalaryController.ts | 13 +++++++++++++ src/controllers/ProfileSalaryEmployeeController.ts | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 827a0913..cbba0397 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -43,6 +43,19 @@ export class ProfileSalaryController extends Controller { return new HttpSuccess(record); } + @Get("position/user") + public async getSalaryPositionUser(@Request() request: { user: Record }) { + const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub }); + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + const record = await this.salaryRepo.find({ + where: { profileId: profile.id }, + order: { order: "ASC" }, + }); + return new HttpSuccess(record); + } + @Get("{profileId}") public async getSalary(@Path() profileId: string, @Request() req: RequestWithUser) { let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER"); diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index a0b561e5..8294eb34 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -47,6 +47,19 @@ export class ProfileSalaryEmployeeController extends Controller { return new HttpSuccess(record); } + @Get("position/user") + public async getSalaryPositionUser(@Request() request: { user: Record }) { + const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub }); + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + const record = await this.salaryRepo.find({ + where: { profileEmployeeId: profile.id }, + order: { order: "ASC" }, + }); + return new HttpSuccess(record); + } + @Get("{profileId}") public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) { let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_EMP");