fix error #224
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m4s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m4s
This commit is contained in:
parent
9dddaf40db
commit
2f17c10050
1 changed files with 40 additions and 0 deletions
|
|
@ -180,6 +180,46 @@ export class OfficerProfileService {
|
||||||
console.log("[OfficerProfileService] Starting executeCreateOfficerProfile");
|
console.log("[OfficerProfileService] Starting executeCreateOfficerProfile");
|
||||||
console.log("[OfficerProfileService] Request body count:", data?.length);
|
console.log("[OfficerProfileService] Request body count:", data?.length);
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
// Normalize date fields
|
||||||
|
// ผ่าน HTTP endpoint → tsoa แปลง ISO string → Date ให้อัตโนมัติ
|
||||||
|
// แต่ผ่าน RabbitMQ handler (axios) → จะได้ string → ต้องแปลงเอง
|
||||||
|
// ไม่งั้น calculateRetireDate/getFullYear ฯลฯ จะพัง
|
||||||
|
// ─────────────────────────────────────────────────────────────
|
||||||
|
const toDate = (v: any): Date | null => {
|
||||||
|
if (v == null || v === "") return null;
|
||||||
|
if (v instanceof Date) return isNaN(v.getTime()) ? null : v;
|
||||||
|
const d = new Date(v);
|
||||||
|
return isNaN(d.getTime()) ? null : d;
|
||||||
|
};
|
||||||
|
for (const item of data ?? []) {
|
||||||
|
const bp = item.bodyProfile as any;
|
||||||
|
if (bp) {
|
||||||
|
bp.birthDate = toDate(bp.birthDate);
|
||||||
|
bp.dateStart = toDate(bp.dateStart);
|
||||||
|
bp.dateAppoint = toDate(bp.dateAppoint);
|
||||||
|
bp.dateRetire = toDate(bp.dateRetire);
|
||||||
|
}
|
||||||
|
const bs = item.bodySalarys as any;
|
||||||
|
if (bs) {
|
||||||
|
bs.commandDateAffect = toDate(bs.commandDateAffect);
|
||||||
|
bs.commandDateSign = toDate(bs.commandDateSign);
|
||||||
|
}
|
||||||
|
if (item.bodyEducations) {
|
||||||
|
for (const edu of item.bodyEducations as any[]) {
|
||||||
|
edu.startDate = toDate(edu.startDate);
|
||||||
|
edu.endDate = toDate(edu.endDate);
|
||||||
|
edu.finishDate = toDate(edu.finishDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.bodyCertificates) {
|
||||||
|
for (const cer of item.bodyCertificates as any[]) {
|
||||||
|
cer.expireDate = toDate(cer.expireDate);
|
||||||
|
cer.issueDate = toDate(cer.issueDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const req = ctx.req;
|
const req = ctx.req;
|
||||||
const roleKeycloak = await this.roleKeycloakRepo.findOne({
|
const roleKeycloak = await this.roleKeycloakRepo.findOne({
|
||||||
where: { name: Like("USER") },
|
where: { name: Like("USER") },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue