From fae8d38013c5600e93c9425b0a5d1f0018bf5d26 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Mon, 22 Apr 2024 15:50:04 +0700 Subject: [PATCH] =?UTF-8?q?er=20=E0=B8=9D=E0=B8=B1=E0=B9=88=E0=B8=87=20use?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/KpiCapacityController.ts | 135 +++++---- src/entities/kpiCapacity.ts | 33 +- src/entities/kpiCapacityDetail.ts | 3 +- src/entities/kpiPeriod.ts | 6 +- src/entities/kpiPlan.ts | 4 + src/entities/kpiRole.ts | 5 +- src/entities/kpiSpecial.ts | 371 +++++++++++++++++++++++ src/entities/kpiUserDirector.ts | 31 ++ src/entities/kpiUserEvaluation.ts | 32 ++ src/entities/kpiUserExecutive.ts | 31 ++ src/entities/kpiUserGroup.ts | 31 ++ src/entities/kpiUserHead.ts | 31 ++ src/entities/kpiUserInspector.ts | 31 ++ src/entities/kpiUserPlanned.ts | 66 ++++ src/entities/kpiUserRole.ts | 66 ++++ src/entities/kpiUserSpecial.ts | 66 ++++ 16 files changed, 870 insertions(+), 72 deletions(-) create mode 100644 src/entities/kpiSpecial.ts create mode 100644 src/entities/kpiUserDirector.ts create mode 100644 src/entities/kpiUserExecutive.ts create mode 100644 src/entities/kpiUserGroup.ts create mode 100644 src/entities/kpiUserHead.ts create mode 100644 src/entities/kpiUserInspector.ts create mode 100644 src/entities/kpiUserPlanned.ts create mode 100644 src/entities/kpiUserRole.ts create mode 100644 src/entities/kpiUserSpecial.ts diff --git a/src/controllers/KpiCapacityController.ts b/src/controllers/KpiCapacityController.ts index 1d37e27..cb2b1ea 100644 --- a/src/controllers/KpiCapacityController.ts +++ b/src/controllers/KpiCapacityController.ts @@ -14,14 +14,18 @@ import { SuccessResponse, Response, Query, - ArrayValidator + ArrayValidator, } from "tsoa"; import { AppDataSource } from "../database/data-source"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatusCode from "../interfaces/http-status"; import { KpiCapacity, createKpiCapacity, updateKpiCapacity } from "../entities/kpiCapacity"; -import { KpiCapacityDetail, createKpiCapacityDetail, updateKpiCapacityDetail } from "../entities/kpiCapacityDetail"; +import { + KpiCapacityDetail, + createKpiCapacityDetail, + updateKpiCapacityDetail, +} from "../entities/kpiCapacityDetail"; import { Like, In } from "typeorm"; @Route("api/v1/kpi/capacity") @@ -38,36 +42,39 @@ export class kpiCapacityController extends Controller { /** * API สร้างรายการสมรรถนะ - * + * * @summary สร้างรายการสมรรถนะ - * + * */ @Post() @Example({ type: "HEAD", name: "ชื่อสมรรถนะ", description: "คำจำกัดความ", - kpiCapacityDetails: [{ - level: "ระดับ", - description: "คำอธิบายระดับ" - }] + kpiCapacityDetails: [ + { + level: "ระดับ", + description: "คำอธิบายระดับ", + }, + ], }) async createKpiCapacity( - @Body() requestBody: { - type: string - name: string - description: string + @Body() + requestBody: { + type: string; + name: string; + description: string; capacityDetails: { level: string; description: string; }[]; }, @Request() request: { user: Record }, - ){ + ) { const kpiCapacity = Object.assign(new KpiCapacity(), { type: requestBody.type, name: requestBody.name, - description: requestBody.description + description: requestBody.description, }); kpiCapacity.createdUserId = request.user.sub; kpiCapacity.createdFullName = request.user.name; @@ -77,12 +84,13 @@ export class kpiCapacityController extends Controller { let idx: number = 0; for (const data of requestBody.capacityDetails) { - idx += 1 - let _level = (kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP") ? idx.toString() : data.level; + idx += 1; + let _level = + kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP" ? idx.toString() : data.level; const kpiCapacityDetail = Object.assign(new KpiCapacityDetail(), { level: _level, description: data.description, - kpiCapacityId: kpiCapacity.id + kpiCapacityId: kpiCapacity.id, }); kpiCapacityDetail.createdUserId = request.user.sub; kpiCapacityDetail.createdFullName = request.user.name; @@ -91,14 +99,14 @@ export class kpiCapacityController extends Controller { await this.kpiCapacityDetailRepository.save(kpiCapacityDetail); } - return new HttpSuccess(kpiCapacity.id) + return new HttpSuccess(kpiCapacity.id); } /** * API แก้ไขรายการสมรรถนะ - * + * * @summary แก้ไขรายการสมรรถนะ - * + * * @param {string} id Guid, *Id รายการสมรรถนะ */ @Put("{id}") @@ -106,19 +114,22 @@ export class kpiCapacityController extends Controller { type: "HEAD", name: "ชื่อสมรรถนะ", description: "คำจำกัดความ", - kpiCapacityDetails: [{ - level: "ระดับ", - description: "คำอธิบายระดับ" - }] + kpiCapacityDetails: [ + { + level: "ระดับ", + description: "คำอธิบายระดับ", + }, + ], }) async updateKpiCapacity( @Path() id: string, - @Body() requestBody: { - type: string - name: string - description: string + @Body() + requestBody: { + type: string; + name: string; + description: string; capacityDetails: { - level: string + level: string; description: string; }[]; }, @@ -128,15 +139,12 @@ export class kpiCapacityController extends Controller { where: { id: id }, }); if (!kpiCapacity) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลรายการสมรรถนะนี้", - ); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายการสมรรถนะนี้"); } const _kpiCapacity = Object.assign(new KpiCapacity(), { type: requestBody.type, name: requestBody.name, - description: requestBody.description + description: requestBody.description, }); kpiCapacity.lastUpdateUserId = request.user.sub; kpiCapacity.lastUpdateFullName = request.user.name; @@ -150,12 +158,13 @@ export class kpiCapacityController extends Controller { let idx: number = 0; for (const data of requestBody.capacityDetails) { - idx += 1 - let _level = (kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP") ? idx.toString() : data.level; + idx += 1; + let _level = + kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP" ? idx.toString() : data.level; const kpiCapacityDetail = Object.assign(new KpiCapacityDetail(), { level: _level, description: data.description, - kpiCapacityId: kpiCapacity.id + kpiCapacityId: kpiCapacity.id, }); kpiCapacityDetail.createdUserId = request.user.sub; kpiCapacityDetail.createdFullName = request.user.name; @@ -163,8 +172,8 @@ export class kpiCapacityController extends Controller { kpiCapacityDetail.lastUpdateFullName = request.user.name; await this.kpiCapacityDetailRepository.save(kpiCapacityDetail); } - - return new HttpSuccess(kpiCapacity.id) + + return new HttpSuccess(kpiCapacity.id); } /** @@ -179,33 +188,32 @@ export class kpiCapacityController extends Controller { type: "HEAD", name: "ชื่อสมรรถนะ", description: "คำจำกัดความ", - kpiCapacityDetails: [{ - level: 1, - description: "คำอธิบายระดับ" - }] + kpiCapacityDetails: [ + { + level: 1, + description: "คำอธิบายระดับ", + }, + ], }) async GetKpiCapacityById(@Path() id: string) { const kpiCapacity = await this.kpiCapacityRepository.findOne({ where: { id: id }, select: ["type", "name", "description"], - }) + }); if (!kpiCapacity) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลรายการสมรรถนะนี้", - ); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายการสมรรถนะนี้"); } const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({ where: { kpiCapacityId: id }, select: ["level", "description"], - order: { "level": "ASC" } - }) + order: { level: "ASC" }, + }); const mapData = { type: kpiCapacity.type, name: kpiCapacity.name, description: kpiCapacity.description, - capacityDetails: kpiCapacityDetails - } + capacityDetails: kpiCapacityDetails, + }; return new HttpSuccess(mapData); } @@ -222,17 +230,13 @@ export class kpiCapacityController extends Controller { @Query("type") type?: string, @Query("keyword") keyword?: string, ) { - const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity) .createQueryBuilder("kpiCapacity") - .leftJoinAndSelect("kpiCapacity.KpiCapacityDetails", "kpiCapacityDetail") + .leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail") .andWhere( keyword == undefined ? "1=1" - : [ - { name: Like(`%${keyword}%`) }, - { description: Like(`%${keyword}%`) }, - ], + : [{ name: Like(`%${keyword}%`) }, { description: Like(`%${keyword}%`) }], ) .andWhere(type == undefined ? "1=1" : { type: type }) .orderBy("kpiCapacityDetail.level", "ASC") @@ -245,23 +249,23 @@ export class kpiCapacityController extends Controller { type: item.type, name: item.name, description: item.description, - capacityDetails: item.KpiCapacityDetails.map(detail => { + capacityDetails: item.kpiCapacityDetails.map((detail) => { return { id: detail.id, description: detail.description, level: detail.level, - capacityId: detail.kpiCapacityId + capacityId: detail.kpiCapacityId, }; - }) + }), })); return new HttpSuccess({ data: mapFormula, total }); } /** * API ลบรายการสมรรถนะ - * + * * @summary ลบรายการสมรรถนะ - * + * * @param {string} id Guid, *Id รายการสมรรถนะ */ @Delete("{id}") @@ -270,10 +274,7 @@ export class kpiCapacityController extends Controller { where: { id: id }, }); if (!kpiCapacity) { - throw new HttpError( - HttpStatusCode.NOT_FOUND, - "ไม่พบข้อมูลรายการสมรรถนะนี้", - ); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายการสมรรถนะนี้"); } const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({ where: { kpiCapacityId: id }, diff --git a/src/entities/kpiCapacity.ts b/src/entities/kpiCapacity.ts index bb253a8..447bce8 100644 --- a/src/entities/kpiCapacity.ts +++ b/src/entities/kpiCapacity.ts @@ -1,7 +1,12 @@ -import { Entity, Column, OneToMany, ManyToOne, ManyToMany, JoinTable } from "typeorm"; +import { Entity, Column, OneToMany, ManyToMany, JoinTable } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiCapacityDetail } from "./kpiCapacityDetail"; import { KpiLink } from "./kpiLink"; +import { KpiUserInspector } from "./kpiUserInspector"; +import { KpiUserDirector } from "./kpiUserDirector"; +import { KpiUserExecutive } from "./kpiUserExecutive"; +import { KpiUserGroup } from "./kpiUserGroup"; +import { KpiUserHead } from "./kpiUserHead"; enum CapacityType { HEAD = "HEAD", @@ -40,11 +45,35 @@ export class KpiCapacity extends EntityBase { description: string; @OneToMany(() => KpiCapacityDetail, (kpiCapacityDetail) => kpiCapacityDetail.kpiCapacitys) - KpiCapacityDetails: KpiCapacityDetail[]; + kpiCapacityDetails: KpiCapacityDetail[]; @ManyToMany(() => KpiLink, (kpiLink) => kpiLink.kpiCapacitys) @JoinTable() kpiLinks: KpiLink[]; + + // @OneToMany(() => KpiUserPlanned, (kpiUserPlanned) => kpiUserPlanned.kpiCapacitys) + // kpiUserPlanneds: KpiUserPlanned[]; + + // @OneToMany(() => KpiUserPosition, (kpiUserPosition) => kpiUserPosition.kpiCapacitys) + // kpiUserPositions: KpiUserPosition[]; + + // @OneToMany(() => KpiUserSpecial, (kpiUserSpecial) => kpiUserSpecial.kpiCapacitys) + // kpiUserSpecials: KpiUserSpecial[]; + + @OneToMany(() => KpiUserHead, (kpiUserHead) => kpiUserHead.kpiCapacitys) + kpiUserHeads: KpiUserHead[]; + + @OneToMany(() => KpiUserGroup, (kpiUserGroup) => kpiUserGroup.kpiCapacitys) + kpiUserGroups: KpiUserGroup[]; + + @OneToMany(() => KpiUserExecutive, (kpiUserExecutive) => kpiUserExecutive.kpiCapacitys) + kpiUserExecutives: KpiUserExecutive[]; + + @OneToMany(() => KpiUserDirector, (kpiUserDirector) => kpiUserDirector.kpiCapacitys) + kpiUserDirectors: KpiUserDirector[]; + + @OneToMany(() => KpiUserInspector, (kpiUserInspector) => kpiUserInspector.kpiCapacitys) + kpiUserInspectors: KpiUserInspector[]; } export class createKpiCapacity { @Column() diff --git a/src/entities/kpiCapacityDetail.ts b/src/entities/kpiCapacityDetail.ts index 73b6e99..d200b51 100644 --- a/src/entities/kpiCapacityDetail.ts +++ b/src/entities/kpiCapacityDetail.ts @@ -1,6 +1,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiCapacity } from "./kpiCapacity"; +import { KpiUserHead } from "./kpiUserHead"; @Entity("kpiCapacityDetail") export class KpiCapacityDetail extends EntityBase { @@ -27,7 +28,7 @@ export class KpiCapacityDetail extends EntityBase { }) kpiCapacityId: string; - @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.KpiCapacityDetails) + @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiCapacityDetails) @JoinColumn({ name: "kpiCapacityId" }) kpiCapacitys: KpiCapacity; } diff --git a/src/entities/kpiPeriod.ts b/src/entities/kpiPeriod.ts index 24e1b8b..355497d 100644 --- a/src/entities/kpiPeriod.ts +++ b/src/entities/kpiPeriod.ts @@ -3,6 +3,7 @@ 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 { @@ -46,7 +47,10 @@ export class KpiPeriod extends EntityBase { @OneToMany(() => KpiPlan, (kpiPlan) => kpiPlan.kpiPeriod) kpiPlans: KpiPlan[]; - + + @OneToMany(() => KpiSpecial, (kpiSpecial) => kpiSpecial.kpiPeriod) + kpiSpecials: KpiSpecial[]; + @OneToMany(() => KpiUserEvaluation, (kpiPlan) => kpiPlan.kpiPeriod) kpiUserEvaluation: KpiUserEvaluation[]; } diff --git a/src/entities/kpiPlan.ts b/src/entities/kpiPlan.ts index 575b688..1366cd3 100644 --- a/src/entities/kpiPlan.ts +++ b/src/entities/kpiPlan.ts @@ -2,6 +2,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiLink } from "./kpiLink"; import { KpiPeriod } from "./kpiPeriod"; +import { KpiUserPlanned } from "./kpiUserPlanned"; @Entity("kpiPlan") export class KpiPlan extends EntityBase { @@ -287,6 +288,9 @@ export class KpiPlan extends EntityBase { @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiPlans) @JoinColumn({ name: "kpiPeriodId" }) kpiPeriod: KpiPeriod; + + @OneToMany(() => KpiUserPlanned, (kpiUserPlanned) => kpiUserPlanned.kpiPlans) + kpiUserPlanneds: KpiUserPlanned[]; } export class createKpiPlan { @Column() diff --git a/src/entities/kpiRole.ts b/src/entities/kpiRole.ts index b767dca..92be5c9 100644 --- a/src/entities/kpiRole.ts +++ b/src/entities/kpiRole.ts @@ -1,7 +1,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; -import { KpiLink } from "./kpiLink"; import { KpiPeriod } from "./kpiPeriod"; +import { KpiUserRole } from "./kpiUserRole"; @Entity("kpiRole") export class KpiRole extends EntityBase { @@ -219,6 +219,9 @@ export class KpiRole extends EntityBase { @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiRoles) @JoinColumn({ name: "kpiPeriodId" }) kpiPeriod: KpiPeriod; + + @OneToMany(() => KpiUserRole, (kpiUserRole) => kpiUserRole.kpiRoles) + kpiUserRoles: KpiUserRole[]; } export class createKpiRole { @Column() diff --git a/src/entities/kpiSpecial.ts b/src/entities/kpiSpecial.ts new file mode 100644 index 0000000..1f50b47 --- /dev/null +++ b/src/entities/kpiSpecial.ts @@ -0,0 +1,371 @@ +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.kpiSpecials) + 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/kpiUserDirector.ts b/src/entities/kpiUserDirector.ts new file mode 100644 index 0000000..3bd7113 --- /dev/null +++ b/src/entities/kpiUserDirector.ts @@ -0,0 +1,31 @@ +import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiCapacity } from "./kpiCapacity"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; + +@Entity("kpiUserDirector") +export class KpiUserDirector extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", + default: null, + }) + kpiUserEvaluationId: string; + + @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserDirectors) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiCapacity", + default: null, + }) + kpiCapacityId: string; + + @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiUserDirectors) + @JoinColumn({ name: "kpiCapacityId" }) + kpiCapacitys: KpiCapacity; +} diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index 0ddfe0f..d5e5b7e 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -1,6 +1,14 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { KpiPeriod } from "./kpiPeriod"; +import { KpiUserHead } from "./kpiUserHead"; +import { KpiUserGroup } from "./kpiUserGroup"; +import { KpiUserExecutive } from "./kpiUserExecutive"; +import { KpiUserDirector } from "./kpiUserDirector"; +import { KpiUserInspector } from "./kpiUserInspector"; +import { KpiUserSpecial } from "./kpiUserSpecial"; +import { KpiUserRole } from "./kpiUserRole"; +import { KpiUserPlanned } from "./kpiUserPlanned"; @Entity("kpiUserEvaluation") export class KpiUserEvaluation extends EntityBase { @Column({ @@ -46,6 +54,30 @@ export class KpiUserEvaluation extends EntityBase { @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiUserEvaluation) @JoinColumn({ name: "kpiPeriodId" }) kpiPeriod: KpiPeriod; + + @OneToMany(() => KpiUserHead, (kpiUserHead) => kpiUserHead.kpiUserEvaluations) + kpiUserHeads: KpiUserHead[]; + + @OneToMany(() => KpiUserGroup, (kpiUserGroup) => kpiUserGroup.kpiUserEvaluations) + kpiUserGroups: KpiUserGroup[]; + + @OneToMany(() => KpiUserExecutive, (kpiUserExecutive) => kpiUserExecutive.kpiUserEvaluations) + kpiUserExecutives: KpiUserExecutive[]; + + @OneToMany(() => KpiUserDirector, (kpiUserDirector) => kpiUserDirector.kpiUserEvaluations) + kpiUserDirectors: KpiUserDirector[]; + + @OneToMany(() => KpiUserInspector, (kpiUserInspector) => kpiUserInspector.kpiUserEvaluations) + kpiUserInspectors: KpiUserInspector[]; + + @OneToMany(() => KpiUserPlanned, (kpiUserPlanned) => kpiUserPlanned.kpiUserEvaluations) + kpiUserPlanneds: KpiUserPlanned[]; + + @OneToMany(() => KpiUserRole, (kpiUserRole) => kpiUserRole.kpiUserEvaluations) + kpiUserRoles: KpiUserRole[]; + + @OneToMany(() => KpiUserSpecial, (kpiUserSpecial) => kpiUserSpecial.kpiUserEvaluations) + kpiUserSpecials: KpiUserSpecial[]; } export class createKpiUserEvaluation { diff --git a/src/entities/kpiUserExecutive.ts b/src/entities/kpiUserExecutive.ts new file mode 100644 index 0000000..8a5259a --- /dev/null +++ b/src/entities/kpiUserExecutive.ts @@ -0,0 +1,31 @@ +import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiCapacity } from "./kpiCapacity"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; + +@Entity("kpiUserExecutive") +export class KpiUserExecutive extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", + default: null, + }) + kpiUserEvaluationId: string; + + @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserExecutives) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiCapacity", + default: null, + }) + kpiCapacityId: string; + + @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiUserExecutives) + @JoinColumn({ name: "kpiCapacityId" }) + kpiCapacitys: KpiCapacity; +} diff --git a/src/entities/kpiUserGroup.ts b/src/entities/kpiUserGroup.ts new file mode 100644 index 0000000..517eb3c --- /dev/null +++ b/src/entities/kpiUserGroup.ts @@ -0,0 +1,31 @@ +import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiCapacity } from "./kpiCapacity"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; + +@Entity("kpiUserGroup") +export class KpiUserGroup extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", + default: null, + }) + kpiUserEvaluationId: string; + + @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserGroups) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiCapacity", + default: null, + }) + kpiCapacityId: string; + + @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiUserGroups) + @JoinColumn({ name: "kpiCapacityId" }) + kpiCapacitys: KpiCapacity; +} diff --git a/src/entities/kpiUserHead.ts b/src/entities/kpiUserHead.ts new file mode 100644 index 0000000..216f344 --- /dev/null +++ b/src/entities/kpiUserHead.ts @@ -0,0 +1,31 @@ +import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiCapacity } from "./kpiCapacity"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; + +@Entity("kpiUserHead") +export class KpiUserHead extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", + default: null, + }) + kpiUserEvaluationId: string; + + @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserHeads) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiCapacity", + default: null, + }) + kpiCapacityId: string; + + @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiUserHeads) + @JoinColumn({ name: "kpiCapacityId" }) + kpiCapacitys: KpiCapacity; +} diff --git a/src/entities/kpiUserInspector.ts b/src/entities/kpiUserInspector.ts new file mode 100644 index 0000000..007b4a9 --- /dev/null +++ b/src/entities/kpiUserInspector.ts @@ -0,0 +1,31 @@ +import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiCapacity } from "./kpiCapacity"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; + +@Entity("kpiUserInspector") +export class KpiUserInspector extends EntityBase { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiUserEvaluation", + default: null, + }) + kpiUserEvaluationId: string; + + @ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserInspectors) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiCapacity", + default: null, + }) + kpiCapacityId: string; + + @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiUserInspectors) + @JoinColumn({ name: "kpiCapacityId" }) + kpiCapacitys: KpiCapacity; +} diff --git a/src/entities/kpiUserPlanned.ts b/src/entities/kpiUserPlanned.ts new file mode 100644 index 0000000..8cd3a8f --- /dev/null +++ b/src/entities/kpiUserPlanned.ts @@ -0,0 +1,66 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; +import { KpiPlan } from "./kpiPlan"; + +@Entity("kpiUserPlanned") +export class KpiUserPlanned extends EntityBase { + @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, + }) + 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.kpiUserPlanneds) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiPlan", + default: null, + }) + kpiPlanId: string; + + @ManyToOne(() => KpiPlan, (kpiPlan) => kpiPlan.kpiUserPlanneds) + @JoinColumn({ name: "kpiPlanId" }) + kpiPlans: KpiPlan; +} diff --git a/src/entities/kpiUserRole.ts b/src/entities/kpiUserRole.ts new file mode 100644 index 0000000..4933a5a --- /dev/null +++ b/src/entities/kpiUserRole.ts @@ -0,0 +1,66 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { KpiUserEvaluation } from "./kpiUserEvaluation"; +import { KpiRole } from "./kpiRole"; + +@Entity("kpiUserRole") +export class KpiUserRole extends EntityBase { + @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, + }) + 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.kpiUserRoles) + @JoinColumn({ name: "kpiUserEvaluationId" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiRole", + default: null, + }) + kpiRoleId: string; + + @ManyToOne(() => KpiRole, (kpiRole) => kpiRole.kpiUserRoles) + @JoinColumn({ name: "kpiRoleId" }) + kpiRoles: KpiRole; +} diff --git a/src/entities/kpiUserSpecial.ts b/src/entities/kpiUserSpecial.ts new file mode 100644 index 0000000..13c5fa2 --- /dev/null +++ b/src/entities/kpiUserSpecial.ts @@ -0,0 +1,66 @@ +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, + }) + target: string; + + @Column({ + nullable: true, + comment: "หน่วยนับ", + default: null, + }) + unit: number; + + @Column({ + nullable: true, + comment: "น้ำหนัก", + default: null, + }) + weight: number; + + @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" }) + kpiUserEvaluations: KpiUserEvaluation; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง kpiSpecial", + default: null, + }) + kpiSpecialId: string; + + @ManyToOne(() => KpiSpecial, (kpiSpecial) => kpiSpecial.kpiUserSpecials) + @JoinColumn({ name: "kpiSpecialId" }) + kpiSpecials: KpiSpecial; +}