ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -24,6 +24,7 @@ import {
|
|||
UpdateProfileNopaid,
|
||||
} from "../entities/ProfileNopaid";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-temp/nopaid")
|
||||
@Tags("ProfileNopaid")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -80,7 +81,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileNopaid();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -96,9 +97,10 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
const history = new ProfileNopaidHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.nopaidRepository.save(data);
|
||||
await this.nopaidRepository.save(data, {data: req});
|
||||
setLogDataDiff( req, { before, after: data})
|
||||
history.profileNopaidId = data.id;
|
||||
await this.nopaidHistoryRepository.save(history);
|
||||
await this.nopaidHistoryRepository.save(history, {data: req});
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -113,7 +115,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileNopaidHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -131,8 +133,9 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record),
|
||||
this.nopaidHistoryRepository.save(history),
|
||||
this.nopaidRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.nopaidHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue