From 3db9258e1be07fbf1b0e39d1c7e525d613957283 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 31 Jan 2025 18:04:19 +0700 Subject: [PATCH] add dna --- src/controllers/KpiPlanController.ts | 10 +++++ src/controllers/KpiRoleController.ts | 15 ++++++- src/entities/kpiPlan.ts | 35 ++++++++++++++++ src/entities/kpiRole.ts | 35 ++++++++++++++++ src/entities/kpiUserEvaluation.ts | 40 ++++++++++++++++++ .../1738321374131-updateroleadddna.ts | 42 +++++++++++++++++++ 6 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 src/migration/1738321374131-updateroleadddna.ts diff --git a/src/controllers/KpiPlanController.ts b/src/controllers/KpiPlanController.ts index 59afe58..9d468dc 100644 --- a/src/controllers/KpiPlanController.ts +++ b/src/controllers/KpiPlanController.ts @@ -79,18 +79,23 @@ export class kpiPlanController extends Controller { .then((x) => { kpiPlan.root = x.root; kpiPlan.rootId = x.rootId; + kpiPlan.rootDnaId = x.rootDnaId; kpiPlan.rootShortName = x.rootShortName; kpiPlan.child1 = requestBody.node <= 0 ? null : x.child1; kpiPlan.child1Id = requestBody.node <= 0 ? null : x.child1Id; + kpiPlan.child1DnaId = requestBody.node <= 0 ? null : x.child1DnaId; kpiPlan.child1ShortName = requestBody.node <= 0 ? null : x.child1ShortName; kpiPlan.child2 = requestBody.node <= 1 ? null : x.child2; kpiPlan.child2Id = requestBody.node <= 1 ? null : x.child2Id; + kpiPlan.child2DnaId = requestBody.node <= 1 ? null : x.child2DnaId; kpiPlan.child2ShortName = requestBody.node <= 1 ? null : x.child2ShortName; kpiPlan.child3 = requestBody.node <= 2 ? null : x.child3; kpiPlan.child3Id = requestBody.node <= 2 ? null : x.child3Id; + kpiPlan.child3DnaId = requestBody.node <= 2 ? null : x.child3DnaId; kpiPlan.child3ShortName = requestBody.node <= 2 ? null : x.child3ShortName; kpiPlan.child4 = requestBody.node <= 3 ? null : x.child4; kpiPlan.child4Id = requestBody.node <= 3 ? null : x.child4Id; + kpiPlan.child4DnaId = requestBody.node <= 3 ? null : x.child4DnaId; kpiPlan.child4ShortName = requestBody.node <= 3 ? null : x.child4ShortName; }) .catch((x) => {}); @@ -250,18 +255,23 @@ export class kpiPlanController extends Controller { .then((x) => { kpiPlan.root = x.root; kpiPlan.rootId = x.rootId; + kpiPlan.rootDnaId = x.rootDnaId; kpiPlan.rootShortName = x.rootShortName; kpiPlan.child1 = requestBody.node <= 0 ? null : x.child1; kpiPlan.child1Id = requestBody.node <= 0 ? null : x.child1Id; + kpiPlan.child1DnaId = requestBody.node <= 0 ? null : x.child1DnaId; kpiPlan.child1ShortName = requestBody.node <= 0 ? null : x.child1ShortName; kpiPlan.child2 = requestBody.node <= 1 ? null : x.child2; kpiPlan.child2Id = requestBody.node <= 1 ? null : x.child2Id; + kpiPlan.child2DnaId = requestBody.node <= 1 ? null : x.child2DnaId; kpiPlan.child2ShortName = requestBody.node <= 1 ? null : x.child2ShortName; kpiPlan.child3 = requestBody.node <= 2 ? null : x.child3; kpiPlan.child3Id = requestBody.node <= 2 ? null : x.child3Id; + kpiPlan.child3DnaId = requestBody.node <= 2 ? null : x.child3DnaId; kpiPlan.child3ShortName = requestBody.node <= 2 ? null : x.child3ShortName; kpiPlan.child4 = requestBody.node <= 3 ? null : x.child4; kpiPlan.child4Id = requestBody.node <= 3 ? null : x.child4Id; + kpiPlan.child4DnaId = requestBody.node <= 3 ? null : x.child4DnaId; kpiPlan.child4ShortName = requestBody.node <= 3 ? null : x.child4ShortName; }) .catch((x) => {}); diff --git a/src/controllers/KpiRoleController.ts b/src/controllers/KpiRoleController.ts index 7722647..01134d4 100644 --- a/src/controllers/KpiRoleController.ts +++ b/src/controllers/KpiRoleController.ts @@ -53,7 +53,10 @@ export class kpiRoleController extends Controller { .where("kpiPeriod.year = :year", { year: requestBody.year }) .andWhere("kpiPeriod.durationKPI = :durationKPI", { durationKPI: requestBody.period }) .getOne(); - const year = requestBody.year && parseInt(requestBody.year) > 0?parseInt(requestBody.year) + 543:"ดังกล่าว"; + const year = + requestBody.year && parseInt(requestBody.year) > 0 + ? parseInt(requestBody.year) + 543 + : "ดังกล่าว"; if (!kpiPeriod) { throw new HttpError( HttpStatusCode.NOT_FOUND, @@ -69,18 +72,23 @@ export class kpiRoleController extends Controller { .then((x) => { kpiRole.root = x.root; kpiRole.rootId = x.rootId; + kpiRole.rootDnaId = x.rootDnaId; kpiRole.rootShortName = x.rootShortName; kpiRole.child1 = requestBody.node <= 0 ? null : x.child1; kpiRole.child1Id = requestBody.node <= 0 ? null : x.child1Id; + kpiRole.child1DnaId = requestBody.node <= 0 ? null : x.child1DnaId; kpiRole.child1ShortName = requestBody.node <= 0 ? null : x.child1ShortName; kpiRole.child2 = requestBody.node <= 1 ? null : x.child2; kpiRole.child2Id = requestBody.node <= 1 ? null : x.child2Id; + kpiRole.child2DnaId = requestBody.node <= 1 ? null : x.child2DnaId; kpiRole.child2ShortName = requestBody.node <= 1 ? null : x.child2ShortName; kpiRole.child3 = requestBody.node <= 2 ? null : x.child3; kpiRole.child3Id = requestBody.node <= 2 ? null : x.child3Id; + kpiRole.child3DnaId = requestBody.node <= 2 ? null : x.child3DnaId; kpiRole.child3ShortName = requestBody.node <= 2 ? null : x.child3ShortName; kpiRole.child4 = requestBody.node <= 3 ? null : x.child4; kpiRole.child4Id = requestBody.node <= 3 ? null : x.child4Id; + kpiRole.child4DnaId = requestBody.node <= 3 ? null : x.child4DnaId; kpiRole.child4ShortName = requestBody.node <= 3 ? null : x.child4ShortName; }) .catch((x) => {}); @@ -238,18 +246,23 @@ export class kpiRoleController extends Controller { .then((x) => { kpiRole.root = x.root; kpiRole.rootId = x.rootId; + kpiRole.rootDnaId = x.rootDnaId; kpiRole.rootShortName = x.rootShortName; kpiRole.child1 = requestBody.node <= 0 ? null : x.child1; kpiRole.child1Id = requestBody.node <= 0 ? null : x.child1Id; + kpiRole.child1DnaId = requestBody.node <= 0 ? null : x.child1DnaId; kpiRole.child1ShortName = requestBody.node <= 0 ? null : x.child1ShortName; kpiRole.child2 = requestBody.node <= 1 ? null : x.child2; kpiRole.child2Id = requestBody.node <= 1 ? null : x.child2Id; + kpiRole.child2DnaId = requestBody.node <= 1 ? null : x.child2DnaId; kpiRole.child2ShortName = requestBody.node <= 1 ? null : x.child2ShortName; kpiRole.child3 = requestBody.node <= 2 ? null : x.child3; kpiRole.child3Id = requestBody.node <= 2 ? null : x.child3Id; + kpiRole.child3DnaId = requestBody.node <= 2 ? null : x.child3DnaId; kpiRole.child3ShortName = requestBody.node <= 2 ? null : x.child3ShortName; kpiRole.child4 = requestBody.node <= 3 ? null : x.child4; kpiRole.child4Id = requestBody.node <= 3 ? null : x.child4Id; + kpiRole.child4DnaId = requestBody.node <= 3 ? null : x.child4DnaId; kpiRole.child4ShortName = requestBody.node <= 3 ? null : x.child4ShortName; }) .catch((x) => {}); diff --git a/src/entities/kpiPlan.ts b/src/entities/kpiPlan.ts index e29ec4c..5ac26a8 100644 --- a/src/entities/kpiPlan.ts +++ b/src/entities/kpiPlan.ts @@ -112,6 +112,13 @@ export class KpiPlan extends EntityBase { }) rootId: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน", + default: null, + }) + rootDnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน", @@ -133,6 +140,13 @@ export class KpiPlan extends EntityBase { }) child1Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child1", + default: null, + }) + child1DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child1", @@ -154,6 +168,13 @@ export class KpiPlan extends EntityBase { }) child2Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child2", + default: null, + }) + child2DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child2", @@ -175,6 +196,13 @@ export class KpiPlan extends EntityBase { }) child3Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child3", + default: null, + }) + child3DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child3", @@ -196,6 +224,13 @@ export class KpiPlan extends EntityBase { }) child4Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child4", + default: null, + }) + child4DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child4", diff --git a/src/entities/kpiRole.ts b/src/entities/kpiRole.ts index caa76a0..464799e 100644 --- a/src/entities/kpiRole.ts +++ b/src/entities/kpiRole.ts @@ -104,6 +104,13 @@ export class KpiRole extends EntityBase { }) rootId: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน", + default: null, + }) + rootDnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน", @@ -125,6 +132,13 @@ export class KpiRole extends EntityBase { }) child1Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child1", + default: null, + }) + child1DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child1", @@ -146,6 +160,13 @@ export class KpiRole extends EntityBase { }) child2Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child2", + default: null, + }) + child2DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child2", @@ -167,6 +188,13 @@ export class KpiRole extends EntityBase { }) child3Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child3", + default: null, + }) + child3DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child3", @@ -188,6 +216,13 @@ export class KpiRole extends EntityBase { }) child4Id: string; + @Column({ + nullable: true, + comment: "id Dna หน่วยงาน child4", + default: null, + }) + child4DnaId: string; + @Column({ nullable: true, comment: "ชื่อหน่วยงาน child4", diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index 1541141..2d7bad7 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -82,6 +82,14 @@ export class KpiUserEvaluation extends EntityBase { }) orgId: string; + @Column({ + nullable: true, + comment: "สังกัดDna", + length: 255, + default: null, + }) + orgDnaId: string; + @Column({ nullable: true, comment: "child1", @@ -98,6 +106,14 @@ export class KpiUserEvaluation extends EntityBase { }) child1Id: string; + @Column({ + nullable: true, + comment: "child1Dna", + length: 255, + default: null, + }) + child1DnaId: string; + @Column({ nullable: true, comment: "child2", @@ -114,6 +130,14 @@ export class KpiUserEvaluation extends EntityBase { }) child2Id: string; + @Column({ + nullable: true, + comment: "child2Dna", + length: 255, + default: null, + }) + child2DnaId: string; + @Column({ nullable: true, comment: "child3", @@ -130,6 +154,14 @@ export class KpiUserEvaluation extends EntityBase { }) child3Id: string; + @Column({ + nullable: true, + comment: "child3Dna", + length: 255, + default: null, + }) + child3DnaId: string; + @Column({ nullable: true, comment: "child4", @@ -146,6 +178,14 @@ export class KpiUserEvaluation extends EntityBase { }) child4Id: string; + @Column({ + nullable: true, + comment: "child4 Dna", + length: 255, + default: null, + }) + child4DnaId: string; + @Column({ nullable: true, comment: "คำนำหน้าผู้ประเมิน", diff --git a/src/migration/1738321374131-updateroleadddna.ts b/src/migration/1738321374131-updateroleadddna.ts new file mode 100644 index 0000000..42786fe --- /dev/null +++ b/src/migration/1738321374131-updateroleadddna.ts @@ -0,0 +1,42 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class Updateroleadddna1738321374131 implements MigrationInterface { + name = 'Updateroleadddna1738321374131' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiPlan\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` ADD \`child1DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child1'`); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` ADD \`child2DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child2'`); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` ADD \`child3DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child3'`); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` ADD \`child4DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child4'`); + await queryRunner.query(`ALTER TABLE \`kpiRole\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`kpiRole\` ADD \`child1DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child1'`); + await queryRunner.query(`ALTER TABLE \`kpiRole\` ADD \`child2DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child2'`); + await queryRunner.query(`ALTER TABLE \`kpiRole\` ADD \`child3DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child3'`); + await queryRunner.query(`ALTER TABLE \`kpiRole\` ADD \`child4DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child4'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`orgDnaId\` varchar(255) NULL COMMENT 'สังกัดDna'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`child1DnaId\` varchar(255) NULL COMMENT 'child1Dna'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`child2DnaId\` varchar(255) NULL COMMENT 'child2Dna'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`child3DnaId\` varchar(255) NULL COMMENT 'child3Dna'`); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`child4DnaId\` varchar(255) NULL COMMENT 'child4 Dna'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`child4DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`child3DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`child2DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`child1DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`orgDnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiRole\` DROP COLUMN \`child4DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiRole\` DROP COLUMN \`child3DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiRole\` DROP COLUMN \`child2DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiRole\` DROP COLUMN \`child1DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiRole\` DROP COLUMN \`rootDnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` DROP COLUMN \`child4DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` DROP COLUMN \`child3DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` DROP COLUMN \`child2DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` DROP COLUMN \`child1DnaId\``); + await queryRunner.query(`ALTER TABLE \`kpiPlan\` DROP COLUMN \`rootDnaId\``); + } + +}