diff --git a/src/entities/kpiSpecial.ts b/src/entities/kpiSpecial.ts new file mode 100644 index 0000000..f1c2ba1 --- /dev/null +++ b/src/entities/kpiSpecial.ts @@ -0,0 +1,187 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; + +@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: "ระดับที่คาดหวัง", + 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: "นิยามหรือความหมาย", + default: null, + }) + meaning: string; + + @Column({ + nullable: true, + comment: "สูตรคำนวณ", + default: null, + }) + formula: string; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", + default: null, + }) + kpiUserEvaluationId: string; + + @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserSpecials) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluation: KpiUserEvaluation; +} + +export class CreateKpiUserSpecial { + @Column() + including: string | null; + @Column() + includingName: string | null; + @Column() + achievement1: string | null; + @Column() + achievement2: string | null; + @Column() + achievement3: string | null; + @Column() + achievement4: string | null; + @Column() + achievement5: string | null; + @Column() + target: string; + @Column() + unit: number; + @Column() + weight: number; + @Column() + meaning: string; + @Column() + formula: string; + @Column("uuid") + kpiUserEvaluationId: string; +} + +export class UpdateKpiUserSpecial { + @Column() + including: string | null; + @Column() + includingName: string | null; + @Column() + achievement1: string | null; + @Column() + achievement2: string | null; + @Column() + achievement3: string | null; + @Column() + achievement4: string | null; + @Column() + achievement5: string | null; + @Column() + target: string; + @Column() + unit: number; + @Column() + weight: number; + @Column() + meaning: string; + @Column() + formula: string; + @Column("uuid") + kpiUserEvaluationId: string; +} + +export class KpiUserSpecialDataPoint { + id: string; + point: number; +} diff --git a/src/entities/kpiUserPlanned.ts b/src/entities/kpiUserPlanned.ts index 82fa670..52e6f3b 100644 --- a/src/entities/kpiUserPlanned.ts +++ b/src/entities/kpiUserPlanned.ts @@ -101,6 +101,41 @@ export class KpiUserPlanned extends EntityBase { default: null, }) endDate: Date; + + @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; } export class CreateKpiUserPlanned { diff --git a/src/entities/kpiUserRole.ts b/src/entities/kpiUserRole.ts index 9704338..f4895c9 100644 --- a/src/entities/kpiUserRole.ts +++ b/src/entities/kpiUserRole.ts @@ -102,6 +102,41 @@ export class KpiUserRole extends EntityBase { default: null, }) endDate: Date; + + @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; } export class CreateKpiUserRole { diff --git a/src/migration/1715137390916-update_table_kpiPlan_add_achievement1.ts b/src/migration/1715137390916-update_table_kpiPlan_add_achievement1.ts new file mode 100644 index 0000000..3037c17 --- /dev/null +++ b/src/migration/1715137390916-update_table_kpiPlan_add_achievement1.ts @@ -0,0 +1,36 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableKpiPlanAddAchievement11715137390916 implements MigrationInterface { + name = 'UpdateTableKpiPlanAddAchievement11715137390916' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`kpiSpecial\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`including\` varchar(255) NULL COMMENT 'รหัสตัวชี้วัด', \`includingName\` varchar(255) NULL COMMENT 'ชื่อตัวชี้วัด', \`target\` varchar(255) NULL COMMENT 'ค่าเป้าหมาย', \`unit\` int NULL COMMENT 'หน่วยนับ', \`weight\` int NULL COMMENT 'น้ำหนัก', \`level\` varchar(255) NULL COMMENT 'ระดับที่คาดหวัง', \`point\` int NULL COMMENT 'ระดับคะแนน', \`summary\` double NULL COMMENT 'ผลการประเมิน', \`achievement1\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 1', \`achievement2\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 2', \`achievement3\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 3', \`achievement4\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 4', \`achievement5\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 5', \`meaning\` varchar(255) NULL COMMENT 'นิยามหรือความหมาย', \`formula\` varchar(255) NULL COMMENT 'สูตรคำนวณ', \`kpiUserEvaluationId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง kpiUserEvaluation', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`achievement1\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 1'`); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`achievement2\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 2'`); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`achievement3\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 3'`); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`achievement4\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 4'`); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`achievement5\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 5'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`achievement1\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 1'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`achievement2\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 2'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`achievement3\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 3'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`achievement4\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 4'`); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`achievement5\` varchar(255) NULL COMMENT 'ผลสำเร็จของงาน 5'`); + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` ADD CONSTRAINT \`FK_10065ab86a67156f5dc6731f79e\` FOREIGN KEY (\`kpiUserEvaluationId\`) REFERENCES \`kpiUserEvaluation\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`kpiSpecial\` DROP FOREIGN KEY \`FK_10065ab86a67156f5dc6731f79e\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`achievement5\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`achievement4\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`achievement3\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`achievement2\``); + await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`achievement1\``); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`achievement5\``); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`achievement4\``); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`achievement3\``); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`achievement2\``); + await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`achievement1\``); + await queryRunner.query(`DROP TABLE \`kpiSpecial\``); + } + +}