แก้ api เก็บประวัติแก้ทะเบียน

This commit is contained in:
kittapath 2024-08-13 17:43:30 +07:00
parent 576f6bcc0d
commit fd3f1fa515
62 changed files with 855 additions and 1471 deletions

View file

@ -95,8 +95,14 @@ export class ProfileLeaveEmployeeController extends Controller {
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileLeaveHistory();
history.profileLeaveId = data.id;
await this.leaveRepo.save(data);
await Promise.all([
this.leaveRepo.save(data),
(history.profileLeaveId = data.id),
this.leaveHistoryRepo.save(history),
]);
return new HttpSuccess();
}
@ -121,11 +127,16 @@ export class ProfileLeaveEmployeeController extends Controller {
const history = new ProfileLeaveHistory();
Object.assign(history, { ...record, id: undefined });
Object.assign(record, body);
Object.assign(history, body);
history.profileLeaveId = leaveId;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
await Promise.all([this.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]);