er ฝั่ง user

This commit is contained in:
Kittapath 2024-04-22 15:50:04 +07:00
parent 27da57f35e
commit fae8d38013
16 changed files with 870 additions and 72 deletions

View file

@ -14,14 +14,18 @@ import {
SuccessResponse, SuccessResponse,
Response, Response,
Query, Query,
ArrayValidator ArrayValidator,
} from "tsoa"; } from "tsoa";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status"; import HttpStatusCode from "../interfaces/http-status";
import { KpiCapacity, createKpiCapacity, updateKpiCapacity } from "../entities/kpiCapacity"; 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"; import { Like, In } from "typeorm";
@Route("api/v1/kpi/capacity") @Route("api/v1/kpi/capacity")
@ -47,27 +51,30 @@ export class kpiCapacityController extends Controller {
type: "HEAD", type: "HEAD",
name: "ชื่อสมรรถนะ", name: "ชื่อสมรรถนะ",
description: "คำจำกัดความ", description: "คำจำกัดความ",
kpiCapacityDetails: [{ kpiCapacityDetails: [
level: "ระดับ", {
description: "คำอธิบายระดับ" level: "ระดับ",
}] description: "คำอธิบายระดับ",
},
],
}) })
async createKpiCapacity( async createKpiCapacity(
@Body() requestBody: { @Body()
type: string requestBody: {
name: string type: string;
description: string name: string;
description: string;
capacityDetails: { capacityDetails: {
level: string; level: string;
description: string; description: string;
}[]; }[];
}, },
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
){ ) {
const kpiCapacity = Object.assign(new KpiCapacity(), { const kpiCapacity = Object.assign(new KpiCapacity(), {
type: requestBody.type, type: requestBody.type,
name: requestBody.name, name: requestBody.name,
description: requestBody.description description: requestBody.description,
}); });
kpiCapacity.createdUserId = request.user.sub; kpiCapacity.createdUserId = request.user.sub;
kpiCapacity.createdFullName = request.user.name; kpiCapacity.createdFullName = request.user.name;
@ -77,12 +84,13 @@ export class kpiCapacityController extends Controller {
let idx: number = 0; let idx: number = 0;
for (const data of requestBody.capacityDetails) { for (const data of requestBody.capacityDetails) {
idx += 1 idx += 1;
let _level = (kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP") ? idx.toString() : data.level; let _level =
kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP" ? idx.toString() : data.level;
const kpiCapacityDetail = Object.assign(new KpiCapacityDetail(), { const kpiCapacityDetail = Object.assign(new KpiCapacityDetail(), {
level: _level, level: _level,
description: data.description, description: data.description,
kpiCapacityId: kpiCapacity.id kpiCapacityId: kpiCapacity.id,
}); });
kpiCapacityDetail.createdUserId = request.user.sub; kpiCapacityDetail.createdUserId = request.user.sub;
kpiCapacityDetail.createdFullName = request.user.name; kpiCapacityDetail.createdFullName = request.user.name;
@ -91,7 +99,7 @@ export class kpiCapacityController extends Controller {
await this.kpiCapacityDetailRepository.save(kpiCapacityDetail); await this.kpiCapacityDetailRepository.save(kpiCapacityDetail);
} }
return new HttpSuccess(kpiCapacity.id) return new HttpSuccess(kpiCapacity.id);
} }
/** /**
@ -106,19 +114,22 @@ export class kpiCapacityController extends Controller {
type: "HEAD", type: "HEAD",
name: "ชื่อสมรรถนะ", name: "ชื่อสมรรถนะ",
description: "คำจำกัดความ", description: "คำจำกัดความ",
kpiCapacityDetails: [{ kpiCapacityDetails: [
level: "ระดับ", {
description: "คำอธิบายระดับ" level: "ระดับ",
}] description: "คำอธิบายระดับ",
},
],
}) })
async updateKpiCapacity( async updateKpiCapacity(
@Path() id: string, @Path() id: string,
@Body() requestBody: { @Body()
type: string requestBody: {
name: string type: string;
description: string name: string;
description: string;
capacityDetails: { capacityDetails: {
level: string level: string;
description: string; description: string;
}[]; }[];
}, },
@ -128,15 +139,12 @@ export class kpiCapacityController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (!kpiCapacity) { if (!kpiCapacity) {
throw new HttpError( throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายการสมรรถนะนี้");
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการสมรรถนะนี้",
);
} }
const _kpiCapacity = Object.assign(new KpiCapacity(), { const _kpiCapacity = Object.assign(new KpiCapacity(), {
type: requestBody.type, type: requestBody.type,
name: requestBody.name, name: requestBody.name,
description: requestBody.description description: requestBody.description,
}); });
kpiCapacity.lastUpdateUserId = request.user.sub; kpiCapacity.lastUpdateUserId = request.user.sub;
kpiCapacity.lastUpdateFullName = request.user.name; kpiCapacity.lastUpdateFullName = request.user.name;
@ -150,12 +158,13 @@ export class kpiCapacityController extends Controller {
let idx: number = 0; let idx: number = 0;
for (const data of requestBody.capacityDetails) { for (const data of requestBody.capacityDetails) {
idx += 1 idx += 1;
let _level = (kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP") ? idx.toString() : data.level; let _level =
kpiCapacity.type === "HEAD" || kpiCapacity.type === "GROUP" ? idx.toString() : data.level;
const kpiCapacityDetail = Object.assign(new KpiCapacityDetail(), { const kpiCapacityDetail = Object.assign(new KpiCapacityDetail(), {
level: _level, level: _level,
description: data.description, description: data.description,
kpiCapacityId: kpiCapacity.id kpiCapacityId: kpiCapacity.id,
}); });
kpiCapacityDetail.createdUserId = request.user.sub; kpiCapacityDetail.createdUserId = request.user.sub;
kpiCapacityDetail.createdFullName = request.user.name; kpiCapacityDetail.createdFullName = request.user.name;
@ -164,7 +173,7 @@ export class kpiCapacityController extends Controller {
await this.kpiCapacityDetailRepository.save(kpiCapacityDetail); 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", type: "HEAD",
name: "ชื่อสมรรถนะ", name: "ชื่อสมรรถนะ",
description: "คำจำกัดความ", description: "คำจำกัดความ",
kpiCapacityDetails: [{ kpiCapacityDetails: [
level: 1, {
description: "คำอธิบายระดับ" level: 1,
}] description: "คำอธิบายระดับ",
},
],
}) })
async GetKpiCapacityById(@Path() id: string) { async GetKpiCapacityById(@Path() id: string) {
const kpiCapacity = await this.kpiCapacityRepository.findOne({ const kpiCapacity = await this.kpiCapacityRepository.findOne({
where: { id: id }, where: { id: id },
select: ["type", "name", "description"], select: ["type", "name", "description"],
}) });
if (!kpiCapacity) { if (!kpiCapacity) {
throw new HttpError( throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายการสมรรถนะนี้");
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการสมรรถนะนี้",
);
} }
const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({ const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({
where: { kpiCapacityId: id }, where: { kpiCapacityId: id },
select: ["level", "description"], select: ["level", "description"],
order: { "level": "ASC" } order: { level: "ASC" },
}) });
const mapData = { const mapData = {
type: kpiCapacity.type, type: kpiCapacity.type,
name: kpiCapacity.name, name: kpiCapacity.name,
description: kpiCapacity.description, description: kpiCapacity.description,
capacityDetails: kpiCapacityDetails capacityDetails: kpiCapacityDetails,
} };
return new HttpSuccess(mapData); return new HttpSuccess(mapData);
} }
@ -222,17 +230,13 @@ export class kpiCapacityController extends Controller {
@Query("type") type?: string, @Query("type") type?: string,
@Query("keyword") keyword?: string, @Query("keyword") keyword?: string,
) { ) {
const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity) const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity)
.createQueryBuilder("kpiCapacity") .createQueryBuilder("kpiCapacity")
.leftJoinAndSelect("kpiCapacity.KpiCapacityDetails", "kpiCapacityDetail") .leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail")
.andWhere( .andWhere(
keyword == undefined keyword == undefined
? "1=1" ? "1=1"
: [ : [{ name: Like(`%${keyword}%`) }, { description: Like(`%${keyword}%`) }],
{ name: Like(`%${keyword}%`) },
{ description: Like(`%${keyword}%`) },
],
) )
.andWhere(type == undefined ? "1=1" : { type: type }) .andWhere(type == undefined ? "1=1" : { type: type })
.orderBy("kpiCapacityDetail.level", "ASC") .orderBy("kpiCapacityDetail.level", "ASC")
@ -245,14 +249,14 @@ export class kpiCapacityController extends Controller {
type: item.type, type: item.type,
name: item.name, name: item.name,
description: item.description, description: item.description,
capacityDetails: item.KpiCapacityDetails.map(detail => { capacityDetails: item.kpiCapacityDetails.map((detail) => {
return { return {
id: detail.id, id: detail.id,
description: detail.description, description: detail.description,
level: detail.level, level: detail.level,
capacityId: detail.kpiCapacityId capacityId: detail.kpiCapacityId,
}; };
}) }),
})); }));
return new HttpSuccess({ data: mapFormula, total }); return new HttpSuccess({ data: mapFormula, total });
} }
@ -270,10 +274,7 @@ export class kpiCapacityController extends Controller {
where: { id: id }, where: { id: id },
}); });
if (!kpiCapacity) { if (!kpiCapacity) {
throw new HttpError( throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายการสมรรถนะนี้");
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการสมรรถนะนี้",
);
} }
const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({ const kpiCapacityDetails = await this.kpiCapacityDetailRepository.find({
where: { kpiCapacityId: id }, where: { kpiCapacityId: id },

View file

@ -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 { EntityBase } from "./base/Base";
import { KpiCapacityDetail } from "./kpiCapacityDetail"; import { KpiCapacityDetail } from "./kpiCapacityDetail";
import { KpiLink } from "./kpiLink"; 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 { enum CapacityType {
HEAD = "HEAD", HEAD = "HEAD",
@ -40,11 +45,35 @@ export class KpiCapacity extends EntityBase {
description: string; description: string;
@OneToMany(() => KpiCapacityDetail, (kpiCapacityDetail) => kpiCapacityDetail.kpiCapacitys) @OneToMany(() => KpiCapacityDetail, (kpiCapacityDetail) => kpiCapacityDetail.kpiCapacitys)
KpiCapacityDetails: KpiCapacityDetail[]; kpiCapacityDetails: KpiCapacityDetail[];
@ManyToMany(() => KpiLink, (kpiLink) => kpiLink.kpiCapacitys) @ManyToMany(() => KpiLink, (kpiLink) => kpiLink.kpiCapacitys)
@JoinTable() @JoinTable()
kpiLinks: KpiLink[]; 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 { export class createKpiCapacity {
@Column() @Column()

View file

@ -1,6 +1,7 @@
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { KpiCapacity } from "./kpiCapacity"; import { KpiCapacity } from "./kpiCapacity";
import { KpiUserHead } from "./kpiUserHead";
@Entity("kpiCapacityDetail") @Entity("kpiCapacityDetail")
export class KpiCapacityDetail extends EntityBase { export class KpiCapacityDetail extends EntityBase {
@ -27,7 +28,7 @@ export class KpiCapacityDetail extends EntityBase {
}) })
kpiCapacityId: string; kpiCapacityId: string;
@ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.KpiCapacityDetails) @ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiCapacityDetails)
@JoinColumn({ name: "kpiCapacityId" }) @JoinColumn({ name: "kpiCapacityId" })
kpiCapacitys: KpiCapacity; kpiCapacitys: KpiCapacity;
} }

View file

@ -3,6 +3,7 @@ import { EntityBase } from "./base/Base";
import { KpiPlan } from "./kpiPlan"; import { KpiPlan } from "./kpiPlan";
import { KpiRole } from "./kpiRole"; import { KpiRole } from "./kpiRole";
import { KpiUserEvaluation } from "./kpiUserEvaluation"; import { KpiUserEvaluation } from "./kpiUserEvaluation";
import { KpiSpecial } from "./kpiSpecial";
@Entity("kpiPeriod") @Entity("kpiPeriod")
export class KpiPeriod extends EntityBase { export class KpiPeriod extends EntityBase {
@ -47,6 +48,9 @@ export class KpiPeriod extends EntityBase {
@OneToMany(() => KpiPlan, (kpiPlan) => kpiPlan.kpiPeriod) @OneToMany(() => KpiPlan, (kpiPlan) => kpiPlan.kpiPeriod)
kpiPlans: KpiPlan[]; kpiPlans: KpiPlan[];
@OneToMany(() => KpiSpecial, (kpiSpecial) => kpiSpecial.kpiPeriod)
kpiSpecials: KpiSpecial[];
@OneToMany(() => KpiUserEvaluation, (kpiPlan) => kpiPlan.kpiPeriod) @OneToMany(() => KpiUserEvaluation, (kpiPlan) => kpiPlan.kpiPeriod)
kpiUserEvaluation: KpiUserEvaluation[]; kpiUserEvaluation: KpiUserEvaluation[];
} }

View file

@ -2,6 +2,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { KpiLink } from "./kpiLink"; import { KpiLink } from "./kpiLink";
import { KpiPeriod } from "./kpiPeriod"; import { KpiPeriod } from "./kpiPeriod";
import { KpiUserPlanned } from "./kpiUserPlanned";
@Entity("kpiPlan") @Entity("kpiPlan")
export class KpiPlan extends EntityBase { export class KpiPlan extends EntityBase {
@ -287,6 +288,9 @@ export class KpiPlan extends EntityBase {
@ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiPlans) @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiPlans)
@JoinColumn({ name: "kpiPeriodId" }) @JoinColumn({ name: "kpiPeriodId" })
kpiPeriod: KpiPeriod; kpiPeriod: KpiPeriod;
@OneToMany(() => KpiUserPlanned, (kpiUserPlanned) => kpiUserPlanned.kpiPlans)
kpiUserPlanneds: KpiUserPlanned[];
} }
export class createKpiPlan { export class createKpiPlan {
@Column() @Column()

View file

@ -1,7 +1,7 @@
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { KpiLink } from "./kpiLink";
import { KpiPeriod } from "./kpiPeriod"; import { KpiPeriod } from "./kpiPeriod";
import { KpiUserRole } from "./kpiUserRole";
@Entity("kpiRole") @Entity("kpiRole")
export class KpiRole extends EntityBase { export class KpiRole extends EntityBase {
@ -219,6 +219,9 @@ export class KpiRole extends EntityBase {
@ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiRoles) @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiRoles)
@JoinColumn({ name: "kpiPeriodId" }) @JoinColumn({ name: "kpiPeriodId" })
kpiPeriod: KpiPeriod; kpiPeriod: KpiPeriod;
@OneToMany(() => KpiUserRole, (kpiUserRole) => kpiUserRole.kpiRoles)
kpiUserRoles: KpiUserRole[];
} }
export class createKpiRole { export class createKpiRole {
@Column() @Column()

371
src/entities/kpiSpecial.ts Normal file
View file

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

View file

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

View file

@ -1,6 +1,14 @@
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { KpiPeriod } from "./kpiPeriod"; 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") @Entity("kpiUserEvaluation")
export class KpiUserEvaluation extends EntityBase { export class KpiUserEvaluation extends EntityBase {
@Column({ @Column({
@ -46,6 +54,30 @@ export class KpiUserEvaluation extends EntityBase {
@ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiUserEvaluation) @ManyToOne(() => KpiPeriod, (kpiPeriod) => kpiPeriod.kpiUserEvaluation)
@JoinColumn({ name: "kpiPeriodId" }) @JoinColumn({ name: "kpiPeriodId" })
kpiPeriod: KpiPeriod; 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 { export class createKpiUserEvaluation {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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