add update time
This commit is contained in:
parent
ad4efc2b47
commit
a2292d6048
57 changed files with 257 additions and 98 deletions
|
|
@ -132,7 +132,7 @@ export class ProfileAbilityController extends Controller {
|
|||
const history = new ProfileAbilityHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAbilityId = abilityId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
const history = new ProfileAbilityHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAbilityId = abilityId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
|||
const history = new ProfileAbilityHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAbilityId = abilityId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ export class ProfileAddressController extends Controller {
|
|||
"currentDistrictId",
|
||||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
"createdAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
|
|
@ -66,7 +65,6 @@ export class ProfileAddressController extends Controller {
|
|||
"currentDistrictId",
|
||||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
"createdAt",
|
||||
],
|
||||
});
|
||||
if (!getProfileAddress) {
|
||||
|
|
@ -88,12 +86,32 @@ export class ProfileAddressController extends Controller {
|
|||
}
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileId: profile.id },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,12 +127,32 @@ export class ProfileAddressController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileId: profileId },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -135,7 +173,7 @@ export class ProfileAddressController extends Controller {
|
|||
const history = new ProfileAddressHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
"currentDistrictId",
|
||||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
"createdAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
|
|
@ -70,7 +69,6 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
"currentDistrictId",
|
||||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
"createdAt",
|
||||
],
|
||||
});
|
||||
if (!getProfileAddress) {
|
||||
|
|
@ -92,12 +90,32 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
}
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -113,12 +131,32 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -139,7 +177,7 @@ export class ProfileAddressEmployeeController extends Controller {
|
|||
const history = new ProfileAddressHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
"currentDistrictId",
|
||||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
"createdAt",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
|
|
@ -70,7 +69,6 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
"currentDistrictId",
|
||||
"currentSubDistrictId",
|
||||
"currentZipCode",
|
||||
"createdAt",
|
||||
],
|
||||
});
|
||||
if (!getProfileAddress) {
|
||||
|
|
@ -92,12 +90,32 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
}
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -113,12 +131,32 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const record = await this.profileAddressHistoryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
order: { createdAt: "DESC" },
|
||||
relations: [
|
||||
"registrationProvince",
|
||||
"registrationDistrict",
|
||||
"registrationSubDistrict",
|
||||
"currentProvince",
|
||||
"currentDistrict",
|
||||
"currentSubDistrict",
|
||||
],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
return new HttpSuccess(record);
|
||||
const _record = record.map((item) => ({
|
||||
id: item.id,
|
||||
currentAddress: item.currentAddress,
|
||||
registrationAddress: item.registrationAddress,
|
||||
currentZipCode: item.currentZipCode,
|
||||
registrationZipCode: item.registrationZipCode,
|
||||
currentProvince: item.currentProvince?.name ?? null,
|
||||
registrationProvince: item.registrationProvince?.name ?? null,
|
||||
currentDistrict: item.currentDistrict?.name ?? null,
|
||||
registrationDistrict: item.registrationDistrict?.name ?? null,
|
||||
currentSubDistrict: item.currentSubDistrict?.name ?? null,
|
||||
registrationSubDistrict: item.registrationSubDistrict?.name ?? null,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
lastUpdateFullName: item.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(_record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -139,7 +177,7 @@ export class ProfileAddressEmployeeTempController extends Controller {
|
|||
const history = new ProfileAddressHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export class ProfileAssessmentsController extends Controller {
|
|||
const history = new ProfileAssessmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAssessmentId = assessmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
const history = new ProfileAssessmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAssessmentId = assessmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
const history = new ProfileAssessmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileAssessmentId = assessmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ export class ProfileCertificateController extends Controller {
|
|||
const history = new ProfileCertificateHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileCertificateId = certificateId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
const history = new ProfileCertificateHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileCertificateId = certificateId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
|||
const history = new ProfileCertificateHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileCertificateId = certificateId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export class ProfileChangeNameController extends Controller {
|
|||
const history = new ProfileChangeNameHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileChangeNameId = changeNameId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
const history = new ProfileChangeNameHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileChangeNameId = changeNameId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
|||
const history = new ProfileChangeNameHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileChangeNameId = changeNameId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export class ProfileChildrenController extends Controller {
|
|||
|
||||
const history = new ProfileChildrenHistory();
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
|
||||
const history = new ProfileChildrenHistory();
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
|||
|
||||
const history = new ProfileChildrenHistory();
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
|
||||
history.profileChildrenId = record.id;
|
||||
|
|
|
|||
|
|
@ -2388,6 +2388,12 @@ export class ProfileController extends Controller {
|
|||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = request.user.sub;
|
||||
record.lastUpdateFullName = request.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileHistory(), {
|
||||
...record,
|
||||
|
|
@ -2395,13 +2401,6 @@ export class ProfileController extends Controller {
|
|||
id: undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
Object.assign(record, body);
|
||||
record.lastUpdateUserId = request.user.sub;
|
||||
record.lastUpdateFullName = request.user.name;
|
||||
record.lastUpdatedAt = new Date();
|
||||
record.dateRetire = calculateRetireDate(record.birthDate);
|
||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
await this.profileRepo.save(record);
|
||||
|
||||
if (record != null && record.keycloak != null) {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export class ProfileDevelopmentController extends Controller {
|
|||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller {
|
|||
const history = new ProfileDevelopmentHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDevelopmentId = developmentId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ export class ProfileDisciplineController extends Controller {
|
|||
const history = new ProfileDisciplineHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDisciplineId = disciplineId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
const history = new ProfileDisciplineHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDisciplineId = disciplineId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
|||
const history = new ProfileDisciplineHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDisciplineId = disciplineId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ export class ProfileDutyController extends Controller {
|
|||
const history = new ProfileDutyHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDutyId = dutyId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
const history = new ProfileDutyHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDutyId = dutyId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
|||
const history = new ProfileDutyHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileDutyId = dutyId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ export class ProfileEducationsController extends Controller {
|
|||
const history = new ProfileEducationHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEducationId = educationId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
const history = new ProfileEducationHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEducationId = educationId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
|||
const history = new ProfileEducationHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEducationId = educationId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -1234,6 +1234,12 @@ export class ProfileEmployeeController extends Controller {
|
|||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
const data = await Promise.all(
|
||||
record.map((_data) => {
|
||||
const shortName =
|
||||
|
|
@ -1256,6 +1262,45 @@ export class ProfileEmployeeController extends Controller {
|
|||
: _data.profileEmployeeEmployment.reduce((latest, current) => {
|
||||
return latest.date > current.date ? latest : current;
|
||||
}).date;
|
||||
const root =
|
||||
_data.current_holders.length == 0 ||
|
||||
(_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
const child1 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1;
|
||||
|
||||
const child2 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2;
|
||||
|
||||
const child3 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3;
|
||||
|
||||
const child4 =
|
||||
_data.current_holders == null ||
|
||||
_data.current_holders.length == 0 ||
|
||||
_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null
|
||||
? null
|
||||
: _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4;
|
||||
|
||||
let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`;
|
||||
let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`;
|
||||
let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`;
|
||||
let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`;
|
||||
return {
|
||||
id: _data.id,
|
||||
prefix: _data.prefix,
|
||||
|
|
@ -1335,6 +1380,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
child4: _data.child4Temp ? _data.child4Temp : null,
|
||||
child4Id: _data.child4IdTemp ? _data.child4IdTemp : null,
|
||||
child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null,
|
||||
org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3144,8 +3144,8 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const history = new ProfileEmployeeEmploymentHistory();
|
||||
Object.assign(history, { ...employment, id: undefined });
|
||||
Object.assign(employment, body);
|
||||
Object.assign(history, { ...employment, id: undefined });
|
||||
|
||||
employment.lastUpdateUserId = request.user.sub;
|
||||
employment.lastUpdateFullName = request.user.name;
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ export class ProfileGovernmentHistoryController extends Controller {
|
|||
const history = new ProfileGovernment();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileId = profileId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
|
|||
const history = new ProfileGovernment();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileEmployeeId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller {
|
|||
const history = new ProfileGovernment();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileEmployeeId = profileEmployeeId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export class ProfileHonorController extends Controller {
|
|||
const history = new ProfileHonorHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileHonorId = honorId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
const history = new ProfileHonorHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileHonorId = honorId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
|||
const history = new ProfileHonorHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileHonorId = honorId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ export class ProfileInsigniaController extends Controller {
|
|||
const history = new ProfileInsigniaHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileInsigniaId = insigniaId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
const history = new ProfileInsigniaHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileInsigniaId = insigniaId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
|||
const history = new ProfileInsigniaHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileInsigniaId = insigniaId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ export class ProfileLeaveController extends Controller {
|
|||
const history = new ProfileLeaveHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileLeaveId = leaveId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
const history = new ProfileLeaveHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileLeaveId = leaveId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
const history = new ProfileLeaveHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileLeaveId = leaveId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ export class ProfileNopaidController extends Controller {
|
|||
const history = new ProfileNopaidHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileNopaidId = nopaidId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
const history = new ProfileNopaidHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileNopaidId = nopaidId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
const history = new ProfileNopaidHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileNopaidId = nopaidId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export class ProfileOtherController extends Controller {
|
|||
const history = new ProfileOtherHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileOtherId = otherId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
const history = new ProfileOtherHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileOtherId = otherId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
|||
const history = new ProfileOtherHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileOtherId = otherId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export class ProfileSalaryController extends Controller {
|
|||
const history = new ProfileSalaryHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileSalaryId = salaryId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
const history = new ProfileSalaryHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileSalaryId = salaryId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
|
|||
const history = new ProfileSalaryHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileSalaryId = salaryId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ export class ProfileTrainingController extends Controller {
|
|||
const history = new ProfileTrainingHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileTrainingId = trainingId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ export class ProfileTrainingEmployeeController extends Controller {
|
|||
const history = new ProfileTrainingHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileTrainingId = trainingId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
|||
const history = new ProfileTrainingHistory();
|
||||
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...body, id: undefined });
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
history.profileTrainingId = trainingId;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue