From 428b99508101be7e1873c964de25e9de1f498b4f Mon Sep 17 00:00:00 2001 From: harid Date: Wed, 24 Dec 2025 17:48:22 +0700 Subject: [PATCH 1/2] no message --- .../OrganizationDotnetController.ts | 39 ++++++++++++++----- .../OrganizationUnauthorizeController.ts | 35 +++++++++++++---- 2 files changed, 56 insertions(+), 18 deletions(-) diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 29a94f70..6ee5cd36 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -2657,12 +2657,17 @@ export class OrganizationDotnetController extends Controller { dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, posLevel: profile.posLevel?.posLevelName ?? "", posType: profile.posType?.posTypeName ?? "", - profileSalary: profile.profileSalary, + // profileSalary: profile.profileSalary, + profileSalary: profile.profileSalary?.map((x) => ({ + ...x, + date: x.commandDateAffect ?? new Date() + })) ?? [], // profileInsignia: profile.profileInsignias.map((x) => { // return { ...x, insignia: x.insignia.name }; // }), profileInsignia: profile.profileInsignias?.map((x) => ({ ...x, + insigniaId: x.insignia?.id ?? null, insignia: x.insignia?.name ?? null, })) ?? [], amount: profile.amount, @@ -2962,9 +2967,14 @@ export class OrganizationDotnetController extends Controller { : profile.posType?.posTypeShortName + " ") + (profile.posLevel?.posLevelName ?? ""), posType: profile.posType?.posTypeName ?? "", profileSalary: profile.profileSalary, - profileInsignia: profile.profileInsignias.map((x) => { - return { ...x, insignia: x.insignia.name }; - }), + // profileInsignia: profile.profileInsignias.map((x) => { + // return { ...x, insignia: x.insignia.name }; + // }), + profileInsignia: profile.profileInsignias?.map((x) => ({ + ...x, + insigniaId: x.insignia?.id ?? null, + insignia: x.insignia?.name ?? null, + })) ?? [], amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, @@ -3176,12 +3186,21 @@ export class OrganizationDotnetController extends Controller { ? "" : profile.posType?.posTypeShortName + " ") + (profile.posLevel?.posLevelName ?? ""), posType: profile.posType?.posTypeName ?? "", - profileSalary: profile.profileSalary.map((x) => { - return { ...x, date: x.commandDateAffect ?? new Date() }; - }), - profileInsignia: profile.profileInsignias.map((x) => { - return { ...x, insignia: x.insignia.name }; - }), + // profileSalary: profile.profileSalary.map((x) => { + // return { ...x, date: x.commandDateAffect ?? new Date() }; + // }), + profileSalary: profile.profileSalary?.map((x) => ({ + ...x, + date: x.commandDateAffect ?? new Date() + })) ?? [], + // profileInsignia: profile.profileInsignias.map((x) => { + // return { ...x, insignia: x.insignia.name }; + // }), + profileInsignia: profile.profileInsignias?.map((x) => ({ + ...x, + insigniaId: x.insignia?.id ?? null, + insignia: x.insignia?.name ?? null, + })) ?? [], amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index d63b885c..dfd26df5 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -1663,12 +1663,17 @@ export class OrganizationUnauthorizeController extends Controller { dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate, posLevel: profile.posLevel?.posLevelName ?? "", posType: profile.posType?.posTypeName ?? "", - profileSalary: profile.profileSalary, + // profileSalary: profile.profileSalary, + profileSalary: profile.profileSalary?.map((x) => ({ + ...x, + date: x.commandDateAffect ?? new Date() + })) ?? [], // profileInsignia: profile.profileInsignias.map((x) => { // return { ...x, insignia: x.insignia.name }; // }), profileInsignia: profile.profileInsignias?.map((x) => ({ ...x, + insigniaId: x.insignia?.id ?? null, insignia: x.insignia?.name ?? null, })) ?? [], amount: profile.amount, @@ -1879,7 +1884,12 @@ export class OrganizationUnauthorizeController extends Controller { posLevel: profile.posLevel ? profile.posLevel : null, posType: profile.posType ? profile.posType : null, profileSalary: profile.profileSalary, - profileInsignia: profile.profileInsignias, + // profileInsignia: profile.profileInsignias, + profileInsignia: profile.profileInsignias?.map((x) => ({ + ...x, + insigniaId: x.insignia?.id ?? null, + insignia: x.insignia?.name ?? null, + })) ?? [], })); return new HttpSuccess(mapProfile); @@ -2053,12 +2063,21 @@ export class OrganizationUnauthorizeController extends Controller { ? "" : profile.posType?.posTypeShortName + " ") + (profile.posLevel?.posLevelName ?? ""), posType: profile.posType?.posTypeName ?? "", - profileSalary: profile.profileSalary.map((x) => { - return { ...x, date: x.commandDateAffect ?? new Date() }; - }), - profileInsignia: profile.profileInsignias.map((x) => { - return { ...x, insignia: x.insignia.name }; - }), + // profileSalary: profile.profileSalary.map((x) => { + // return { ...x, date: x.commandDateAffect ?? new Date() }; + // }), + profileSalary: profile.profileSalary?.map((x) => ({ + ...x, + date: x.commandDateAffect ?? new Date() + })) ?? [], + // profileInsignia: profile.profileInsignias.map((x) => { + // return { ...x, insignia: x.insignia.name }; + // }), + profileInsignia: profile.profileInsignias?.map((x) => ({ + ...x, + insigniaId: x.insignia?.id ?? null, + insignia: x.insignia?.name ?? null, + })) ?? [], amount: profile.amount, positionSalaryAmount: profile.positionSalaryAmount, mouthSalaryAmount: profile.mouthSalaryAmount, From 7334fd711fcf35e1260511a42de05888bbf842f4 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 26 Dec 2025 22:04:17 +0700 Subject: [PATCH 2/2] migration: add field dnaId and profileId --- src/entities/PosMasterHistory.ts | 48 +++++++++++++++++++ ...760828376-add_field_dnaid_and_prodileid.ts | 24 ++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/migration/1766760828376-add_field_dnaid_and_prodileid.ts diff --git a/src/entities/PosMasterHistory.ts b/src/entities/PosMasterHistory.ts index 4360cf1e..bbdd3f7e 100644 --- a/src/entities/PosMasterHistory.ts +++ b/src/entities/PosMasterHistory.ts @@ -98,4 +98,52 @@ export class PosMasterHistory extends EntityBase { default: null, }) ancestorDNA: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง profile", + default: null, + }) + profileId: string; + + @Column({ + nullable: true, + length: 40, + comment: "dna ของตาราง orgRoot", + default: null, + }) + rootDnaId: string; + + @Column({ + nullable: true, + length: 40, + comment: "dna ของตาราง orgChild1", + default: null, + }) + child1DnaId: string; + + @Column({ + nullable: true, + length: 40, + comment: "dna ของตาราง orgChild2", + default: null, + }) + child2DnaId: string; + + @Column({ + nullable: true, + length: 40, + comment: "dna ของตาราง orgChild3", + default: null, + }) + child3DnaId: string; + + @Column({ + nullable: true, + length: 40, + comment: "dna ของตาราง orgChild4", + default: null, + }) + child4DnaId: string; } diff --git a/src/migration/1766760828376-add_field_dnaid_and_prodileid.ts b/src/migration/1766760828376-add_field_dnaid_and_prodileid.ts new file mode 100644 index 00000000..28ceec51 --- /dev/null +++ b/src/migration/1766760828376-add_field_dnaid_and_prodileid.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddFieldDnaidAndProdileid1766760828376 implements MigrationInterface { + name = 'AddFieldDnaidAndProdileid1766760828376' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`rootDnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgRoot'`); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child1DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild1'`); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child2DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild2'`); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child3DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild3'`); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child4DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild4'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child4DnaId\``); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child3DnaId\``); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child2DnaId\``); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child1DnaId\``); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`rootDnaId\``); + await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`profileId\``); + } + +} \ No newline at end of file