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
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue