ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -25,6 +25,7 @@ import {
|
|||
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
|
||||
import Extension from "../interfaces/extension";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-temp/family/father")
|
||||
@Tags("ProfileEmployeeFamilyFather")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -162,6 +163,7 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const before = null;
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
familyFather.createdUserId = req.user.sub;
|
||||
familyFather.createdFullName = req.user.name;
|
||||
|
|
@ -173,9 +175,11 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
const history = new ProfileFamilyFatherHistory();
|
||||
Object.assign(history, { ...familyFather, id: undefined });
|
||||
|
||||
await this.ProfileFamilyFather.save(familyFather);
|
||||
await this.ProfileFamilyFather.save(familyFather, { data: req });
|
||||
setLogDataDiff(req, { before, after: familyFather });
|
||||
history.profileFamilyFatherId = familyFather.id;
|
||||
await this.ProfileFamilyFatherHistory.save(history);
|
||||
await this.ProfileFamilyFatherHistory.save(history, { data: req });
|
||||
//setLogDataDiff(req, { before, after: history });
|
||||
|
||||
return new HttpSuccess(familyFather.id);
|
||||
}
|
||||
|
|
@ -195,7 +199,8 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
const history = new ProfileFamilyFatherHistory();
|
||||
Object.assign(familyFather, body);
|
||||
Object.assign(history, { ...familyFather, id: undefined });
|
||||
|
||||
const before = structuredClone(familyFather);
|
||||
// const before_null = null;
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
history.profileFamilyFatherId = familyFather.id;
|
||||
familyFather.lastUpdateUserId = req.user.sub;
|
||||
|
|
@ -209,8 +214,10 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller {
|
|||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyFather.save(familyFather),
|
||||
this.ProfileFamilyFatherHistory.save(history),
|
||||
this.ProfileFamilyFather.save(familyFather, { data: req }),
|
||||
setLogDataDiff(req, { before, after: familyFather }),
|
||||
this.ProfileFamilyFatherHistory.save(history, { data: req }),
|
||||
// setLogDataDiff(req, { before: before_null, after: history }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue