This commit is contained in:
AdisakKanthawilang 2025-07-17 13:18:14 +07:00
parent 0113b9bb59
commit 33b43416e9

View file

@ -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()