From a2292d6048cea3b7825677f86a0cb3b124ca6ffb Mon Sep 17 00:00:00 2001 From: kittapath Date: Sun, 1 Sep 2024 22:44:23 +0700 Subject: [PATCH] add update time --- src/controllers/ProfileAbilityController.ts | 2 +- .../ProfileAbilityEmployeeController.ts | 2 +- .../ProfileAbilityEmployeeTempController.ts | 2 +- src/controllers/ProfileAddressController.ts | 64 +++++++++++++++---- .../ProfileAddressEmployeeController.ts | 64 +++++++++++++++---- .../ProfileAddressEmployeeTempController.ts | 64 +++++++++++++++---- .../ProfileAssessmentsController.ts | 2 +- .../ProfileAssessmentsEmployeeController.ts | 2 +- ...rofileAssessmentsEmployeeTempController.ts | 2 +- .../ProfileCertificateController.ts | 2 +- .../ProfileCertificateEmployeeController.ts | 2 +- ...rofileCertificateEmployeeTempController.ts | 2 +- .../ProfileChangeNameController.ts | 2 +- .../ProfileChangeNameEmployeeController.ts | 2 +- ...ProfileChangeNameEmployeeTempController.ts | 2 +- src/controllers/ProfileChildrenController.ts | 2 +- .../ProfileChildrenEmployeeController.ts | 2 +- .../ProfileChildrenEmployeeTempController.ts | 2 +- src/controllers/ProfileController.ts | 13 ++-- .../ProfileDevelopmentController.ts | 2 +- .../ProfileDevelopmentEmployeeController.ts | 2 +- ...rofileDevelopmentEmployeeTempController.ts | 2 +- .../ProfileDisciplineController.ts | 2 +- .../ProfileDisciplineEmployeeController.ts | 2 +- ...ProfileDisciplineEmployeeTempController.ts | 2 +- src/controllers/ProfileDutyController.ts | 2 +- .../ProfileDutyEmployeeController.ts | 2 +- .../ProfileDutyEmployeeTempController.ts | 2 +- .../ProfileEducationsController.ts | 2 +- .../ProfileEducationsEmployeeController.ts | 2 +- ...ProfileEducationsEmployeeTempController.ts | 2 +- src/controllers/ProfileEmployeeController.ts | 46 +++++++++++++ .../ProfileEmployeeTempController.ts | 2 +- .../ProfileGovernmentController.ts | 2 +- .../ProfileGovernmentEmployeeController.ts | 2 +- ...ProfileGovernmentEmployeeTempController.ts | 2 +- src/controllers/ProfileHonorController.ts | 2 +- .../ProfileHonorEmployeeController.ts | 2 +- .../ProfileHonorEmployeeTempController.ts | 2 +- src/controllers/ProfileInsigniaController.ts | 2 +- .../ProfileInsigniaEmployeeController.ts | 2 +- .../ProfileInsigniaEmployeeTempController.ts | 2 +- src/controllers/ProfileLeaveController.ts | 2 +- .../ProfileLeaveEmployeeController.ts | 2 +- .../ProfileLeaveEmployeeTempController.ts | 2 +- src/controllers/ProfileNopaidController.ts | 2 +- .../ProfileNopaidEmployeeController.ts | 2 +- .../ProfileNopaidEmployeeTempController.ts | 2 +- src/controllers/ProfileOtherController.ts | 2 +- .../ProfileOtherEmployeeController.ts | 2 +- .../ProfileOtherEmployeeTempController.ts | 2 +- src/controllers/ProfileSalaryController.ts | 2 +- .../ProfileSalaryEmployeeController.ts | 2 +- .../ProfileSalaryEmployeeTempController.ts | 2 +- src/controllers/ProfileTrainingController.ts | 2 +- .../ProfileTrainingEmployeeController.ts | 2 +- .../ProfileTrainingEmployeeTempController.ts | 2 +- 57 files changed, 257 insertions(+), 98 deletions(-) diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index c8351ef5..d92c96aa 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -132,7 +132,7 @@ export class ProfileAbilityController extends Controller { const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAbilityId = abilityId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAbilityEmployeeController.ts b/src/controllers/ProfileAbilityEmployeeController.ts index dba3c1be..8963c260 100644 --- a/src/controllers/ProfileAbilityEmployeeController.ts +++ b/src/controllers/ProfileAbilityEmployeeController.ts @@ -140,7 +140,7 @@ export class ProfileAbilityEmployeeController extends Controller { const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAbilityId = abilityId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAbilityEmployeeTempController.ts b/src/controllers/ProfileAbilityEmployeeTempController.ts index 93fdb67b..949eaf90 100644 --- a/src/controllers/ProfileAbilityEmployeeTempController.ts +++ b/src/controllers/ProfileAbilityEmployeeTempController.ts @@ -132,7 +132,7 @@ export class ProfileAbilityEmployeeTempController extends Controller { const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAbilityId = abilityId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index c70253a2..44f1c447 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -34,7 +34,6 @@ export class ProfileAddressController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], order: { createdAt: "ASC" }, }); @@ -66,7 +65,6 @@ export class ProfileAddressController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], }); if (!getProfileAddress) { @@ -88,12 +86,32 @@ export class ProfileAddressController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileId: profile.id }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -109,12 +127,32 @@ export class ProfileAddressController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileId: profileId }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -135,7 +173,7 @@ export class ProfileAddressController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAddressEmployeeController.ts b/src/controllers/ProfileAddressEmployeeController.ts index bb37895c..3e6bce14 100644 --- a/src/controllers/ProfileAddressEmployeeController.ts +++ b/src/controllers/ProfileAddressEmployeeController.ts @@ -35,7 +35,6 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], order: { createdAt: "ASC" }, }); @@ -70,7 +69,6 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], }); if (!getProfileAddress) { @@ -92,12 +90,32 @@ export class ProfileAddressEmployeeController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profile.id }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -113,12 +131,32 @@ export class ProfileAddressEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -139,7 +177,7 @@ export class ProfileAddressEmployeeController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAddressEmployeeTempController.ts b/src/controllers/ProfileAddressEmployeeTempController.ts index 18dab2db..1aaca55f 100644 --- a/src/controllers/ProfileAddressEmployeeTempController.ts +++ b/src/controllers/ProfileAddressEmployeeTempController.ts @@ -35,7 +35,6 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], order: { createdAt: "ASC" }, }); @@ -70,7 +69,6 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], }); if (!getProfileAddress) { @@ -92,12 +90,32 @@ export class ProfileAddressEmployeeTempController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profile.id }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -113,12 +131,32 @@ export class ProfileAddressEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -139,7 +177,7 @@ export class ProfileAddressEmployeeTempController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index ba3d6ed3..681de617 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -136,7 +136,7 @@ export class ProfileAssessmentsController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAssessmentId = assessmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAssessmentsEmployeeController.ts b/src/controllers/ProfileAssessmentsEmployeeController.ts index 301e7ae7..dd7b7b41 100644 --- a/src/controllers/ProfileAssessmentsEmployeeController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeController.ts @@ -141,7 +141,7 @@ export class ProfileAssessmentsEmployeeController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAssessmentId = assessmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAssessmentsEmployeeTempController.ts b/src/controllers/ProfileAssessmentsEmployeeTempController.ts index 08e843a4..ae7a834f 100644 --- a/src/controllers/ProfileAssessmentsEmployeeTempController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeTempController.ts @@ -135,7 +135,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAssessmentId = assessmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index 4d73c67a..18a8aba0 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -121,7 +121,7 @@ export class ProfileCertificateController extends Controller { const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileCertificateId = certificateId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileCertificateEmployeeController.ts b/src/controllers/ProfileCertificateEmployeeController.ts index e5f3bd03..3c4a2aeb 100644 --- a/src/controllers/ProfileCertificateEmployeeController.ts +++ b/src/controllers/ProfileCertificateEmployeeController.ts @@ -128,7 +128,7 @@ export class ProfileCertificateEmployeeController extends Controller { const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileCertificateId = certificateId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileCertificateEmployeeTempController.ts b/src/controllers/ProfileCertificateEmployeeTempController.ts index 010948f9..ae494b85 100644 --- a/src/controllers/ProfileCertificateEmployeeTempController.ts +++ b/src/controllers/ProfileCertificateEmployeeTempController.ts @@ -119,7 +119,7 @@ export class ProfileCertificateEmployeeTempController extends Controller { const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileCertificateId = certificateId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index bf2aa75a..85100d84 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -131,7 +131,7 @@ export class ProfileChangeNameController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileChangeNameId = changeNameId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index 25c1357c..8accbad2 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -139,7 +139,7 @@ export class ProfileChangeNameEmployeeController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileChangeNameId = changeNameId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index 1ea57a8e..69e27fd7 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -130,7 +130,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileChangeNameId = changeNameId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChildrenController.ts b/src/controllers/ProfileChildrenController.ts index 61cd3cab..b9b010bd 100644 --- a/src/controllers/ProfileChildrenController.ts +++ b/src/controllers/ProfileChildrenController.ts @@ -112,7 +112,7 @@ export class ProfileChildrenController extends Controller { const history = new ProfileChildrenHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); history.profileChildrenId = record.id; diff --git a/src/controllers/ProfileChildrenEmployeeController.ts b/src/controllers/ProfileChildrenEmployeeController.ts index f0b8acde..5c2510fc 100644 --- a/src/controllers/ProfileChildrenEmployeeController.ts +++ b/src/controllers/ProfileChildrenEmployeeController.ts @@ -124,7 +124,7 @@ export class ProfileChildrenEmployeeController extends Controller { const history = new ProfileChildrenHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); history.profileChildrenId = record.id; diff --git a/src/controllers/ProfileChildrenEmployeeTempController.ts b/src/controllers/ProfileChildrenEmployeeTempController.ts index e0e63daa..9a6ce934 100644 --- a/src/controllers/ProfileChildrenEmployeeTempController.ts +++ b/src/controllers/ProfileChildrenEmployeeTempController.ts @@ -113,7 +113,7 @@ export class ProfileChildrenEmployeeTempController extends Controller { const history = new ProfileChildrenHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); history.profileChildrenId = record.id; diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index a2126488..08142f0d 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2388,6 +2388,12 @@ export class ProfileController extends Controller { if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); + Object.assign(record, body); + record.lastUpdateUserId = request.user.sub; + record.lastUpdateFullName = request.user.name; + record.lastUpdatedAt = new Date(); + record.dateRetire = calculateRetireDate(record.birthDate); + record.dateRetireLaw = calculateRetireLaw(record.birthDate); await this.profileHistoryRepo.save( Object.assign(new ProfileHistory(), { ...record, @@ -2395,13 +2401,6 @@ export class ProfileController extends Controller { id: undefined, }), ); - - Object.assign(record, body); - record.lastUpdateUserId = request.user.sub; - record.lastUpdateFullName = request.user.name; - record.lastUpdatedAt = new Date(); - record.dateRetire = calculateRetireDate(record.birthDate); - record.dateRetireLaw = calculateRetireLaw(record.birthDate); await this.profileRepo.save(record); if (record != null && record.keycloak != null) { diff --git a/src/controllers/ProfileDevelopmentController.ts b/src/controllers/ProfileDevelopmentController.ts index 11deb174..46d16d6d 100644 --- a/src/controllers/ProfileDevelopmentController.ts +++ b/src/controllers/ProfileDevelopmentController.ts @@ -120,7 +120,7 @@ export class ProfileDevelopmentController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDevelopmentId = developmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDevelopmentEmployeeController.ts b/src/controllers/ProfileDevelopmentEmployeeController.ts index 4089b8a4..b93a5608 100644 --- a/src/controllers/ProfileDevelopmentEmployeeController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeController.ts @@ -128,7 +128,7 @@ export class ProfileDevelopmentEmployeeController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDevelopmentId = developmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDevelopmentEmployeeTempController.ts b/src/controllers/ProfileDevelopmentEmployeeTempController.ts index 425232a4..b92c1149 100644 --- a/src/controllers/ProfileDevelopmentEmployeeTempController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeTempController.ts @@ -119,7 +119,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDevelopmentId = developmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index d9acf0e4..510b8a69 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -129,7 +129,7 @@ export class ProfileDisciplineController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDisciplineId = disciplineId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDisciplineEmployeeController.ts b/src/controllers/ProfileDisciplineEmployeeController.ts index 3beb847b..9463641e 100644 --- a/src/controllers/ProfileDisciplineEmployeeController.ts +++ b/src/controllers/ProfileDisciplineEmployeeController.ts @@ -136,7 +136,7 @@ export class ProfileDisciplineEmployeeController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDisciplineId = disciplineId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDisciplineEmployeeTempController.ts b/src/controllers/ProfileDisciplineEmployeeTempController.ts index c459ed03..18213655 100644 --- a/src/controllers/ProfileDisciplineEmployeeTempController.ts +++ b/src/controllers/ProfileDisciplineEmployeeTempController.ts @@ -127,7 +127,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDisciplineId = disciplineId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDutyController.ts b/src/controllers/ProfileDutyController.ts index f97c7e5d..6c909495 100644 --- a/src/controllers/ProfileDutyController.ts +++ b/src/controllers/ProfileDutyController.ts @@ -111,7 +111,7 @@ export class ProfileDutyController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDutyId = dutyId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDutyEmployeeController.ts b/src/controllers/ProfileDutyEmployeeController.ts index 72f2a65e..f34b6631 100644 --- a/src/controllers/ProfileDutyEmployeeController.ts +++ b/src/controllers/ProfileDutyEmployeeController.ts @@ -119,7 +119,7 @@ export class ProfileDutyEmployeeController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDutyId = dutyId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDutyEmployeeTempController.ts b/src/controllers/ProfileDutyEmployeeTempController.ts index 3c65f345..f39bd693 100644 --- a/src/controllers/ProfileDutyEmployeeTempController.ts +++ b/src/controllers/ProfileDutyEmployeeTempController.ts @@ -110,7 +110,7 @@ export class ProfileDutyEmployeeTempController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDutyId = dutyId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index 0e8bc208..d7131240 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -133,7 +133,7 @@ export class ProfileEducationsController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEducationId = educationId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEducationsEmployeeController.ts b/src/controllers/ProfileEducationsEmployeeController.ts index 06789f3c..179be788 100644 --- a/src/controllers/ProfileEducationsEmployeeController.ts +++ b/src/controllers/ProfileEducationsEmployeeController.ts @@ -143,7 +143,7 @@ export class ProfileEducationsEmployeeController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEducationId = educationId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEducationsEmployeeTempController.ts b/src/controllers/ProfileEducationsEmployeeTempController.ts index a24c6dda..103e6e92 100644 --- a/src/controllers/ProfileEducationsEmployeeTempController.ts +++ b/src/controllers/ProfileEducationsEmployeeTempController.ts @@ -131,7 +131,7 @@ export class ProfileEducationsEmployeeTempController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEducationId = educationId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 059e9206..9069ccc9 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1234,6 +1234,12 @@ export class ProfileEmployeeController extends Controller { .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + if (!findRevision) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision"); + } const data = await Promise.all( record.map((_data) => { const shortName = @@ -1256,6 +1262,45 @@ export class ProfileEmployeeController extends Controller { : _data.profileEmployeeEmployment.reduce((latest, current) => { return latest.date > current.date ? latest : current; }).date; + const root = + _data.current_holders.length == 0 || + (_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null) + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; + + const child1 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1; + + const child2 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2; + + const child3 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3; + + const child4 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; + + let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`; + let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`; + let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`; + let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`; return { id: _data.id, prefix: _data.prefix, @@ -1335,6 +1380,7 @@ export class ProfileEmployeeController extends Controller { child4: _data.child4Temp ? _data.child4Temp : null, child4Id: _data.child4IdTemp ? _data.child4IdTemp : null, child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null, + org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, }; }), ); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 3488ebb6..6dcfc92f 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -3144,8 +3144,8 @@ export class ProfileEmployeeTempController extends Controller { if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const history = new ProfileEmployeeEmploymentHistory(); - Object.assign(history, { ...employment, id: undefined }); Object.assign(employment, body); + Object.assign(history, { ...employment, id: undefined }); employment.lastUpdateUserId = request.user.sub; employment.lastUpdateFullName = request.user.name; diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 6ca9bec5..2a4645a5 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -389,7 +389,7 @@ export class ProfileGovernmentHistoryController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index 5b6256ba..7aac86c9 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -371,7 +371,7 @@ export class ProfileGovernmentEmployeeController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileEmployeeId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileGovernmentEmployeeTempController.ts b/src/controllers/ProfileGovernmentEmployeeTempController.ts index ee9b7c27..57c223a0 100644 --- a/src/controllers/ProfileGovernmentEmployeeTempController.ts +++ b/src/controllers/ProfileGovernmentEmployeeTempController.ts @@ -372,7 +372,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileEmployeeId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index 17711b4e..ac93bc40 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -136,7 +136,7 @@ export class ProfileHonorController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileHonorId = honorId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileHonorEmployeeController.ts b/src/controllers/ProfileHonorEmployeeController.ts index e038665f..f992d526 100644 --- a/src/controllers/ProfileHonorEmployeeController.ts +++ b/src/controllers/ProfileHonorEmployeeController.ts @@ -148,7 +148,7 @@ export class ProfileHonorEmployeeController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileHonorId = honorId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileHonorEmployeeTempController.ts b/src/controllers/ProfileHonorEmployeeTempController.ts index c59c662a..075e31ee 100644 --- a/src/controllers/ProfileHonorEmployeeTempController.ts +++ b/src/controllers/ProfileHonorEmployeeTempController.ts @@ -138,7 +138,7 @@ export class ProfileHonorEmployeeTempController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileHonorId = honorId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index 048e0230..8d2d34a0 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -148,7 +148,7 @@ export class ProfileInsigniaController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileInsigniaId = insigniaId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileInsigniaEmployeeController.ts b/src/controllers/ProfileInsigniaEmployeeController.ts index e00202a9..b2d4a613 100644 --- a/src/controllers/ProfileInsigniaEmployeeController.ts +++ b/src/controllers/ProfileInsigniaEmployeeController.ts @@ -159,7 +159,7 @@ export class ProfileInsigniaEmployeeController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileInsigniaId = insigniaId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileInsigniaEmployeeTempController.ts b/src/controllers/ProfileInsigniaEmployeeTempController.ts index 298bdf5b..fc22ca48 100644 --- a/src/controllers/ProfileInsigniaEmployeeTempController.ts +++ b/src/controllers/ProfileInsigniaEmployeeTempController.ts @@ -150,7 +150,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileInsigniaId = insigniaId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index d7ff9617..843cc39b 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -221,7 +221,7 @@ export class ProfileLeaveController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileLeaveId = leaveId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index e25395c5..f4858bb2 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -153,7 +153,7 @@ export class ProfileLeaveEmployeeController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileLeaveId = leaveId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index 2ea9c4d4..831480a8 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -143,7 +143,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileLeaveId = leaveId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index 27167e49..e934bda9 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -111,7 +111,7 @@ export class ProfileNopaidController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileNopaidId = nopaidId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileNopaidEmployeeController.ts b/src/controllers/ProfileNopaidEmployeeController.ts index 08dd320e..a337ca7a 100644 --- a/src/controllers/ProfileNopaidEmployeeController.ts +++ b/src/controllers/ProfileNopaidEmployeeController.ts @@ -119,7 +119,7 @@ export class ProfileNopaidEmployeeController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileNopaidId = nopaidId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileNopaidEmployeeTempController.ts b/src/controllers/ProfileNopaidEmployeeTempController.ts index 6e7d4396..aad9f443 100644 --- a/src/controllers/ProfileNopaidEmployeeTempController.ts +++ b/src/controllers/ProfileNopaidEmployeeTempController.ts @@ -117,7 +117,7 @@ export class ProfileNopaidEmployeeTempController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileNopaidId = nopaidId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index 95ddd931..14e3e3a4 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -112,7 +112,7 @@ export class ProfileOtherController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileOtherId = otherId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileOtherEmployeeController.ts b/src/controllers/ProfileOtherEmployeeController.ts index 12c5d446..4b4c7033 100644 --- a/src/controllers/ProfileOtherEmployeeController.ts +++ b/src/controllers/ProfileOtherEmployeeController.ts @@ -123,7 +123,7 @@ export class ProfileOtherEmployeeController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileOtherId = otherId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileOtherEmployeeTempController.ts b/src/controllers/ProfileOtherEmployeeTempController.ts index d8aa8e12..647e01cf 100644 --- a/src/controllers/ProfileOtherEmployeeTempController.ts +++ b/src/controllers/ProfileOtherEmployeeTempController.ts @@ -115,7 +115,7 @@ export class ProfileOtherEmployeeTempController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileOtherId = otherId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 6e82bb70..94c2e633 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -131,7 +131,7 @@ export class ProfileSalaryController extends Controller { const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileSalaryId = salaryId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index e143324a..6c39900d 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -145,7 +145,7 @@ export class ProfileSalaryEmployeeController extends Controller { const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileSalaryId = salaryId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index 1461d588..b23c4bf9 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -136,7 +136,7 @@ export class ProfileSalaryEmployeeTempController extends Controller { const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileSalaryId = salaryId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index ae64e294..414c2e56 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -117,7 +117,7 @@ export class ProfileTrainingController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileTrainingId = trainingId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileTrainingEmployeeController.ts b/src/controllers/ProfileTrainingEmployeeController.ts index da4ba019..0f576ffb 100644 --- a/src/controllers/ProfileTrainingEmployeeController.ts +++ b/src/controllers/ProfileTrainingEmployeeController.ts @@ -130,7 +130,7 @@ export class ProfileTrainingEmployeeController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileTrainingId = trainingId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileTrainingEmployeeTempController.ts b/src/controllers/ProfileTrainingEmployeeTempController.ts index b1836ab4..942abac4 100644 --- a/src/controllers/ProfileTrainingEmployeeTempController.ts +++ b/src/controllers/ProfileTrainingEmployeeTempController.ts @@ -120,7 +120,7 @@ export class ProfileTrainingEmployeeTempController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileTrainingId = trainingId; record.lastUpdateUserId = req.user.sub;