ผูก 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/family/father")
|
||||
@Tags("ProfileFamilyFather")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -158,6 +159,7 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const before = null;
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
|
||||
familyFather.createdUserId = req.user.sub;
|
||||
|
|
@ -170,10 +172,11 @@ export class ProfileFamilyFatherController 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);
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +189,8 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId });
|
||||
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const before = structuredClone(familyFather);
|
||||
// const before_null = null;
|
||||
const history = new ProfileFamilyFatherHistory();
|
||||
Object.assign(familyFather, body);
|
||||
Object.assign(history, { ...familyFather, id: undefined });
|
||||
|
|
@ -204,8 +208,10 @@ export class ProfileFamilyFatherController 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