checkpoint

This commit is contained in:
AdisakKanthawilang 2024-04-23 12:29:26 +07:00
parent 44f669b5b1
commit f12dbfcbee
3 changed files with 76 additions and 79 deletions

View file

@ -119,40 +119,38 @@ export class KpiUserPlannedController extends Controller {
return new HttpSuccess();
}
// /**
// * API รายละเอียดงานตามแผนปฏิบัติราชการประจำปี
// *
// * @summary - รายละเอียดงานตามแผนปฏิบัติราชการประจำปี #51
// *
// * @param {string} id Id งานตามแผนปฏิบัติราชการประจำปี
// */
// @Get("{id}")
// async GetKpiUserPlannedDetail(@Path() id: string) {
// const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
// select: ["id", "kpiUserPlannedName", "kpiUserPlannedRank"],
// relations: ["posLevels"],
// where: { id: id },
// });
// if (!getKpiUserPlanned) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามแผนปฏิบัติราชการประจำปีนี้");
// }
/**
* API
*
* @summary - #51
*
* @param {string} id Id
*/
@Get("{id}")
async GetKpiUserPlannedDetail(@Path() id: string) {
const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
relations: ["kpiPlan","kpiUserEvaluation"],
where: { id: id },
});
if (!getKpiUserPlanned) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามแผนปฏิบัติราชการประจำปีนี้");
}
// const mapGetKpiUserPlanned = {
// id: getKpiUserPlanned.id,
// kpiUserPlannedName: getKpiUserPlanned.kpiUserPlannedName,
// kpiUserPlannedRank: getKpiUserPlanned.kpiUserPlannedRank,
// posLevels: getKpiUserPlanned.posLevels
// .sort((a, b) => a.posLevelRank - b.posLevelRank)
// .map((posLevel) => ({
// id: posLevel.id,
// posLevelName: posLevel.posLevelName,
// posLevelRank: posLevel.posLevelRank,
// posLevelAuthority: posLevel.posLevelAuthority,
// })),
// };
const mapGetKpiUserPlanned = ({
id: getKpiUserPlanned.id,
evaluationId: getKpiUserPlanned.kpiUserEvaluation.id,
kpiRoleId: getKpiUserPlanned.kpiPlan.id,
including: getKpiUserPlanned.kpiPlan.including, //รหัสตัวชี้วัด
includingName: getKpiUserPlanned.kpiPlan.includingName, //ชื่อตัวชี้วัด
target: getKpiUserPlanned.target,
weight: getKpiUserPlanned.weight,
unit: getKpiUserPlanned.unit,
meaning: getKpiUserPlanned.meaning,
formula: getKpiUserPlanned.formula,
});
// return new HttpSuccess(mapGetKpiUserPlanned);
// }
return new HttpSuccess(mapGetKpiUserPlanned);
}
/**
* API
@ -161,14 +159,17 @@ export class KpiUserPlannedController extends Controller {
*
*/
@Get()
async GetKpiUserPlanned() {
async GetKpiUserPlanned(
@Query("id") id: string ,
) {
const kpiUserPlanned = await this.kpiUserPlannedRepository.find({
where:{
kpiUserEvaluationId:id
},
relations: ["kpiPlan","kpiUserEvaluation"],
order: { createdAt: "ASC" },
});
// if (!kpiUserPlanned) {
// return new HttpSuccess([]);
// }
const mapKpiUserPlanned = kpiUserPlanned.map((item) => ({
id: item.id,
evaluationId: item.kpiUserEvaluation.id,
@ -183,8 +184,8 @@ export class KpiUserPlannedController extends Controller {
achievement: item.point === 1 ? "ระดับ 1" :
item.point === 2 ? "ระดับ 2" :
item.point === 3 ? "ระดับ 3" :
item.point === 3 ? "ระดับ 4" :
item.point === 3 ? "ระดับ 5" : null,
item.point === 4 ? "ระดับ 4" :
item.point === 5 ? "ระดับ 5" : null,
achievement1: item.kpiPlan.achievement1,
achievement2: item.kpiPlan.achievement2,
achievement3: item.kpiPlan.achievement3,

View file

@ -132,40 +132,38 @@ export class KpiUserRoleController extends Controller {
return new HttpSuccess();
}
// /**
// * API รายละเอียดงานตามหน้าที่ความรับผิดชอบหลัก
// *
// * @summary - รายละเอียดงานตามหน้าที่ความรับผิดชอบหลัก #51
// *
// * @param {string} id Id งานตามหน้าที่ความรับผิดชอบหลัก
// */
// @Get("{id}")
// async GetKpiUserRoleDetail(@Path() id: string) {
// const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
// select: ["id", "kpiUserRoleName", "kpiUserRoleRank"],
// relations: ["posLevels"],
// where: { id: id },
// });
// if (!getKpiUserRole) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้");
// }
/**
* API
*
* @summary - #51
*
* @param {string} id Id
*/
@Get("{id}")
async GetKpiUserRoleDetail(@Path() id: string) {
const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
relations: ["kpiRole","kpiUserEvaluation"],
where: { id: id },
});
if (!getKpiUserRole) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้");
}
// const mapGetKpiUserRole = {
// id: getKpiUserRole.id,
// kpiUserRoleName: getKpiUserRole.kpiUserRoleName,
// kpiUserRoleRank: getKpiUserRole.kpiUserRoleRank,
// posLevels: getKpiUserRole.posLevels
// .sort((a, b) => a.posLevelRank - b.posLevelRank)
// .map((posLevel) => ({
// id: posLevel.id,
// posLevelName: posLevel.posLevelName,
// posLevelRank: posLevel.posLevelRank,
// posLevelAuthority: posLevel.posLevelAuthority,
// })),
// };
const mapKpiUserRole = ({
id: getKpiUserRole.id,
evaluationId: getKpiUserRole.kpiUserEvaluation.id,
kpiRoleId: getKpiUserRole.kpiRole.id,
including: getKpiUserRole.kpiRole.including,
includingName: getKpiUserRole.kpiRole.includingName,
target: getKpiUserRole.target,
weight: getKpiUserRole.weight,
unit: getKpiUserRole.unit,
meaning: getKpiUserRole.meaning,
formula: getKpiUserRole.formula,
});
// return new HttpSuccess(mapGetKpiUserRole);
// }
return new HttpSuccess(mapKpiUserRole);
}
/**
* API
@ -184,9 +182,7 @@ export class KpiUserRoleController extends Controller {
relations: ["kpiRole","kpiUserEvaluation"],
order: { createdAt: "ASC" },
});
// if (!kpiUserRole) {
// return new HttpSuccess([]);
// }
const mapKpiUserRole = kpiUserRole.map((item) => ({
id: item.id,
evaluationId: item.kpiUserEvaluation.id,
@ -202,8 +198,8 @@ export class KpiUserRoleController extends Controller {
achievement: item.point === 1 ? "ระดับ 1" :
item.point === 2 ? "ระดับ 2" :
item.point === 3 ? "ระดับ 3" :
item.point === 3 ? "ระดับ 4" :
item.point === 3 ? "ระดับ 5" : null,
item.point === 4 ? "ระดับ 4" :
item.point === 5 ? "ระดับ 5" : null,
achievement1: item.kpiRole.achievement1,
achievement2: item.kpiRole.achievement2,
achievement3: item.kpiRole.achievement3,

View file

@ -108,8 +108,8 @@ export class UpdateKpiUserPlanned {
meaning: string;
@Column()
formula: string;
// @Column("uuid")
// kpiUserEvaluationId: string;
// @Column("uuid")
// kpiPlanId: string;
@Column("uuid")
kpiUserEvaluationId: string;
@Column("uuid")
kpiPlanId: string;
}