ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -25,6 +25,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { LessThan, MoreThan } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-employee/salary")
|
||||
@Tags("ProfileSalary")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -115,7 +116,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
where: { profileEmployeeId: body.profileEmployeeId },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileSalary();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -132,9 +133,10 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
const history = new ProfileSalaryHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.salaryRepo.save(data);
|
||||
await this.salaryRepo.save(data, { data: req });
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
history.profileSalaryId = data.id;
|
||||
await this.salaryHistoryRepo.save(history);
|
||||
await this.salaryHistoryRepo.save(history, { data: req });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -152,7 +154,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
"SYS_REGISTRY_EMP",
|
||||
record.profileEmployeeId,
|
||||
);
|
||||
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileSalaryHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -169,7 +171,11 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]);
|
||||
await Promise.all([
|
||||
this.salaryRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.salaryHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue