ผูก log เมนูทะเบียนประวัติ

This commit is contained in:
AdisakKanthawilang 2024-10-03 15:57:44 +07:00
parent 5643cc67c4
commit 6539804937
76 changed files with 909 additions and 431 deletions

View file

@ -8,6 +8,7 @@ import { ProfileAddressHistory } from "../entities/Profile";
import { AppDataSource } from "../database/data-source";
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
@Route("api/v1/org/profile-temp/address")
@Tags("ProfileAddressEmployee")
@Security("bearerAuth")
@ -173,7 +174,8 @@ export class ProfileAddressEmployeeTempController extends Controller {
await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP");
const record = await this.profileEmployeeRepo.findOneBy({ id: profileId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const before = structuredClone(record);
// const before_null = null;
const history = new ProfileAddressHistory();
Object.assign(record, body);
@ -191,8 +193,10 @@ export class ProfileAddressEmployeeTempController extends Controller {
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileEmployeeRepo.save(record),
this.profileAddressHistoryRepo.save(history),
this.profileEmployeeRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAddressHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
return new HttpSuccess();