ผูก 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-temp/salary")
|
||||
@Tags("ProfileSalary")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -109,7 +110,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
|||
where: { profileEmployeeId: body.profileEmployeeId },
|
||||
order: { order: "DESC" },
|
||||
});
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileSalary();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -126,9 +127,10 @@ export class ProfileSalaryEmployeeTempController 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();
|
||||
}
|
||||
|
|
@ -143,7 +145,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
|||
const record = await this.salaryRepo.findOneBy({ id: salaryId });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileSalaryHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -160,7 +162,11 @@ export class ProfileSalaryEmployeeTempController 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