history kpi

This commit is contained in:
AdisakKanthawilang 2024-05-08 17:54:53 +07:00
parent 46e23f619c
commit 36de3d9717
5 changed files with 118 additions and 124 deletions

View file

@ -593,4 +593,22 @@ export class kpiPlanController extends Controller {
return new HttpSuccess(); return new HttpSuccess();
} }
/**
* API
* @param id Guid, *Id
*/
@Get("history/{id}")
async GetHistory(@Path() id: string) {
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
where: { kpiPlanId: id },
order:{
createdAt: "ASC"
}
});
if (!kpiPlanHistory) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัดิตัวชี้วัดตามแผนนี้");
}
return new HttpSuccess(kpiPlanHistory);
}
} }

View file

@ -551,4 +551,22 @@ export class kpiRoleController extends Controller {
} }
return new HttpSuccess(); return new HttpSuccess();
} }
/**
* API
* @param id Guid, *Id
*/
@Get("history/{id}")
async GetHistory(@Path() id: string) {
const kpiRoleHistory = await this.kpiRoleHistoryRepository.find({
where: { kpiRoleId: id },
order:{
createdAt: "ASC"
}
});
if (!kpiRoleHistory) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประวัดิตัวชี้วัดตามตำแหน่งนี้");
}
return new HttpSuccess(kpiRoleHistory);
}
} }

View file

@ -27,7 +27,7 @@ import {
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation"; import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
import { Not } from "typeorm"; import { Not } from "typeorm";
@Route("api/v1/kpi/user/achievement/Development") @Route("api/v1/kpi/user/achievement/evelopment")
@Tags("KpiUserDevelopment") @Tags("KpiUserDevelopment")
@Security("bearerAuth") @Security("bearerAuth")
@Response( @Response(
@ -149,103 +149,65 @@ import {
return new HttpSuccess(); return new HttpSuccess();
} }
// /** /**
// * API รายละเอียดพัฒนาตนเอง * API
// * *
// * @summary - รายละเอียดพัฒนาตนเอง # * @summary - #
// * *
// * @param {string} id Id พัฒนาตนเอง * @param {string} id Id
// */ */
// @Get("{id}") @Get("{id}")
// async GetKpiUserDevelopmentDetail(@Path() id: string) { async GetKpiUserDevelopmentDetail(@Path() id: string) {
// const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({ const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
// relations: ["kpiUserEvaluation"], relations: ["kpiUserEvaluation"],
// where: { id: id }, where: { id: id },
// }); });
// if (!getKpiUserDevelopment) { if (!getKpiUserDevelopment) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลพัฒนาตนเองนี้"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลพัฒนาตนเองนี้");
// } }
// const mapKpiUserDevelopment = { const mapKpiUserDevelopment = {
// id: getKpiUserDevelopment.id, id: getKpiUserDevelopment.id,
// evaluationId: getKpiUserDevelopment.kpiUserEvaluation.id, evaluationId: getKpiUserDevelopment.kpiUserEvaluation.id,
// including: getKpiUserDevelopment.including, target: getKpiUserDevelopment.target,
// includingName: getKpiUserDevelopment.includingName, summary: getKpiUserDevelopment.summary,
// target: getKpiUserDevelopment.target, name: getKpiUserDevelopment.name,
// weight: getKpiUserDevelopment.weight, achievement10: getKpiUserDevelopment.achievement10,
// unit: getKpiUserDevelopment.unit, achievement5: getKpiUserDevelopment.achievement5,
// meaning: getKpiUserDevelopment.meaning, achievement0: getKpiUserDevelopment.achievement0,
// formula: getKpiUserDevelopment.formula, };
// point: getKpiUserDevelopment.point,
// achievement:
// getKpiUserDevelopment.point === 1
// ? getKpiUserDevelopment.achievement1
// : getKpiUserDevelopment.point === 2
// ? getKpiUserDevelopment.achievement2
// : getKpiUserDevelopment.point === 3
// ? getKpiUserDevelopment.achievement3
// : getKpiUserDevelopment.point === 4
// ? getKpiUserDevelopment.achievement4
// : getKpiUserDevelopment.point === 5
// ? getKpiUserDevelopment.achievement5
// : null,
// achievement1: getKpiUserDevelopment.achievement1,
// achievement2: getKpiUserDevelopment.achievement2,
// achievement3: getKpiUserDevelopment.achievement3,
// achievement4: getKpiUserDevelopment.achievement4,
// achievement5: getKpiUserDevelopment.achievement5,
// };
// return new HttpSuccess(mapKpiUserDevelopment); return new HttpSuccess(mapKpiUserDevelopment);
// } }
// /** /**
// * API รายการพัฒนาตนเอง * API
// * *
// * @summary - รายการพัฒนาตนเอง # * @summary - #
// * *
// */ */
// @Get() @Get()
// async GetKpiUserDevelopment(@Query("id") id: string) { async GetKpiUserDevelopment(@Query("id") id: string) {
// const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({ const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({
// where: { where: {
// kpiUserEvaluationId: id, kpiUserEvaluationId: id,
// }, },
// relations: ["kpiUserEvaluation"], relations: ["kpiUserEvaluation"],
// order: { createdAt: "ASC" }, order: { createdAt: "ASC" },
// }); });
// const mapKpiUserDevelopment = kpiUserDevelopment.map((item) => ({ const mapKpiUserDevelopment = kpiUserDevelopment.map((item) => ({
// id: item.id, id: item.id,
// evaluationId: item.kpiUserEvaluation.id, evaluationId: item.kpiUserEvaluation.id,
// including: item.including, target: item.target,
// includingName: item.includingName, summary: item.summary,
// target: item.target, name: item.name,
// weight: item.weight, achievement10: item.achievement10,
// unit: item.unit, achievement5: item.achievement5,
// meaning: item.meaning, achievement0: item.achievement0,
// formula: item.formula, }));
// point: item.point, return new HttpSuccess(mapKpiUserDevelopment);
// achievement: }
// item.point === 1
// ? item.achievement1
// : item.point === 2
// ? item.achievement2
// : item.point === 3
// ? item.achievement3
// : item.point === 4
// ? item.achievement4
// : item.point === 5
// ? item.achievement5
// : null,
// achievement1: item.achievement1,
// achievement2: item.achievement2,
// achievement3: item.achievement3,
// achievement4: item.achievement4,
// achievement5: item.achievement5,
// }));
// return new HttpSuccess(mapKpiUserDevelopment);
// }
/** /**
* API * API

View file

@ -198,6 +198,14 @@ export class KpiUserRoleController extends Controller {
unit: getKpiUserRole.unit, unit: getKpiUserRole.unit,
meaning: getKpiUserRole.meaning, meaning: getKpiUserRole.meaning,
formula: getKpiUserRole.formula, formula: getKpiUserRole.formula,
achievement1: getKpiUserRole.achievement1,
achievement2: getKpiUserRole.achievement2,
achievement3: getKpiUserRole.achievement3,
achievement4: getKpiUserRole.achievement4,
achievement5: getKpiUserRole.achievement5,
documentInfoEvidence: getKpiUserRole.documentInfoEvidence,
endDate: getKpiUserRole.endDate,
startDate: getKpiUserRole.startDate,
}; };
return new HttpSuccess(mapKpiUserRole); return new HttpSuccess(mapKpiUserRole);

View file

@ -80,58 +80,46 @@ export class KpiUserDevelopment extends EntityBase {
export class CreateKpiUserDevelopment { export class CreateKpiUserDevelopment {
@Column() @Column()
including: string | null; name: string | null;
@Column() @Column()
includingName: string | null; target: string | null;
@Column() @Column()
achievement1: string | null; summary?: number | null;
@Column() @Column()
achievement2: string | null; achievement10?: string | null;
@Column() @Column()
achievement3: string | null; achievement5?: string | null;
@Column() @Column()
achievement4: string | null; achievement0?: string | null;
@Column() @Column()
achievement5: string | null; isDevelopment70: boolean;
@Column() @Column()
target: string; isDevelopment20: boolean;
@Column() @Column()
unit: number; isDevelopment10: boolean;
@Column()
weight: number;
@Column()
meaning: string;
@Column()
formula: string;
@Column("uuid") @Column("uuid")
kpiUserEvaluationId: string; kpiUserEvaluationId: string;
} }
export class UpdateKpiUserDevelopment { export class UpdateKpiUserDevelopment {
@Column() @Column()
including: string | null; name: string | null;
@Column() @Column()
includingName: string | null; target: string | null;
@Column() @Column()
achievement1: string | null; summary?: number | null;
@Column() @Column()
achievement2: string | null; achievement10?: string | null;
@Column() @Column()
achievement3: string | null; achievement5?: string | null;
@Column() @Column()
achievement4: string | null; achievement0?: string | null;
@Column() @Column()
achievement5: string | null; isDevelopment70: boolean;
@Column() @Column()
target: string; isDevelopment20: boolean;
@Column() @Column()
unit: number; isDevelopment10: boolean;
@Column()
weight: number;
@Column()
meaning: string;
@Column()
formula: string;
@Column("uuid") @Column("uuid")
kpiUserEvaluationId: string; kpiUserEvaluationId: string;
} }