ผูก 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 { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
|
||||
import Extension from "../interfaces/extension";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-temp/family/mother")
|
||||
@Tags("ProfileEmployeeFamilyMother")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -162,6 +163,7 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const before = null;
|
||||
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
|
||||
familyMother.createdUserId = req.user.sub;
|
||||
familyMother.createdFullName = req.user.name;
|
||||
|
|
@ -173,10 +175,11 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
const history = new ProfileFamilyMotherHistory();
|
||||
Object.assign(history, { ...familyMother, id: undefined });
|
||||
|
||||
await this.ProfileFamilyMother.save(familyMother);
|
||||
await this.ProfileFamilyMother.save(familyMother, { data: req });
|
||||
setLogDataDiff(req, { before, after: familyMother });
|
||||
history.profileFamilyMotherId = familyMother.id;
|
||||
await this.ProfileFamilyMotherHistory.save(history);
|
||||
|
||||
await this.ProfileFamilyMotherHistory.save(history, { data: req });
|
||||
//setLogDataDiff(req, { before, after: history });
|
||||
return new HttpSuccess(familyMother.id);
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +194,8 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
profileEmployeeId: profileEmployeeId,
|
||||
});
|
||||
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const before = structuredClone(familyMother);
|
||||
// const before_null = null;
|
||||
const history = new ProfileFamilyMotherHistory();
|
||||
Object.assign(familyMother, body);
|
||||
Object.assign(history, { ...familyMother, id: undefined });
|
||||
|
|
@ -209,8 +213,10 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
|
|||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.ProfileFamilyMother.save(familyMother),
|
||||
this.ProfileFamilyMotherHistory.save(history),
|
||||
this.ProfileFamilyMother.save(familyMother, { data: req }),
|
||||
setLogDataDiff(req, { before, after: familyMother }),
|
||||
this.ProfileFamilyMotherHistory.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