From 33b43416e9979e2ae4e6d931e606fcec2a3e483a Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 17 Jul 2025 13:18:14 +0700 Subject: [PATCH] #1633 --- .../ProfileActpositionController.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/controllers/ProfileActpositionController.ts b/src/controllers/ProfileActpositionController.ts index 0033af36..8e1aa9ff 100644 --- a/src/controllers/ProfileActpositionController.ts +++ b/src/controllers/ProfileActpositionController.ts @@ -93,6 +93,7 @@ export class ProfileActpositionController extends Controller { @Get("history/{actpositionId}") public async getProfileActpositionHistory(@Path() actpositionId: string) { const record = await this.profileActpositionHistoryRepo.find({ + relations: ["histories"], where: { profileActpositionId: actpositionId }, order: { createdAt: "DESC" }, }); @@ -100,7 +101,30 @@ export class ProfileActpositionController extends Controller { if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } - return new HttpSuccess(record); + + const mappedRecords = record.map(history => { + const firstHistory = history.histories ?? []; + + return { + id: history.id, + createdAt: history.createdAt, + createdUserId: history.createdUserId, + lastUpdatedAt: history.lastUpdatedAt, + lastUpdateUserId: history.lastUpdateUserId, + createdFullName: history.createdFullName, + lastUpdateFullName: history.lastUpdateFullName, + dateStart: history.dateStart, + dateEnd: history.dateEnd, + posNo: history.posNo, + position: history.position, + status: history.status, + profileActpositionId: history.profileActpositionId, + refCommandNo: firstHistory?.refCommandNo ?? null, + }; + }); + + + return new HttpSuccess(mappedRecords); } @Post()