refactor: history in database after first edit only
This commit is contained in:
parent
fd9218964e
commit
57719af5f3
4 changed files with 8 additions and 31 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue