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; }