ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -24,6 +24,7 @@ import { ProfileHonorHistory } from "../entities/ProfileHonorHistory";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-employee/honor")
|
||||
@Tags("ProfileEmployeeHonor")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -119,7 +120,7 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileHonor();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -135,9 +136,10 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
const history = new ProfileHonorHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.honorRepo.save(data);
|
||||
await this.honorRepo.save(data, { data: req });
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
history.profileHonorId = data.id;
|
||||
await this.honorHistoryRepo.save(history);
|
||||
await this.honorHistoryRepo.save(history, { data: req });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -155,7 +157,7 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
"SYS_REGISTRY_EMP",
|
||||
record.profileEmployeeId,
|
||||
);
|
||||
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileHonorHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -172,7 +174,11 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||
await Promise.all([
|
||||
this.honorRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.honorHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue