แก้ 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

@ -220,24 +220,16 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
familyMother.createdFullName = req.user.name;
familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name;
await this.ProfileFamilyMother.save(familyMother);
if (familyMother) {
const history: ProfileFamilyMotherHistory = Object.assign(new ProfileFamilyMotherHistory(), {
profileFamilyMotherId: familyMother.id,
motherPrefix: familyMother.motherPrefix,
motherFirstName: familyMother.motherFirstName,
motherLastName: familyMother.motherLastName,
motherCareer: familyMother.motherCareer,
motherCitizenId: familyMother.motherCitizenId,
motherLive: familyMother.motherLive,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
});
await this.ProfileFamilyMotherHistory.save(history);
}
const history = new ProfileFamilyMotherHistory();
history.profileFamilyMotherId = familyMother.id;
await Promise.all([
this.ProfileFamilyMother.save(familyMother),
(history.profileFamilyMotherId = familyMother.id),
this.ProfileFamilyMotherHistory.save(history),
]);
return new HttpSuccess(familyMother.id);
}
@ -254,20 +246,17 @@ export class ProfileFamilyMotherEmployeeTempController extends Controller {
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
const history = new ProfileFamilyMotherHistory();
Object.assign(history, { ...familyMother, id: undefined });
Object.assign(familyMother, body);
(familyMother.lastUpdateUserId = req.user.sub),
(familyMother.lastUpdateFullName = req.user.name);
Object.assign(history, { ...familyMother, id: undefined });
familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId));
history.profileFamilyMotherId = familyMother.id;
(history.motherPrefix = familyMother.motherPrefix),
(history.motherFirstName = familyMother.motherFirstName),
(history.motherLastName = familyMother.motherLastName),
(history.motherCareer = familyMother.motherCareer),
(history.motherCitizenId = familyMother.motherCitizenId),
(history.motherLive = familyMother.motherLive),
(history.lastUpdateUserId = req.user.sub),
(history.lastUpdateFullName = req.user.name);
familyMother.lastUpdateUserId = req.user.sub;
familyMother.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.ProfileFamilyMother.save(familyMother),