add update time

This commit is contained in:
kittapath 2024-09-01 22:44:23 +07:00
parent ad4efc2b47
commit a2292d6048
57 changed files with 257 additions and 98 deletions

View file

@ -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;