ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -20,6 +20,7 @@ import { ProfileHonorHistory } from "../entities/ProfileHonorHistory";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile/honor")
|
||||
@Tags("ProfileHonor")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -111,7 +112,7 @@ export class ProfileHonorController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileHonor();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -127,9 +128,10 @@ export class ProfileHonorController extends Controller {
|
|||
const history = new ProfileHonorHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.honorRepo.save(data);
|
||||
await this.honorRepo.save(data, {data: req});
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
history.profileHonorId = data.id;
|
||||
await this.honorHistoryRepo.save(history);
|
||||
await this.honorHistoryRepo.save(history, {data: req});
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -148,7 +150,7 @@ export class ProfileHonorController extends Controller {
|
|||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
const before = structuredClone(record);
|
||||
history.profileHonorId = honorId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
|
|
@ -160,7 +162,11 @@ export class ProfileHonorController extends Controller {
|
|||
history.createdAt = new Date();
|
||||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([this.honorRepo.save(record), this.honorHistoryRepo.save(history)]);
|
||||
await Promise.all([
|
||||
this.honorRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.honorHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue