no message

This commit is contained in:
Kittapath 2024-05-08 18:03:47 +07:00
parent 305fd51c99
commit b3adb67e44
13 changed files with 497 additions and 121 deletions

View file

@ -30,10 +30,6 @@ import {
} from "../entities/kpiUserEvaluation";
import { Like, In, Brackets } from "typeorm";
import CallAPI from "../interfaces/call-api";
import {
KpiUserEvaluationReason,
updateKpiUserReasonEvaluation,
} from "../entities/kpiUserEvaluationReason";
@Route("api/v1/kpi/user/evaluation")
@Tags("kpiUserEvaluation")
@ -46,7 +42,6 @@ import {
export class KpiUserEvaluationController extends Controller {
private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod);
private kpiUserEvalutionRepository = AppDataSource.getRepository(KpiUserEvaluation);
private kpiUserEvaluationReasonRepository = AppDataSource.getRepository(KpiUserEvaluationReason);
/**
* API
@ -195,56 +190,56 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("{type}/{id}")
async updateKpiUserEvaluatorEvaluation(
@Path() id: string,
@Path() type: string,
@Body() requestBody: updateKpiUserReasonEvaluation,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
// /**
// * API แก้ไขหมายเหตุ (USER)
// *
// * @summary แก้ไขหมายเหตุ (USER)
// *
// * @param {string} id Guid, *Id คนประเมิน (USER)
// */
// @Put("{type}/{id}")
// async updateKpiUserEvaluatorEvaluation(
// @Path() id: string,
// @Path() type: string,
// @Body() requestBody: updateKpiUserReasonEvaluation,
// @Request() request: { user: Record<string, any> },
// ) {
// const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
// where: { id: id },
// });
// if (!kpiUserEvaluation) {
// throw new HttpError(
// HttpStatusCode.NOT_FOUND,
// "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
// );
// }
const kpiUserEvaluationReason = Object.assign(new KpiUserEvaluationReason(), requestBody);
kpiUserEvaluationReason.type = type.trim().toUpperCase();
kpiUserEvaluationReason.kpiUserEvaluationId = id;
kpiUserEvaluationReason.createdUserId = request.user.sub;
kpiUserEvaluationReason.createdFullName = request.user.name;
kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
await this.kpiUserEvaluationReasonRepository.save(kpiUserEvaluationReason);
return new HttpSuccess(kpiUserEvaluation.id);
}
// const kpiUserEvaluationReason = Object.assign(new KpiUserEvaluationReason(), requestBody);
// kpiUserEvaluationReason.type = type.trim().toUpperCase();
// kpiUserEvaluationReason.kpiUserEvaluationId = id;
// kpiUserEvaluationReason.createdUserId = request.user.sub;
// kpiUserEvaluationReason.createdFullName = request.user.name;
// kpiUserEvaluationReason.lastUpdateUserId = request.user.sub;
// kpiUserEvaluationReason.lastUpdateFullName = request.user.name;
// await this.kpiUserEvaluationReasonRepository.save(kpiUserEvaluationReason);
// return new HttpSuccess(kpiUserEvaluation.id);
// }
/**
* API list (USER)
*
* @summary list (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Get("{type}/{id}")
async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({
where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() },
order: { createdAt: "ASC" },
});
return new HttpSuccess(kpiUserEvaluationReason);
}
// /**
// * API list หมายเหตุ (USER)
// *
// * @summary list หมายเหตุ (USER)
// *
// * @param {string} id Guid, *Id คนประเมิน (USER)
// */
// @Get("{type}/{id}")
// async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) {
// const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({
// where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() },
// order: { createdAt: "ASC" },
// });
// return new HttpSuccess(kpiUserEvaluationReason);
// }
/**
* API (USER)

View file

@ -2,6 +2,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiCapacity } from "./kpiCapacity";
import { KpiUserEvaluation } from "./kpiUserEvaluation";
import { KpiUserEvaluationReasonCapacity } from "./kpiUserEvaluationReasonCapacity";
@Entity("kpiUserCapacity")
export class KpiUserCapacity extends EntityBase {
@ -57,9 +58,15 @@ export class KpiUserCapacity extends EntityBase {
@ManyToOne(() => KpiCapacity, (kpiCapacity) => kpiCapacity.kpiUserCapacitys)
@JoinColumn({ name: "kpiCapacityId" })
kpiCapacity: KpiCapacity;
@OneToMany(
() => KpiUserEvaluationReasonCapacity,
(kpiUserEvaluationReasonCapacity) => kpiUserEvaluationReasonCapacity.kpiUserCapacity,
)
kpiUserEvaluationReasonCapacitys: KpiUserEvaluationReasonCapacity[];
}
export class KpiUserCapacityDataPoint {
id: string;
point: number;
}
}

View file

@ -1,6 +1,7 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserEvaluation } from "./kpiUserEvaluation";
import { KpiUserEvaluationReasonDevelopment } from "./kpiUserEvaluationReasonDevelopment";
@Entity("kpiUserDevelopment")
export class KpiUserDevelopment extends EntityBase {
@ -76,6 +77,12 @@ export class KpiUserDevelopment extends EntityBase {
@ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserDevelopments)
@JoinColumn({ name: "kpiUserEvaluationId" })
kpiUserEvaluation: KpiUserEvaluation;
@OneToMany(
() => KpiUserEvaluationReasonDevelopment,
(kpiUserEvaluationReasonDevelopment) => kpiUserEvaluationReasonDevelopment.kpiUserDevelopment,
)
kpiUserEvaluationReasonDevelopments: KpiUserEvaluationReasonDevelopment[];
}
export class CreateKpiUserDevelopment {

View file

@ -5,7 +5,6 @@ import { KpiUserSpecial } from "./kpiUserSpecial";
import { KpiUserRole } from "./kpiUserRole";
import { KpiUserPlanned } from "./kpiUserPlanned";
import { KpiUserCapacity } from "./kpiUserCapacity";
import { KpiUserEvaluationReason } from "./kpiUserEvaluationReason";
import { KpiUserDevelopment } from "./kpiUserDevelopment";
@Entity("kpiUserEvaluation")
export class KpiUserEvaluation extends EntityBase {
@ -149,12 +148,6 @@ export class KpiUserEvaluation extends EntityBase {
@OneToMany(() => KpiUserDevelopment, (kpiUserDevelopment) => kpiUserDevelopment.kpiUserEvaluation)
kpiUserDevelopments: KpiUserDevelopment[];
@OneToMany(
() => KpiUserEvaluationReason,
(kpiUserEvaluationReason) => kpiUserEvaluationReason.kpiUserEvaluation,
)
kpiUserEvaluationReasons: KpiUserEvaluationReason[];
}
export class createKpiUserEvaluation {

View file

@ -1,56 +0,0 @@
import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiPeriod } from "./kpiPeriod";
import { KpiUserSpecial } from "./kpiUserSpecial";
import { KpiUserRole } from "./kpiUserRole";
import { KpiUserPlanned } from "./kpiUserPlanned";
import { KpiUserCapacity } from "./kpiUserCapacity";
import { KpiUserEvaluation } from "./kpiUserEvaluation";
@Entity("kpiUserEvaluationReason")
export class KpiUserEvaluationReason extends EntityBase {
@Column({
nullable: true,
comment: "หมายเหตุ",
length: 255,
default: null,
})
reason: string;
@Column({
nullable: true,
comment: "หัวข้อ",
length: 255,
default: null,
})
topic: string;
@Column({
nullable: true,
comment: "ประเภท",
length: 255,
default: null,
})
type: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง kpiPeriodId",
default: null,
})
kpiUserEvaluationId: string;
@ManyToOne(
() => KpiUserEvaluation,
(kpiUserEvaluation) => kpiUserEvaluation.kpiUserEvaluationReasons,
)
@JoinColumn({ name: "kpiUserEvaluationId" })
kpiUserEvaluation: KpiUserEvaluation;
}
export class updateKpiUserReasonEvaluation {
@Column()
reason: string | null;
@Column()
topic: string | null;
}

View file

@ -0,0 +1,83 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserCapacity } from "./kpiUserCapacity";
@Entity("kpiUserEvaluationReasonCapacity")
export class KpiUserEvaluationReasonCapacity extends EntityBase {
@Column({
nullable: true,
comment: "หัวข้อ",
length: 255,
default: null,
})
topic: string;
@Column({
nullable: true,
comment: "หมายเหตุ",
length: 255,
default: null,
})
reason: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้ประเมิน",
length: 255,
default: null,
})
reasonEvaluator: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป",
length: 255,
default: null,
})
reasonCommander: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
length: 255,
default: null,
})
reasonCommanderHigh: string;
@Column({
nullable: true,
comment: "สถานะ DRAFT EVALUATOR COMMANDER COMMANDERHIGH",
length: 255,
default: "DRAFT",
})
status: string;
@Column({
nullable: true,
comment: "ประเภท PROGRESS PROBLEM",
length: 255,
default: null,
})
type: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง kpiUserCapacity",
default: null,
})
kpiUserCapacityId: string;
@ManyToOne(
() => KpiUserCapacity,
(kpiUserCapacity) => kpiUserCapacity.kpiUserEvaluationReasonCapacitys,
)
@JoinColumn({ name: "kpiUserCapacityId" })
kpiUserCapacity: KpiUserCapacity;
}
export class updateKpiUserReasonEvaluation {
@Column()
reason: string | null;
@Column()
topic: string | null;
}

View file

@ -0,0 +1,83 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserDevelopment } from "./kpiUserDevelopment";
@Entity("kpiUserEvaluationReasonDevelopment")
export class KpiUserEvaluationReasonDevelopment extends EntityBase {
@Column({
nullable: true,
comment: "หัวข้อ",
length: 255,
default: null,
})
topic: string;
@Column({
nullable: true,
comment: "หมายเหตุ",
length: 255,
default: null,
})
reason: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้ประเมิน",
length: 255,
default: null,
})
reasonEvaluator: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป",
length: 255,
default: null,
})
reasonCommander: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
length: 255,
default: null,
})
reasonCommanderHigh: string;
@Column({
nullable: true,
comment: "สถานะ DRAFT EVALUATOR COMMANDER COMMANDERHIGH",
length: 255,
default: "DRAFT",
})
status: string;
@Column({
nullable: true,
comment: "ประเภท PROGRESS PROBLEM",
length: 255,
default: null,
})
type: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง kpiUserDevelopment",
default: null,
})
kpiUserDevelopmentId: string;
@ManyToOne(
() => KpiUserDevelopment,
(kpiUserDevelopment) => kpiUserDevelopment.kpiUserEvaluationReasonDevelopments,
)
@JoinColumn({ name: "kpiUserDevelopmentId" })
kpiUserDevelopment: KpiUserDevelopment;
}
export class updateKpiUserReasonEvaluation {
@Column()
reason: string | null;
@Column()
topic: string | null;
}

View file

@ -0,0 +1,80 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserPlanned } from "./kpiUserPlanned";
@Entity("kpiUserEvaluationReasonPlan")
export class KpiUserEvaluationReasonPlan extends EntityBase {
@Column({
nullable: true,
comment: "หัวข้อ",
length: 255,
default: null,
})
topic: string;
@Column({
nullable: true,
comment: "หมายเหตุ",
length: 255,
default: null,
})
reason: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้ประเมิน",
length: 255,
default: null,
})
reasonEvaluator: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป",
length: 255,
default: null,
})
reasonCommander: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
length: 255,
default: null,
})
reasonCommanderHigh: string;
@Column({
nullable: true,
comment: "สถานะ DRAFT EVALUATOR COMMANDER COMMANDERHIGH",
length: 255,
default: "DRAFT",
})
status: string;
@Column({
nullable: true,
comment: "ประเภท PROGRESS PROBLEM",
length: 255,
default: null,
})
type: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง kpiUserPlan",
default: null,
})
kpiUserPlannedId: string;
@ManyToOne(() => KpiUserPlanned, (kpiUserPlanned) => kpiUserPlanned.kpiUserEvaluationReasonPlans)
@JoinColumn({ name: "kpiUserPlanId" })
kpiUserPlanned: KpiUserPlanned;
}
export class updateKpiUserReasonEvaluation {
@Column()
reason: string | null;
@Column()
topic: string | null;
}

View file

@ -0,0 +1,80 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserRole } from "./kpiUserRole";
@Entity("kpiUserEvaluationReasonRole")
export class KpiUserEvaluationReasonRole extends EntityBase {
@Column({
nullable: true,
comment: "หัวข้อ",
length: 255,
default: null,
})
topic: string;
@Column({
nullable: true,
comment: "หมายเหตุ",
length: 255,
default: null,
})
reason: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้ประเมิน",
length: 255,
default: null,
})
reasonEvaluator: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป",
length: 255,
default: null,
})
reasonCommander: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
length: 255,
default: null,
})
reasonCommanderHigh: string;
@Column({
nullable: true,
comment: "สถานะ DRAFT EVALUATOR COMMANDER COMMANDERHIGH",
length: 255,
default: "DRAFT",
})
status: string;
@Column({
nullable: true,
comment: "ประเภท PROGRESS PROBLEM",
length: 255,
default: null,
})
type: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง kpiUserRole",
default: null,
})
kpiUserRoleId: string;
@ManyToOne(() => KpiUserRole, (kpiUserRole) => kpiUserRole.kpiUserEvaluationReasonRoles)
@JoinColumn({ name: "kpiUserRoleId" })
kpiUserRole: KpiUserRole;
}
export class updateKpiUserReasonEvaluation {
@Column()
reason: string | null;
@Column()
topic: string | null;
}

View file

@ -0,0 +1,83 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserSpecial } from "./kpiUserSpecial";
@Entity("kpiUserEvaluationReasonSpecial")
export class KpiUserEvaluationReasonSpecial extends EntityBase {
@Column({
nullable: true,
comment: "หัวข้อ",
length: 255,
default: null,
})
topic: string;
@Column({
nullable: true,
comment: "หมายเหตุ",
length: 255,
default: null,
})
reason: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้ประเมิน",
length: 255,
default: null,
})
reasonEvaluator: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป",
length: 255,
default: null,
})
reasonCommander: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
length: 255,
default: null,
})
reasonCommanderHigh: string;
@Column({
nullable: true,
comment: "สถานะ DRAFT EVALUATOR COMMANDER COMMANDERHIGH",
length: 255,
default: "DRAFT",
})
status: string;
@Column({
nullable: true,
comment: "ประเภท PROGRESS PROBLEM",
length: 255,
default: null,
})
type: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง kpiUserSpecial",
default: null,
})
kpiUserSpecialId: string;
@ManyToOne(
() => KpiUserSpecial,
(kpiUserSpecial) => kpiUserSpecial.kpiUserEvaluationReasonSpecials,
)
@JoinColumn({ name: "kpiUserSpecialId" })
kpiUserSpecial: KpiUserSpecial;
}
export class updateKpiUserReasonEvaluation {
@Column()
reason: string | null;
@Column()
topic: string | null;
}

View file

@ -1,7 +1,8 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserEvaluation } from "./kpiUserEvaluation";
import { KpiPlan } from "./kpiPlan";
import { KpiUserEvaluationReasonPlan } from "./kpiUserEvaluationReasonPlan";
@Entity("kpiUserPlanned")
export class KpiUserPlanned extends EntityBase {
@ -136,6 +137,12 @@ export class KpiUserPlanned extends EntityBase {
default: null,
})
achievement5: string;
@OneToMany(
() => KpiUserEvaluationReasonPlan,
(kpiUserEvaluationReasonPlan) => kpiUserEvaluationReasonPlan.kpiUserPlanned,
)
kpiUserEvaluationReasonPlans: KpiUserEvaluationReasonPlan[];
}
export class CreateKpiUserPlanned {

View file

@ -1,8 +1,9 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserEvaluation } from "./kpiUserEvaluation";
import { KpiRole } from "./kpiRole";
import { Double } from "typeorm/browser";
import { KpiUserEvaluationReasonRole } from "./kpiUserEvaluationReasonRole";
@Entity("kpiUserRole")
export class KpiUserRole extends EntityBase {
@ -137,6 +138,12 @@ export class KpiUserRole extends EntityBase {
default: null,
})
achievement5: string;
@OneToMany(
() => KpiUserEvaluationReasonRole,
(kpiUserEvaluationReasonRole) => kpiUserEvaluationReasonRole.kpiUserRole,
)
kpiUserEvaluationReasonRoles: KpiUserEvaluationReasonRole[];
}
export class CreateKpiUserRole {

View file

@ -1,6 +1,7 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { KpiUserEvaluation } from "./kpiUserEvaluation";
import { KpiUserEvaluationReasonSpecial } from "./kpiUserEvaluationReasonSpecial";
@Entity("kpiUserSpecial")
export class KpiUserSpecial extends EntityBase {
@ -158,6 +159,12 @@ export class KpiUserSpecial extends EntityBase {
@ManyToOne(() => KpiUserEvaluation, (kpiUserEvaluation) => kpiUserEvaluation.kpiUserSpecials)
@JoinColumn({ name: "kpiUserEvaluationId" })
kpiUserEvaluation: KpiUserEvaluation;
@OneToMany(
() => KpiUserEvaluationReasonSpecial,
(kpiUserEvaluationReasonSpecial) => kpiUserEvaluationReasonSpecial.kpiUserSpecial,
)
kpiUserEvaluationReasonSpecials: KpiUserEvaluationReasonSpecial[];
}
export class CreateKpiUserSpecial {