diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index 18ed3f3e..567dbed2 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -123,7 +123,6 @@ export class ProfileCertificateController extends Controller { } const data = new ProfileCertificate(); - const history = new ProfileCertificateHistory(); const meta = { createdUserId: req.user.sub, @@ -133,13 +132,8 @@ export class ProfileCertificateController extends Controller { }; Object.assign(data, { ...body, ...meta }); - Object.assign(history, { ...body, ...meta }); - const result = await this.certificateRepo.save(data); - - history.profileCertificateId = result.id; - - await this.certificateHistoryRepo.save(history); + await this.certificateRepo.save(data); return new HttpSuccess(); } @@ -156,8 +150,8 @@ export class ProfileCertificateController extends Controller { const history = new ProfileCertificateHistory(); + Object.assign(history, { ...record, id: undefined }); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); history.profileCertificateId = certificateId; record.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name; diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index 1cf305b2..8d71dece 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -117,7 +117,6 @@ export class ProfileHonorController extends Controller { } const data = new ProfileHonor(); - const history = new ProfileHonorHistory(); const meta = { createdUserId: req.user.sub, @@ -127,13 +126,8 @@ export class ProfileHonorController extends Controller { }; Object.assign(data, { ...body, ...meta }); - Object.assign(history, { ...body, ...meta }); - const result = await this.honorRepo.save(data); - - history.profileHonorId = result.id; - - await this.honorHistoryRepo.save(history); + await this.honorRepo.save(data); return new HttpSuccess(); } @@ -150,8 +144,8 @@ export class ProfileHonorController extends Controller { const history = new ProfileHonorHistory(); + Object.assign(history, { ...record, id: undefined }); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); history.profileHonorId = honorId; record.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name; diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index d05ef9f7..a999b495 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -144,7 +144,6 @@ export class ProfileInsigniaController extends Controller { } const data = new ProfileInsignia(); - const history = new ProfileInsigniaHistory(); const meta = { createdUserId: req.user.sub, @@ -154,13 +153,8 @@ export class ProfileInsigniaController extends Controller { }; Object.assign(data, { ...body, ...meta }); - Object.assign(history, { ...body, ...meta }); - const result = await this.insigniaRepo.save(data); - - history.profileInsigniaId = result.id; - - await this.insigniaHistoryRepo.save(history); + await this.insigniaRepo.save(data); return new HttpSuccess(); } @@ -177,8 +171,8 @@ export class ProfileInsigniaController extends Controller { const history = new ProfileInsigniaHistory(); + Object.assign(history, { ...record, id: undefined }); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); history.profileInsigniaId = insigniaId; record.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name; diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index 32a1a123..8b9a5f83 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -136,7 +136,6 @@ export class ProfileTrainingController extends Controller { } const data = new ProfileTraining(); - const history = new ProfileTrainingHistory(); const meta = { createdUserId: req.user.sub, @@ -148,11 +147,7 @@ export class ProfileTrainingController extends Controller { Object.assign(data, { ...body, ...meta }); Object.assign(history, { ...body, ...meta }); - const result = await this.trainingRepo.save(data); - - history.profileTrainingId = result.id; - - await this.trainingHistoryRepo.save(history); + await this.trainingRepo.save(data); return new HttpSuccess(); } @@ -169,8 +164,8 @@ export class ProfileTrainingController extends Controller { const history = new ProfileTrainingHistory(); + Object.assign(history, { ...record, id: undefined }); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); history.profileTrainingId = trainingId; record.lastUpdateFullName = req.user.name; history.lastUpdateFullName = req.user.name;