From 5c2569e5b425adb42b713da2987b8c8b494a5b62 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 3 Sep 2024 14:48:19 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=A7=E0=B8=B1=E0=B8=99=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2?= =?UTF-8?q?=20=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82/=E0=B8=AA?= =?UTF-8?q?=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PosLevelController.ts | 3 + src/controllers/PosTypeController.ts | 3 + src/controllers/ReportController.ts | 15 ++ src/controllers/SalaryController.ts | 14 ++ src/controllers/SalaryEmployeeController.ts | 15 ++ .../SalaryFormulaEmployeeController.ts | 3 + src/controllers/SalaryPeriodController.ts | 154 ++++++++++++++++++ .../SalaryPeriodEmployeeController.ts | 71 ++++++++ src/controllers/SalaryRankController.ts | 3 + .../SalaryRankEmployeeController.ts | 3 + 10 files changed, 284 insertions(+) diff --git a/src/controllers/PosLevelController.ts b/src/controllers/PosLevelController.ts index dfd576d..0ed8dfe 100644 --- a/src/controllers/PosLevelController.ts +++ b/src/controllers/PosLevelController.ts @@ -96,6 +96,8 @@ export class PosLevelController extends Controller { posLevel.createdFullName = request.user.name; posLevel.lastUpdateUserId = request.user.sub; posLevel.lastUpdateFullName = request.user.name; + posLevel.createdAt = new Date(); + posLevel.lastUpdatedAt = new Date(); await this.posLevelRepository.save(posLevel, { data: request }); setLogDataDiff(request, { before, after: posLevel }); return new HttpSuccess(posLevel); @@ -160,6 +162,7 @@ export class PosLevelController extends Controller { const before = structuredClone(posLevel); posLevel.lastUpdateUserId = request.user.sub; posLevel.lastUpdateFullName = request.user.name; + posLevel.lastUpdatedAt = new Date(); this.posLevelRepository.merge(posLevel, requestBody); await this.posLevelRepository.save(posLevel, { data: Request }); setLogDataDiff(request, { before, after: posLevel }); diff --git a/src/controllers/PosTypeController.ts b/src/controllers/PosTypeController.ts index 0c3be9a..126f02a 100644 --- a/src/controllers/PosTypeController.ts +++ b/src/controllers/PosTypeController.ts @@ -75,6 +75,8 @@ export class PosTypeController extends Controller { posType.createdFullName = request.user.name; posType.lastUpdateUserId = request.user.sub; posType.lastUpdateFullName = request.user.name; + posType.createdAt = new Date(); + posType.lastUpdatedAt = new Date(); await this.posTypeRepository.save(posType, { data: request }); setLogDataDiff(request, { before, after: posType }); return new HttpSuccess(posType); @@ -120,6 +122,7 @@ export class PosTypeController extends Controller { const before = structuredClone(posType); posType.lastUpdateUserId = request.user.sub; posType.lastUpdateFullName = request.user.name; + posType.lastUpdatedAt = new Date(); this.posTypeRepository.merge(posType, requestBody); await this.posTypeRepository.save(posType, { data: request }); setLogDataDiff(request, { before, after: posType }); diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index c1725b8..29dd076 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -6307,6 +6307,9 @@ export class ReportController extends Controller { .then(async (x) => { const before = null; salary.status = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salary, { data: request }); setLogDataDiff(request, { before, after: salary }); }); @@ -6357,6 +6360,9 @@ export class ReportController extends Controller { .then(async (x) => { const before = null; salary.status = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salary, { data: request }); setLogDataDiff(request, { before, after: salary }); }); @@ -6407,6 +6413,9 @@ export class ReportController extends Controller { .then(async (x) => { const before = null; salary.status = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salary, { data: request }); setLogDataDiff(request, { before, after: salary }); }); @@ -6457,6 +6466,9 @@ export class ReportController extends Controller { .then(async (x) => { const before = null; salary.status = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); await this.salaryProfileEmployeeRepository.save(salary, { data: request }); setLogDataDiff(request, { before, after: salary }); }); @@ -6507,6 +6519,9 @@ export class ReportController extends Controller { .then(async (x) => { const before = null; salary.status = "DONE"; + salary.lastUpdateUserId = request.user.sub; + salary.lastUpdateFullName = request.user.name; + salary.lastUpdatedAt = new Date(); await this.salaryProfileEmployeeRepository.save(salary, { data: request }); setLogDataDiff(request, { before, after: salary }); }); diff --git a/src/controllers/SalaryController.ts b/src/controllers/SalaryController.ts index 9f89ee0..ea0cff1 100644 --- a/src/controllers/SalaryController.ts +++ b/src/controllers/SalaryController.ts @@ -103,6 +103,8 @@ export class SalaryController extends Controller { salarys.createdFullName = request.user.name; salarys.lastUpdateUserId = request.user.sub; salarys.lastUpdateFullName = request.user.name; + salarys.createdAt = new Date(); + salarys.lastUpdatedAt = new Date(); await this.salaryRepository.save(salarys, { data: request }); setLogDataDiff(request, { before, after: salarys }); return new HttpSuccess(salarys.id); @@ -355,12 +357,24 @@ export class SalaryController extends Controller { const before = null; const newSalary = { ...salary, id: randomUUID(), isActive: false }; + newSalary.createdUserId = request.user.sub; + newSalary.createdFullName = request.user.name; + newSalary.lastUpdateUserId = request.user.sub; + newSalary.lastUpdateFullName = request.user.name; + newSalary.createdAt = new Date(); + newSalary.lastUpdatedAt = new Date(); await this.salaryRepository.save(newSalary, { data: request }); setLogDataDiff(request, { before, after: newSalary }); await Promise.all( salaryRank.map(async (v) => { const newSalaryRank = { ...v, id: randomUUID() }; + newSalary.createdUserId = request.user.sub; + newSalary.createdFullName = request.user.name; + newSalary.lastUpdateUserId = request.user.sub; + newSalary.lastUpdateFullName = request.user.name; + newSalary.createdAt = new Date(); + newSalary.lastUpdatedAt = new Date(); await this.salaryRankRepository.save(newSalaryRank, { data: request }); setLogDataDiff(request, { before, after: newSalaryRank }); }), diff --git a/src/controllers/SalaryEmployeeController.ts b/src/controllers/SalaryEmployeeController.ts index 6cc38ad..6c16a04 100644 --- a/src/controllers/SalaryEmployeeController.ts +++ b/src/controllers/SalaryEmployeeController.ts @@ -92,6 +92,9 @@ export class SalaryEmployeeController extends Controller { salarys.createdFullName = request.user.name; salarys.lastUpdateUserId = request.user.sub; salarys.lastUpdateFullName = request.user.name; + salarys.createdAt = new Date(); + salarys.lastUpdatedAt = new Date(); + await this.salaryEmployeeRepository.save(salarys, { data: request }); setLogDataDiff(request, { before, after: salarys }); return new HttpSuccess(salarys.id); @@ -296,12 +299,24 @@ export class SalaryEmployeeController extends Controller { const newSalary = { ...salary, id: randomUUID(), isActive: false }; const before = null; + newSalary.createdUserId = request.user.sub; + newSalary.createdFullName = request.user.name; + newSalary.lastUpdateUserId = request.user.sub; + newSalary.lastUpdateFullName = request.user.name; + newSalary.createdAt = new Date(); + newSalary.lastUpdatedAt = new Date(); await this.salaryEmployeeRepository.save(newSalary, { data: request }); setLogDataDiff(request, { before, after: newSalary }); await Promise.all( salaryRank.map(async (v) => { const newSalaryRank = { ...v, id: randomUUID() }; + newSalaryRank.createdUserId = request.user.sub; + newSalaryRank.createdFullName = request.user.name; + newSalaryRank.lastUpdateUserId = request.user.sub; + newSalaryRank.lastUpdateFullName = request.user.name; + newSalaryRank.createdAt = new Date(); + newSalaryRank.lastUpdatedAt = new Date(); await this.salaryRankEmployeeRepository.save(newSalaryRank, { data: request }); setLogDataDiff(request, { before, after: newSalaryRank }); }), diff --git a/src/controllers/SalaryFormulaEmployeeController.ts b/src/controllers/SalaryFormulaEmployeeController.ts index f85db72..f194a23 100644 --- a/src/controllers/SalaryFormulaEmployeeController.ts +++ b/src/controllers/SalaryFormulaEmployeeController.ts @@ -105,6 +105,8 @@ export class SalaryFormulaEmployeeController extends Controller { formula.createdFullName = request.user.name; formula.lastUpdateUserId = request.user.sub; formula.lastUpdateFullName = request.user.name; + formula.createdAt = new Date(); + formula.lastUpdatedAt = new Date(); await this.salaryFormulaEmployeeRepository.save(formula, { data: request }); setLogDataDiff(request, { before, after: formula }); return new HttpSuccess(formula); @@ -175,6 +177,7 @@ export class SalaryFormulaEmployeeController extends Controller { formula.salaryEmployeeMins = chkSalaryEmployeeMin; formula.lastUpdateUserId = request.user.sub; formula.lastUpdateFullName = request.user.name; + formula.lastUpdatedAt = new Date(); await this.salaryFormulaEmployeeRepository.save(formula, { data: request }); setLogDataDiff(request, { before, after: formula }); return new HttpSuccess(formula.id); diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index c29ad9a..55c94d9 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -329,6 +329,9 @@ export class SalaryPeriodController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); } } @@ -383,6 +386,9 @@ export class SalaryPeriodController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); } } @@ -579,6 +585,9 @@ export class SalaryPeriodController extends Controller { } else { throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง"); } + salaryProfile.lastUpdateUserId = request.user.sub; + salaryProfile.lastUpdateFullName = request.user.name; + salaryProfile.lastUpdatedAt = new Date(); const before = structuredClone(salaryProfile); await this.salaryProfileRepository.save(salaryProfile, { data: request }); setLogDataDiff(request, { before, after: salaryProfile }); @@ -612,6 +621,9 @@ export class SalaryPeriodController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); setLogDataDiff(request, { before, after: salaryOrg }); } @@ -667,6 +679,9 @@ export class SalaryPeriodController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); setLogDataDiff(request, { before, after: salaryOrg }); } @@ -708,6 +723,9 @@ export class SalaryPeriodController extends Controller { const before = null; salaryProfile.salaryOrgId = salaryOrg.id; + salaryProfile.lastUpdateUserId = req.user.sub; + salaryProfile.lastUpdateFullName = req.user.name; + salaryProfile.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salaryProfile, { data: req }); setLogDataDiff(req, { before, after: salaryProfile }); @@ -740,6 +758,9 @@ export class SalaryPeriodController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -795,6 +816,9 @@ export class SalaryPeriodController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -1026,6 +1050,9 @@ export class SalaryPeriodController extends Controller { } else { throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง"); } + salaryProfile.lastUpdateUserId = req.user.sub; + salaryProfile.lastUpdateFullName = req.user.name; + salaryProfile.lastUpdatedAt = new Date(); const before = structuredClone(salaryProfile); await this.salaryProfileRepository.save(salaryProfile, { data: req }); setLogDataDiff(req, { before, after: salaryProfile }); @@ -1059,6 +1086,9 @@ export class SalaryPeriodController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -1114,6 +1144,9 @@ export class SalaryPeriodController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -1468,6 +1501,8 @@ export class SalaryPeriodController extends Controller { salaryProfile.createdFullName = request.user.name; salaryProfile.lastUpdateUserId = request.user.sub; salaryProfile.lastUpdateFullName = request.user.name; + salaryProfile.createdAt = new Date(); + salaryProfile.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salaryProfile, { data: request }); setLogDataDiff(request, { before, after: salaryProfile }); @@ -1500,6 +1535,9 @@ export class SalaryPeriodController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); setLogDataDiff(request, { before, after: salaryOrg }); } @@ -1555,6 +1593,9 @@ export class SalaryPeriodController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); setLogDataDiff(request, { before, after: salaryOrg }); } @@ -1583,6 +1624,9 @@ export class SalaryPeriodController extends Controller { } const before = structuredClone(salaryPeriod); salaryPeriod.isClose = !salaryPeriod.isClose; + salaryPeriod.lastUpdateUserId = request.user.sub; + salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); @@ -1627,6 +1671,8 @@ export class SalaryPeriodController extends Controller { salaryPeriod.createdFullName = request.user.name; salaryPeriod.lastUpdateUserId = request.user.sub; salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.createdAt = new Date(); + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); @@ -1654,6 +1700,9 @@ export class SalaryPeriodController extends Controller { let revisionId = await new CallAPI().GetData(request, "/org/unauthorize/revision/latest"); salaryPeriod.revisionId = revisionId; + salaryPeriod.lastUpdateUserId = request.user.sub; + salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); @@ -1670,6 +1719,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.createdFullName = request.user.name; salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); salaryOrgNew.group = "GROUP1"; await this.salaryOrgRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before, after: salaryOrgNew }); @@ -1689,6 +1740,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; salaryOrgNew.group = "GROUP1"; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); await this.salaryOrgEmployeeRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before, after: salaryOrgNew }); }), @@ -1769,6 +1822,10 @@ export class SalaryPeriodController extends Controller { let revisionId = await new CallAPI().GetData(request, "/org/unauthorize/revision/latest"); chk_SalaryPeriod.revisionId = revisionId; + chk_SalaryPeriod.lastUpdateUserId = request.user.sub; + chk_SalaryPeriod.lastUpdateFullName = request.user.name; + chk_SalaryPeriod.lastUpdatedAt = new Date(); + await this.salaryPeriodRepository.save(chk_SalaryPeriod, { data: request }); setLogDataDiff(request, { before: beforeChk_SalaryPeriod, after: chk_SalaryPeriod }); @@ -1788,6 +1845,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; salaryOrgNew.group = "GROUP1"; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before: beforeSalaryOrgNew, after: salaryOrgNew }); }), @@ -1809,6 +1868,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; salaryOrgNew.group = "GROUP1"; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); await this.salaryOrgEmployeeRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before: beforeSalaryOrgNew, after: salaryOrgNew }); }), @@ -2088,6 +2149,9 @@ export class SalaryPeriodController extends Controller { const beforeSalaryPeriod = structuredClone(salaryPeriod); salaryPeriod.revisionId = revisionId; + salaryPeriod.lastUpdateUserId = request.user.sub; + salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before: beforeSalaryPeriod, after: salaryPeriod }); @@ -2107,6 +2171,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.createdFullName = request.user.name; salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); salaryOrgNew.group = "GROUP1"; await this.salaryOrgRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before: beforeSalaryOrgNew, after: salaryOrgNew }); @@ -2136,6 +2202,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; salaryOrgNew.group = "GROUP1"; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); await this.salaryOrgEmployeeRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before: beforeSalaryOrgNew, after: salaryOrgNew }); @@ -2182,6 +2250,8 @@ export class SalaryPeriodController extends Controller { salaryProfileNew.createdFullName = request.user.name; salaryProfileNew.lastUpdateUserId = request.user.sub; salaryProfileNew.lastUpdateFullName = request.user.name; + salaryProfileNew.createdAt = new Date(); + salaryProfileNew.lastUpdatedAt = new Date(); if (snapshot == "SNAP2") { const salaryOrgOld = await this.salaryOrgRepository.find({ @@ -2231,6 +2301,8 @@ export class SalaryPeriodController extends Controller { salaryProfileNew.createdFullName = request.user.name; salaryProfileNew.lastUpdateUserId = request.user.sub; salaryProfileNew.lastUpdateFullName = request.user.name; + salaryProfileNew.createdAt = new Date(); + salaryProfileNew.lastUpdatedAt = new Date(); if (snapshot == "SNAP2") { const salaryOrgOld = await this.salaryOrgEmployeeRepository.find({ @@ -2329,6 +2401,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount; } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before: before_salaryOrg, after: _salaryOrg }); }), @@ -2387,6 +2465,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount; } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgEmployeeRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before: before_salaryOrg, after: _salaryOrg }); }), @@ -2424,6 +2508,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100); } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before: before_salaryOrg, after: _salaryOrg }); }), @@ -2460,6 +2550,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100); } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgEmployeeRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before: before_salaryOrg, after: _salaryOrg }); }), @@ -2610,6 +2706,9 @@ export class SalaryPeriodController extends Controller { let revisionId = await new CallAPI().GetData(request, "/org/unauthorize/revision/latest"); const before = null; salaryPeriod.revisionId = revisionId; + salaryPeriod.lastUpdateUserId = request.user.sub; + salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); @@ -2626,6 +2725,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.createdFullName = request.user.name; salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); salaryOrgNew.group = "GROUP1"; await this.salaryOrgRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before, after: salaryOrgNew }); @@ -2652,6 +2753,8 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.createdFullName = request.user.name; salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); salaryOrgNew.group = "GROUP1"; await this.salaryOrgRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before, after: salaryOrgNew }); @@ -2719,6 +2822,12 @@ export class SalaryPeriodController extends Controller { salaryProfileNew.isReserve = salaryOld == null ? false : salaryOld.isReserve; salaryProfileNew.isRetired = salaryOld == null ? false : salaryOld.isRetired; } + salaryProfileNew.createdUserId = request.user.sub; + salaryProfileNew.createdFullName = request.user.name; + salaryProfileNew.lastUpdateUserId = request.user.sub; + salaryProfileNew.lastUpdateFullName = request.user.name; + salaryProfileNew.createdAt = new Date(); + salaryProfileNew.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salaryProfileNew, { data: request }); setLogDataDiff(request, { before, after: salaryProfileNew }); } @@ -2766,6 +2875,12 @@ export class SalaryPeriodController extends Controller { salaryProfileNew.isReserve = salaryOld == null ? false : salaryOld.isReserve; salaryProfileNew.isRetired = salaryOld == null ? false : salaryOld.isRetired; } + salaryProfileNew.createdUserId = request.user.sub; + salaryProfileNew.createdFullName = request.user.name; + salaryProfileNew.lastUpdateUserId = request.user.sub; + salaryProfileNew.lastUpdateFullName = request.user.name; + salaryProfileNew.createdAt = new Date(); + salaryProfileNew.lastUpdatedAt = new Date(); await this.salaryProfileEmployeeRepository.save(salaryProfileNew, { data: request }); setLogDataDiff(request, { before, after: salaryProfileNew }); } @@ -2840,6 +2955,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount; } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before, after: _salaryOrg }); }), @@ -2896,6 +3017,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount; } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgEmployeeRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before, after: _salaryOrg }); }), @@ -2931,6 +3058,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100); } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before, after: _salaryOrg }); }), @@ -2965,6 +3098,12 @@ export class SalaryPeriodController extends Controller { _salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100); } + _salaryOrg.createdUserId = request.user.sub; + _salaryOrg.createdFullName = request.user.name; + _salaryOrg.lastUpdateUserId = request.user.sub; + _salaryOrg.lastUpdateFullName = request.user.name; + _salaryOrg.createdAt = new Date(); + _salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgEmployeeRepository.save(_salaryOrg, { data: request }); setLogDataDiff(request, { before, after: _salaryOrg }); }), @@ -2997,6 +3136,9 @@ export class SalaryPeriodController extends Controller { .map(async (x) => { const before = structuredClone(x); x.status = "WAITHEAD1"; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -3026,6 +3168,9 @@ export class SalaryPeriodController extends Controller { .map(async (x) => { const before = structuredClone(x); x.status = "WAITOWNER1"; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -3059,6 +3204,9 @@ export class SalaryPeriodController extends Controller { .map(async (x) => { const before = structuredClone(x); x.status = "REPORT"; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -3098,6 +3246,9 @@ export class SalaryPeriodController extends Controller { const before = structuredClone(x); x.status = "WAITHEAD2"; x.ownerRecommend = body.titleRecommend; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -3137,6 +3288,9 @@ export class SalaryPeriodController extends Controller { const before = structuredClone(x); x.status = "REPORT"; x.ownerRecommend = body.titleRecommend; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index d239826..fb6ae7b 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -290,6 +290,9 @@ export class SalaryPeriodEmployeeController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); } } @@ -344,6 +347,9 @@ export class SalaryPeriodEmployeeController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); } } @@ -713,6 +719,9 @@ export class SalaryPeriodEmployeeController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง"); } + salaryProfile.lastUpdateUserId = req.user.sub; + salaryProfile.lastUpdateFullName = req.user.name; + salaryProfile.lastUpdatedAt = new Date(); const before = structuredClone(salaryProfile); await this.salaryProfileRepository.save(salaryProfile, { data: req }); setLogDataDiff(req, { before, after: salaryProfile }); @@ -746,6 +755,9 @@ export class SalaryPeriodEmployeeController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -801,6 +813,9 @@ export class SalaryPeriodEmployeeController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -842,6 +857,9 @@ export class SalaryPeriodEmployeeController extends Controller { } const before = null; salaryProfile.salaryOrgId = salaryOrg.id; + salaryProfile.lastUpdateUserId = req.user.sub; + salaryProfile.lastUpdateFullName = req.user.name; + salaryProfile.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salaryProfile, { data: req }); setLogDataDiff(req, { before, after: salaryProfile }); const _salaryProfile = await this.salaryProfileRepository.findOne({ @@ -873,6 +891,9 @@ export class SalaryPeriodEmployeeController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -928,6 +949,9 @@ export class SalaryPeriodEmployeeController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -1334,6 +1358,9 @@ export class SalaryPeriodEmployeeController extends Controller { } else { throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง"); } + salaryProfile.lastUpdateUserId = req.user.sub; + salaryProfile.lastUpdateFullName = req.user.name; + salaryProfile.lastUpdatedAt = new Date(); const before = structuredClone(salaryProfile); await this.salaryProfileRepository.save(salaryProfile, { data: req }); setLogDataDiff(req, { before, after: salaryProfile }); @@ -1367,6 +1394,9 @@ export class SalaryPeriodEmployeeController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -1422,6 +1452,9 @@ export class SalaryPeriodEmployeeController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = req.user.sub; + salaryOrg.lastUpdateFullName = req.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: req }); setLogDataDiff(req, { before, after: salaryOrg }); } @@ -2003,6 +2036,8 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.createdFullName = request.user.name; salaryProfile.lastUpdateUserId = request.user.sub; salaryProfile.lastUpdateFullName = request.user.name; + salaryProfile.createdAt = new Date(); + salaryProfile.lastUpdatedAt = new Date(); await this.salaryProfileRepository.save(salaryProfile, { data: request }); setLogDataDiff(request, { before, after: salaryProfile }); @@ -2035,6 +2070,9 @@ export class SalaryPeriodEmployeeController extends Controller { salaryOrg.quantityUsed = amountFullType; const calRemainQuota = salaryOrg.fifteenPercent - amountFullType; salaryOrg.remainQuota = calRemainQuota; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); setLogDataDiff(request, { before, after: salaryOrg }); } @@ -2090,6 +2128,9 @@ export class SalaryPeriodEmployeeController extends Controller { ? 0 : sumAmountUse.totalAmount; salaryOrg.remainingAmount = calRemainAmount; + salaryOrg.lastUpdateUserId = request.user.sub; + salaryOrg.lastUpdateFullName = request.user.name; + salaryOrg.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(salaryOrg, { data: request }); setLogDataDiff(request, { before, after: salaryOrg }); } @@ -2119,6 +2160,9 @@ export class SalaryPeriodEmployeeController extends Controller { } const before = structuredClone(salaryPeriod); salaryPeriod.isClose = !salaryPeriod.isClose; + salaryPeriod.lastUpdateUserId = request.user.sub; + salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); return new HttpSuccess(); @@ -2162,6 +2206,8 @@ export class SalaryPeriodEmployeeController extends Controller { salaryPeriod.createdFullName = request.user.name; salaryPeriod.lastUpdateUserId = request.user.sub; salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.createdAt = new Date(); + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); @@ -2180,6 +2226,9 @@ export class SalaryPeriodEmployeeController extends Controller { let revisionId = await new CallAPI().GetData(request, "/org/unauthorize/revision/latest"); salaryPeriod.revisionId = revisionId; + salaryPeriod.lastUpdateUserId = request.user.sub; + salaryPeriod.lastUpdateFullName = request.user.name; + salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); @@ -2195,6 +2244,8 @@ export class SalaryPeriodEmployeeController extends Controller { salaryOrgNew.createdFullName = request.user.name; salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); salaryOrgNew.group = "GROUP1"; await this.salaryOrgRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before, after: salaryOrgNew }); @@ -2267,6 +2318,9 @@ export class SalaryPeriodEmployeeController extends Controller { let revisionId = await new CallAPI().GetData(request, "/org/unauthorize/revision/latest"); chk_SalaryPeriod.revisionId = revisionId; + chk_SalaryPeriod.lastUpdateUserId = request.user.sub; + chk_SalaryPeriod.lastUpdateFullName = request.user.name; + chk_SalaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(chk_SalaryPeriod, { data: request }); setLogDataDiff(request, { before: beforechk_SalaryPeriod, after: chk_SalaryPeriod }); @@ -2283,6 +2337,8 @@ export class SalaryPeriodEmployeeController extends Controller { salaryOrgNew.createdFullName = request.user.name; salaryOrgNew.lastUpdateUserId = request.user.sub; salaryOrgNew.lastUpdateFullName = request.user.name; + salaryOrgNew.createdAt = new Date(); + salaryOrgNew.lastUpdatedAt = new Date(); salaryOrgNew.group = "GROUP1"; await this.salaryOrgRepository.save(salaryOrgNew, { data: request }); setLogDataDiff(request, { before, after: salaryOrgNew }); @@ -2451,6 +2507,9 @@ export class SalaryPeriodEmployeeController extends Controller { .map(async (x: any) => { const before = structuredClone(x); x.status = "WAITHEAD1"; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -2480,6 +2539,9 @@ export class SalaryPeriodEmployeeController extends Controller { .map(async (x: any) => { const before = structuredClone(x); x.status = "WAITOWNER1"; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -2513,6 +2575,9 @@ export class SalaryPeriodEmployeeController extends Controller { .map(async (x: any) => { const before = structuredClone(x); x.status = "REPORT"; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -2552,6 +2617,9 @@ export class SalaryPeriodEmployeeController extends Controller { const before = structuredClone(x); x.status = "WAITHEAD2"; x.ownerRecommend = body.titleRecommend; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), @@ -2591,6 +2659,9 @@ export class SalaryPeriodEmployeeController extends Controller { const before = structuredClone(x); x.status = "REPORT"; x.ownerRecommend = body.titleRecommend; + x.lastUpdateUserId = request.user.sub; + x.lastUpdateFullName = request.user.name; + x.lastUpdatedAt = new Date(); await this.salaryOrgRepository.save(x, { data: request }); setLogDataDiff(request, { before, after: x }); }), diff --git a/src/controllers/SalaryRankController.ts b/src/controllers/SalaryRankController.ts index 0dfa984..a2db7f0 100644 --- a/src/controllers/SalaryRankController.ts +++ b/src/controllers/SalaryRankController.ts @@ -63,6 +63,8 @@ export class SalaryRanksController extends Controller { salaryRank.createdFullName = request.user.name; salaryRank.lastUpdateUserId = request.user.sub; salaryRank.lastUpdateFullName = request.user.name; + salaryRank.createdAt = new Date(); + salaryRank.lastUpdatedAt = new Date(); await this.salaryRankRepository.save(salaryRank, { data: request }); setLogDataDiff(request, { before, after: salaryRank }); return new HttpSuccess(); @@ -93,6 +95,7 @@ export class SalaryRanksController extends Controller { const before = structuredClone(salaryRank); salaryRank.lastUpdateUserId = request.user.sub; salaryRank.lastUpdateFullName = request.user.name; + salaryRank.lastUpdatedAt = new Date(); this.salaryRankRepository.merge(salaryRank, requestBody); await this.salaryRankRepository.save(salaryRank, { data: request }); setLogDataDiff(request, { before, after: salaryRank }); diff --git a/src/controllers/SalaryRankEmployeeController.ts b/src/controllers/SalaryRankEmployeeController.ts index 7cfa4af..4e4a866 100644 --- a/src/controllers/SalaryRankEmployeeController.ts +++ b/src/controllers/SalaryRankEmployeeController.ts @@ -75,6 +75,8 @@ export class SalaryRankEmployeeController extends Controller { salaryRankEmployee.createdFullName = request.user.name; salaryRankEmployee.lastUpdateUserId = request.user.sub; salaryRankEmployee.lastUpdateFullName = request.user.name; + salaryRankEmployee.createdAt = new Date(); + salaryRankEmployee.lastUpdatedAt = new Date(); await this.salaryRankEmployeeRepository.save(salaryRankEmployee, { data: request }); setLogDataDiff(request, { before, after: salaryRankEmployee }); return new HttpSuccess(); @@ -116,6 +118,7 @@ export class SalaryRankEmployeeController extends Controller { const before = structuredClone(salaryRankEmployee); salaryRankEmployee.lastUpdateUserId = request.user.sub; salaryRankEmployee.lastUpdateFullName = request.user.name; + salaryRankEmployee.lastUpdatedAt = new Date(); this.salaryRankEmployeeRepository.merge(salaryRankEmployee, requestBody); await this.salaryRankEmployeeRepository.save(salaryRankEmployee, { data: request }); setLogDataDiff(request, { before, after: salaryRankEmployee });