ผูก log เมนูทะเบียนประวัติ
This commit is contained in:
parent
5643cc67c4
commit
6539804937
76 changed files with 909 additions and 431 deletions
|
|
@ -24,6 +24,7 @@ import { ProfileAssessmentHistory } from "../entities/ProfileAssessmentHistory";
|
|||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-employee/assessments")
|
||||
@Tags("ProfileEmployeeAssessments")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -120,7 +121,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id);
|
||||
|
||||
const before = null;
|
||||
const data = new ProfileAssessment();
|
||||
const meta = {
|
||||
createdUserId: req.user.sub,
|
||||
|
|
@ -134,9 +135,11 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
const history = new ProfileAssessmentHistory();
|
||||
Object.assign(history, { ...data, id: undefined });
|
||||
|
||||
await this.profileAssessmentsRepository.save(data);
|
||||
await this.profileAssessmentsRepository.save(data, { data: req });
|
||||
setLogDataDiff( req, { before, after: data });
|
||||
history.profileAssessmentId = data.id;
|
||||
await this.profileAssessmentsHistoryRepository.save(history);
|
||||
await this.profileAssessmentsHistoryRepository.save(history, { data: req });
|
||||
setLogDataDiff( req, { before, after: history });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -155,6 +158,8 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
record.profileEmployeeId,
|
||||
);
|
||||
|
||||
const before = structuredClone(record);
|
||||
// const before_null = null;
|
||||
const history = new ProfileAssessmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
|
|
@ -172,8 +177,10 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
history.lastUpdatedAt = new Date();
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssessmentsRepository.save(record),
|
||||
this.profileAssessmentsHistoryRepository.save(history),
|
||||
this.profileAssessmentsRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAssessmentsHistoryRepository.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