From db692475573e309fef2c0898bb010326a0114b5c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 3 Jul 2024 17:51:44 +0700 Subject: [PATCH] fix --- src/controllers/SalaryController.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/controllers/SalaryController.ts b/src/controllers/SalaryController.ts index 5f168d0..fd54e73 100644 --- a/src/controllers/SalaryController.ts +++ b/src/controllers/SalaryController.ts @@ -247,6 +247,7 @@ export class SalaryController extends Controller { }) async GetSalaryById(@Path() id: string) { const salary = await this.salaryRepository.findOne({ + relations: ["posType_", "posLevel_"], where: { id: id }, select: [ "name", @@ -260,10 +261,24 @@ export class SalaryController extends Controller { "details", ], }); + + const formattedData = { + name: salary?.name, + isSpecial: salary?.isSpecial, + posTypeId: salary?.posTypeId, + posTypeName: salary?.posType_.posTypeName, + posLevelId: salary?.posLevelId, + posLevelName: salary?.posLevel_.posLevelName, + isActive: salary?.isActive, + date: salary?.date, + startDate: salary?.startDate, + endDate: salary?.endDate, + details: salary?.details, + }; if (!salary) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผังเงินเดือนนี้"); } - return new HttpSuccess(salary); + return new HttpSuccess(formattedData); } /**