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

@ -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,