From 4f54040982d3166bc71942d8591c60abc60a9aa5 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Fri, 19 Apr 2024 17:35:36 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=A3=E0=B8=AD=E0=B8=9A=E0=B9=83=E0=B8=99=E0=B9=81=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B9=81=E0=B8=9C=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/kpiPeriod.ts | 10 +++++++++- src/entities/kpiPlan.ts | 19 ++++++++++++++++++- src/entities/kpiRole.ts | 19 ++++++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/entities/kpiPeriod.ts b/src/entities/kpiPeriod.ts index 1711afe..2e02ada 100644 --- a/src/entities/kpiPeriod.ts +++ b/src/entities/kpiPeriod.ts @@ -1,5 +1,7 @@ -import { Entity, Column } from "typeorm"; +import { Entity, Column, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; +import { KpiPlan } from "./kpiPlan"; +import { KpiRole } from "./kpiRole"; @Entity("kpiPeriod") export class KpiPeriod extends EntityBase { @@ -37,6 +39,12 @@ export class KpiPeriod extends EntityBase { default: true, }) isActive: boolean; + + @OneToMany(() => KpiRole, (kpiRole) => kpiRole.kpiPeriod) + kpiRoles: KpiRole[]; + + @OneToMany(() => KpiPlan, (kpiPlan) => kpiPlan.kpiPeriod) + kpiPlans: KpiPlan[]; } export class createKpiPeriod { @Column() diff --git a/src/entities/kpiPlan.ts b/src/entities/kpiPlan.ts index 649564b..0f5c6ea 100644 --- a/src/entities/kpiPlan.ts +++ b/src/entities/kpiPlan.ts @@ -1,6 +1,7 @@ -import { Entity, Column, OneToMany } from "typeorm"; +import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiLink } from "./kpiLink"; +import { KpiPeriod } from "./kpiPeriod"; @Entity("kpiPlan") export class KpiPlan extends EntityBase { @@ -287,6 +288,18 @@ export class KpiPlan extends EntityBase { default: null, }) strategyChild5: string; + + @Column({ + nullable: true, + length: 40, + comment: "ไอดีรอบ", + default: null, + }) + kpiPeriodId: string | null; + + @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiPlans) + @JoinColumn({ name: "kpiPeriodId" }) + kpiPeriod: KpiPeriod; } export class createKpiPlan { @Column() @@ -327,6 +340,8 @@ export class createKpiPlan { strategy: number; @Column() strategyId: string | null; + @Column() + kpiPeriodId: string | null; } export class updateKpiPlan { @@ -368,4 +383,6 @@ export class updateKpiPlan { strategy: number; @Column() strategyId: string | null; + @Column() + kpiPeriodId: string | null; } diff --git a/src/entities/kpiRole.ts b/src/entities/kpiRole.ts index e548ad5..d644fa5 100644 --- a/src/entities/kpiRole.ts +++ b/src/entities/kpiRole.ts @@ -1,6 +1,7 @@ -import { Entity, Column, OneToMany } from "typeorm"; +import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiLink } from "./kpiLink"; +import { KpiPeriod } from "./kpiPeriod"; @Entity("kpiRole") export class KpiRole extends EntityBase { @@ -219,6 +220,18 @@ export class KpiRole extends EntityBase { default: null, }) formula: string; + + @Column({ + nullable: true, + length: 40, + comment: "ไอดีรอบ", + default: null, + }) + kpiPeriodId: string | null; + + @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiRoles) + @JoinColumn({ name: "kpiPeriodId" }) + kpiPeriod: KpiPeriod; } export class createKpiRole { @Column() @@ -257,6 +270,8 @@ export class createKpiRole { meaning: string | null; @Column() formula: string | null; + @Column() + kpiPeriodId: string | null; } export class updateKpiRole { @@ -296,4 +311,6 @@ export class updateKpiRole { meaning: string | null; @Column() formula: string | null; + @Column() + kpiPeriodId: string | null; }