diff --git a/src/entities/kpiPeriod.ts b/src/entities/kpiPeriod.ts index bc177ff..a72fc13 100644 --- a/src/entities/kpiPeriod.ts +++ b/src/entities/kpiPeriod.ts @@ -3,7 +3,6 @@ import { EntityBase } from "./base/Base"; import { KpiPlan } from "./kpiPlan"; import { KpiRole } from "./kpiRole"; import { KpiUserEvaluation } from "./kpiUserEvaluation"; -import { KpiSpecial } from "./kpiSpecial"; @Entity("kpiPeriod") export class KpiPeriod extends EntityBase { @@ -48,9 +47,6 @@ export class KpiPeriod extends EntityBase { @OneToMany(() => KpiPlan, (kpiPlan) => kpiPlan.kpiPeriod) kpiPlans: KpiPlan[]; - @OneToMany(() => KpiSpecial, (kpiSpecial) => kpiSpecial.kpiPeriod) - kpiSpecials: KpiSpecial[]; - @OneToMany(() => KpiUserEvaluation, (kpiPlan) => kpiPlan.kpiPeriod) kpiUserEvaluations: KpiUserEvaluation[]; } diff --git a/src/entities/kpiSpecial.ts b/src/entities/kpiSpecial.ts deleted file mode 100644 index 714a825..0000000 --- a/src/entities/kpiSpecial.ts +++ /dev/null @@ -1,371 +0,0 @@ -import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { KpiLink } from "./kpiLink"; -import { KpiPeriod } from "./kpiPeriod"; -import { KpiUserSpecial } from "./kpiUserSpecial"; - -@Entity("kpiSpecial") -export class KpiSpecial extends EntityBase { - @Column({ - nullable: true, - comment: "รหัสตัวชี้วัด", - default: null, - }) - including: string; - - @Column({ - nullable: true, - comment: "ชื่อตัวชี้วัด", - default: null, - }) - includingName: string; - - @Column({ - nullable: true, - comment: "ค่าเป้าหมาย", - default: null, - }) - target: string; - - @Column({ - nullable: true, - comment: "หน่วยนับ", - default: null, - }) - unit: number; - - @Column({ - nullable: true, - comment: "น้ำหนัก", - default: null, - }) - weight: number; - - @Column({ - nullable: true, - comment: "ผลสำเร็จของงาน 1", - default: null, - }) - achievement1: string; - - @Column({ - nullable: true, - comment: "ผลสำเร็จของงาน 2", - default: null, - }) - achievement2: string; - - @Column({ - nullable: true, - comment: "ผลสำเร็จของงาน 3", - default: null, - }) - achievement3: string; - - @Column({ - nullable: true, - comment: "ผลสำเร็จของงาน 4", - default: null, - }) - achievement4: string; - - @Column({ - nullable: true, - comment: "ผลสำเร็จของงาน 5", - default: null, - }) - achievement5: string; - - @Column({ - nullable: true, - comment: "นิยามหรือความหมาย", - default: null, - }) - meaning: string; - - @Column({ - nullable: true, - comment: "สูตรคำนวณ", - default: null, - }) - formula: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน", - default: null, - }) - rootId: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน", - default: null, - }) - root: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน", - default: null, - }) - rootShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child1", - default: null, - }) - child1Id: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child1", - default: null, - }) - child1: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child1", - default: null, - }) - child1ShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child2", - default: null, - }) - child2Id: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child2", - default: null, - }) - child2: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child2", - default: null, - }) - child2ShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child3", - default: null, - }) - child3Id: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child3", - default: null, - }) - child3: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child3", - default: null, - }) - child3ShortName: string; - - @Column({ - nullable: true, - comment: "id หน่วยงาน child4", - default: null, - }) - child4Id: string; - - @Column({ - nullable: true, - comment: "ชื่อหน่วยงาน child4", - default: null, - }) - child4: string; - - @Column({ - nullable: true, - comment: "ชื่อย่อหน่วยงาน child4", - default: null, - }) - child4ShortName: string; - - @Column({ - nullable: true, - comment: "id revision", - default: null, - }) - orgRevisionId: string; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild1", - default: null, - }) - strategyChild1Id: string; - - @Column({ - nullable: true, - comment: "ชื่อ strategyChild1", - default: null, - }) - strategyChild1: string; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild2", - default: null, - }) - strategyChild2Id: string; - - @Column({ - nullable: true, - comment: "ชื่อ strategyChild2", - default: null, - }) - strategyChild2: string; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild3", - default: null, - }) - strategyChild3Id: string; - - @Column({ - nullable: true, - comment: "ชื่อ strategyChild3", - default: null, - }) - strategyChild3: string; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild4", - default: null, - }) - strategyChild4Id: string; - - @Column({ - nullable: true, - comment: "ชื่อ strategyChild4", - default: null, - }) - strategyChild4: string; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง strategyChild5", - default: null, - }) - strategyChild5Id: string; - - @Column({ - nullable: true, - comment: "ชื่อ strategyChild5", - default: null, - }) - strategyChild5: string; - - @Column({ - nullable: true, - length: 40, - comment: "ไอดีรอบ", - default: null, - }) - kpiPeriodId: string | null; - - @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiSpecials) - @JoinColumn({ name: "kpiPeriodId" }) - kpiPeriod: KpiPeriod; - - @OneToMany(() => KpiUserSpecial, (kpiUserSpecial) => kpiUserSpecial.kpiSpecial) - kpiUserSpecials: KpiUserSpecial[]; -} -export class createKpiSpecial { - @Column() - including: string | null; - @Column() - includingName: string | null; - @Column() - target: string | null; - @Column() - unit: number | null; - @Column() - weight: number | null; - @Column() - achievement1: string | null; - @Column() - achievement2: string | null; - @Column() - achievement3: string | null; - @Column() - achievement4: string | null; - @Column() - achievement5: string | null; - @Column() - meaning: string | null; - @Column() - formula: string | null; - @Column() - node: number; - @Column() - nodeId: string | null; - @Column() - orgRevisionId: string; - @Column() - strategy: number; - @Column() - strategyId: string | null; - @Column() - kpiPeriodId: string | null; -} - -export class updateKpiSpecial { - @Column() - including: string | null; - @Column() - includingName: string | null; - @Column() - target: string | null; - @Column() - unit: number | null; - @Column() - weight: number | null; - @Column() - achievement1: string | null; - @Column() - achievement2: string | null; - @Column() - achievement3: string | null; - @Column() - achievement4: string | null; - @Column() - achievement5: string | null; - @Column() - meaning: string | null; - @Column() - formula: string | null; - @Column() - node: number; - @Column() - nodeId: string | null; - @Column() - orgRevisionId: string; - @Column() - strategy: number; - @Column() - strategyId: string | null; - @Column() - kpiPeriodId: string | null; -} diff --git a/src/entities/kpiUserSpecial.ts b/src/entities/kpiUserSpecial.ts index 4834218..6aee45d 100644 --- a/src/entities/kpiUserSpecial.ts +++ b/src/entities/kpiUserSpecial.ts @@ -1,10 +1,23 @@ import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiUserEvaluation } from "./kpiUserEvaluation"; -import { KpiSpecial } from "./kpiSpecial"; @Entity("kpiUserSpecial") export class KpiUserSpecial extends EntityBase { + @Column({ + nullable: true, + comment: "รหัสตัวชี้วัด", + default: null, + }) + including: string; + + @Column({ + nullable: true, + comment: "ชื่อตัวชี้วัด", + default: null, + }) + includingName: string; + @Column({ nullable: true, comment: "ค่าเป้าหมาย", @@ -26,6 +39,63 @@ export class KpiUserSpecial extends EntityBase { }) weight: number; + @Column({ + nullable: true, + comment: "ระดับที่คาดหวัง", + default: null, + }) + level: string; + + @Column({ + nullable: true, + comment: "ระดับคะแนน", + default: null, + }) + point: number; + + @Column({ + type: "double", + nullable: true, + default: null, + comment: "ผลการประเมิน", + }) + summary: number; + + @Column({ + nullable: true, + comment: "ผลสำเร็จของงาน 1", + default: null, + }) + achievement1: string; + + @Column({ + nullable: true, + comment: "ผลสำเร็จของงาน 2", + default: null, + }) + achievement2: string; + + @Column({ + nullable: true, + comment: "ผลสำเร็จของงาน 3", + default: null, + }) + achievement3: string; + + @Column({ + nullable: true, + comment: "ผลสำเร็จของงาน 4", + default: null, + }) + achievement4: string; + + @Column({ + nullable: true, + comment: "ผลสำเร็จของงาน 5", + default: null, + }) + achievement5: string; + @Column({ nullable: true, comment: "นิยามหรือความหมาย", @@ -51,16 +121,4 @@ export class KpiUserSpecial extends EntityBase { @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserSpecials) @JoinColumn({ name: "kpiUserEvaluationId" }) kpiUserEvaluation: KpiUserEvaluation; - - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง kpiSpecial", - default: null, - }) - kpiSpecialId: string; - - @ManyToOne(() => KpiSpecial, (kpiSpecial) => kpiSpecial.kpiUserSpecials) - @JoinColumn({ name: "kpiSpecialId" }) - kpiSpecial: KpiSpecial; } diff --git a/src/migration/1713862233571-update_table_kpiuserspecial_add_including.ts b/src/migration/1713862233571-update_table_kpiuserspecial_add_including.ts new file mode 100644 index 0000000..4a02ca5 --- /dev/null +++ b/src/migration/1713862233571-update_table_kpiuserspecial_add_including.ts @@ -0,0 +1,36 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableKpiuserspecialAddIncluding1713862233571 implements MigrationInterface { + name = 'UpdateTableKpiuserspecialAddIncluding1713862233571' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP FOREIGN KEY \`FK_d532eaa10d76a882a18282dae18\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`kpiSpecialId\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`including\` varchar(255) NULL COMMENT 'รหัสตัวชี้วัด'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`includingName\` varchar(255) NULL COMMENT 'ชื่อตัวชี้วัด'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`level\` varchar(255) NULL COMMENT 'ระดับที่คาดหวัง'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`point\` int NULL COMMENT 'ระดับคะแนน'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`summary\` double NULL COMMENT 'ผลการประเมิน'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`achievement1\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 1'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`achievement2\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 2'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`achievement3\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 3'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`achievement4\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 4'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`achievement5\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 5'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`achievement5\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`achievement4\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`achievement3\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`achievement2\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`achievement1\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`summary\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`point\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`level\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`includingName\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` DROP COLUMN \`including\``); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD \`kpiSpecialId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง kpiSpecial'`); + await queryRunner.query(`ALTER TABLE \`kpiUserSpecial\` ADD CONSTRAINT \`FK_d532eaa10d76a882a18282dae18\` FOREIGN KEY (\`kpiSpecialId\`) REFERENCES \`kpiSpecial\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + +}