This commit is contained in:
parent
0113b9bb59
commit
33b43416e9
1 changed files with 25 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue