ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -24,6 +24,7 @@ import { ProfileCertificateHistory } from "../entities/ProfileCertificateHistory
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-employee/certificate")
|
||||
@Tags("ProfileEmployeeCertificate")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -56,7 +57,10 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
}
|
||||
|
||||
@Get("admin/history/{certificateId}")
|
||||
public async certificateAdminHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||
public async certificateAdminHistory(
|
||||
@Path() certificateId: string,
|
||||
@Request() req: RequestWithUser,
|
||||
) {
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
|
|
@ -73,7 +77,7 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
});
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
|
||||
@Get("history/{certificateId}")
|
||||
public async certificateHistory(@Path() certificateId: string) {
|
||||
const record = await this.certificateHistoryRepo.find({
|
||||
|
|
@ -100,6 +104,7 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileCertificate();
|
||||
|
||||
const meta = {
|
||||
|
|
@ -115,9 +120,11 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
const history = new ProfileCertificateHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.certificateRepo.save(data);
|
||||
await this.certificateRepo.save(data, { data: req });
|
||||
setLogDataDiff(req, { before, after: data });
|
||||
history.profileCertificateId = data.id;
|
||||
await this.certificateHistoryRepo.save(history);
|
||||
await this.certificateHistoryRepo.save(history, { data: req });
|
||||
//setLogDataDiff(req, { before, after: history });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -135,7 +142,8 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
"SYS_REGISTRY_EMP",
|
||||
record.profileEmployeeId,
|
||||
);
|
||||
|
||||
const before = structuredClone(record);
|
||||
// const before_null = null;
|
||||
const history = new ProfileCertificateHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -153,8 +161,10 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.certificateRepo.save(record),
|
||||
this.certificateHistoryRepo.save(history),
|
||||
this.certificateRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.certificateHistoryRepo.save(history, { data: req }),
|
||||
// setLogDataDiff(req, { before: before_null, after: history }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue