เก็บประวัติ isupload

This commit is contained in:
mamoss 2025-06-12 16:47:33 +07:00
parent d249e94cb5
commit 7eea4cd33c
24 changed files with 146 additions and 135 deletions

View file

@ -164,12 +164,12 @@ export class ProfileAbilityController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAbilityRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAbilityHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.profileAbilityRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.profileAbilityHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -173,12 +173,12 @@ export class ProfileAbilityEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAbilityRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAbilityHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.profileAbilityRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.profileAbilityHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -163,12 +163,12 @@ export class ProfileAbilityEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAbilityRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAbilityHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.profileAbilityRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.profileAbilityHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -165,12 +165,12 @@ export class ProfileAssistanceController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAssistanceRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAssistanceHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.profileAssistanceRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.profileAssistanceHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -173,12 +173,12 @@ export class ProfileAssistanceEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAssistanceRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAssistanceHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.profileAssistanceRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.profileAssistanceHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -163,12 +163,12 @@ export class ProfileAssistanceEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.profileAssistanceRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.profileAssistanceHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.profileAssistanceRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.profileAssistanceHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -156,12 +156,12 @@ export class ProfileCertificateController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.certificateRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.certificateHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.certificateRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.certificateHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -164,12 +164,12 @@ export class ProfileCertificateEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.certificateRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.certificateHistoryRepo.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.certificateRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.certificateHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -152,12 +152,12 @@ export class ProfileCertificateEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.certificateRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.certificateHistoryRepo.save(history, { data: req }),
setLogDataDiff(req, { before: before_null, after: history }),
]);
this.certificateRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.certificateHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -163,12 +163,14 @@ export class ProfileDisciplineController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.disciplineRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.disciplineHistoryRepository.save(history, { data: req }),
setLogDataDiff(req, { before, after: history }),
]);
// await Promise.all(
this.disciplineRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.disciplineHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
// );
return new HttpSuccess();
}

View file

@ -169,12 +169,12 @@ export class ProfileDisciplineEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.disciplineRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.disciplineHistoryRepository.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.disciplineRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.disciplineHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -159,12 +159,12 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.disciplineRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.disciplineHistoryRepository.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.disciplineRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.disciplineHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -140,12 +140,12 @@ export class ProfileDutyController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.dutyRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.dutyHistoryRepository.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.dutyRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.dutyHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -149,12 +149,12 @@ export class ProfileDutyEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.dutyRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.dutyHistoryRepository.save(history, { data: req }),
setLogDataDiff(req, { before, after: history }),
]);
this.dutyRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.dutyHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -138,12 +138,12 @@ export class ProfileDutyEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.dutyRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.dutyHistoryRepository.save(history, { data: req }),
// setLogDataDiff(req, { before: before_null, after: history }),
]);
this.dutyRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.dutyHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -166,11 +166,12 @@ export class ProfileHonorController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.honorRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.honorHistoryRepo.save(history, { data: req }),
]);
this.honorRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.honorHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -178,11 +178,12 @@ export class ProfileHonorEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.honorRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.honorHistoryRepo.save(history, { data: req }),
]);
this.honorRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.honorHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -166,11 +166,12 @@ export class ProfileHonorEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.honorRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.honorHistoryRepo.save(history, { data: req }),
]);
this.honorRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.honorHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -186,11 +186,12 @@ export class ProfileInsigniaController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.insigniaRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.insigniaHistoryRepo.save(history, { data: req }),
]);
this.insigniaRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.insigniaHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -197,11 +197,12 @@ export class ProfileInsigniaEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.insigniaRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.insigniaHistoryRepo.save(history, { data: req }),
]);
this.insigniaRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.insigniaHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -186,11 +186,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.insigniaRepo.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.insigniaHistoryRepo.save(history, { data: req }),
]);
this.insigniaRepo.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.insigniaHistoryRepo.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -130,11 +130,12 @@ export class ProfileNopaidController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.nopaidRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.nopaidHistoryRepository.save(history, { data: req }),
]);
this.nopaidRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.nopaidHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -137,11 +137,12 @@ export class ProfileNopaidEmployeeController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.nopaidRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.nopaidHistoryRepository.save(history, { data: req }),
]);
this.nopaidRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.nopaidHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}

View file

@ -134,11 +134,12 @@ export class ProfileNopaidEmployeeTempController extends Controller {
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.nopaidRepository.save(record, { data: req }),
setLogDataDiff(req, { before, after: record }),
this.nopaidHistoryRepository.save(history, { data: req }),
]);
this.nopaidRepository.save(record, { data: req });
setLogDataDiff(req, { before, after: record });
if (!(Object.keys(body).length === 1 && body.isUpload)) {
this.nopaidHistoryRepository.save(history, { data: req });
// setLogDataDiff(req, { before, after: history });
}
return new HttpSuccess();
}