แก้ api เก็บประวัติแก้ทะเบียน

This commit is contained in:
kittapath 2024-08-13 17:43:30 +07:00
parent 576f6bcc0d
commit fd3f1fa515
62 changed files with 855 additions and 1471 deletions

View file

@ -234,30 +234,18 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
familyCouple.createdFullName = req.user.name;
familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name;
await this.ProfileFamilyCouple.save(familyCouple);
if (familyCouple) {
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
const history: ProfileFamilyCoupleHistory = Object.assign(new ProfileFamilyCoupleHistory(), {
profileFamilyCoupleId: familyCouple.id,
couplePrefix: familyCouple.couplePrefix,
coupleFirstName: familyCouple.coupleFirstName,
coupleLastName: familyCouple.coupleLastName,
coupleLastNameOld: familyCouple.coupleLastNameOld,
coupleCareer: familyCouple.coupleCareer,
coupleCitizenId: familyCouple.coupleCitizenId,
coupleLive: familyCouple.coupleLive,
relationship: familyCouple.relationship,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await Promise.all([
this.profileRepo.save(profile),
this.ProfileFamilyCoupleHistory.save(history),
]);
}
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
const history = new ProfileFamilyCoupleHistory();
history.profileFamilyCoupleId = familyCouple.id;
await Promise.all([
this.profileRepo.save(profile),
this.ProfileFamilyCouple.save(familyCouple),
(history.profileFamilyCoupleId = familyCouple.id),
this.ProfileFamilyCoupleHistory.save(history),
]);
return new HttpSuccess(familyCouple.id);
}
@ -274,22 +262,17 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
if (!familyCouple) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyCoupleHistory();
Object.assign(history, { ...familyCouple, id: undefined });
Object.assign(familyCouple, body);
(familyCouple.lastUpdateUserId = req.user.sub),
(familyCouple.lastUpdateFullName = req.user.name);
Object.assign(history, { ...familyCouple, id: undefined });
familyCouple.coupleCitizenId = Extension.CheckCitizen(String(body.coupleCitizenId));
history.profileFamilyCoupleId = familyCouple.id;
(history.couplePrefix = familyCouple.couplePrefix),
(history.coupleFirstName = familyCouple.coupleFirstName),
(history.coupleLastName = familyCouple.coupleLastName),
(history.coupleLastNameOld = familyCouple.coupleLastNameOld),
(history.coupleCareer = familyCouple.coupleCareer),
(history.coupleCitizenId = familyCouple.coupleCitizenId),
(history.coupleLive = familyCouple.coupleLive),
(history.relationship = familyCouple.relationship),
(history.lastUpdateUserId = req.user.sub),
(history.lastUpdateFullName = req.user.name);
familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name;
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
await Promise.all([
this.ProfileFamilyCouple.save(familyCouple),