diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 0fa0fc6..460a456 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -27,6 +27,8 @@ import { updateKpiUserCheckEvaluation, updateKpiUserEvaluation, updateKpiUserPointEvaluation, + updateKpiUserStatusEvaluation, + updateKpiUserReqEditEvaluation, } from "../entities/kpiUserEvaluation"; import { Like, In, Brackets } from "typeorm"; import CallAPI from "../interfaces/call-api"; @@ -230,6 +232,66 @@ export class KpiUserEvaluationController extends Controller { return new HttpSuccess(kpiUserEvaluation.id); } + /** + * API แก้ไขสถานะประเมิน (USER) + * + * @summary แก้ไขคนประเมิน (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Put("edit/{id}") + async updateKpiUserReqEditEvaluation( + @Path() id: string, + @Body() requestBody: updateKpiUserReqEditEvaluation, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + kpiUserEvaluation.evaluationReqEdit = requestBody.status.trim().toUpperCase(); + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + // Object.assign(kpiUserEvaluation, requestBody); + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + return new HttpSuccess(kpiUserEvaluation.id); + } + + /** + * API แก้ไขสถานะประเมิน (USER) + * + * @summary แก้ไขคนประเมิน (USER) + * + * @param {string} id Guid, *Id คนประเมิน (USER) + */ + @Put("status/{id}") + async updateKpiUserStatusEvaluation( + @Path() id: string, + @Body() requestBody: updateKpiUserStatusEvaluation, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + kpiUserEvaluation.evaluationStatus = requestBody.status.trim().toUpperCase(); + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; + // Object.assign(kpiUserEvaluation, requestBody); + await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); + return new HttpSuccess(kpiUserEvaluation.id); + } + /** * API รายละเอียดรายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER) * diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index 61955bb..d499542 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -203,3 +203,13 @@ export class updateKpiUserPointEvaluation { @Column() capacityPoint: number | null; } + +export class updateKpiUserReqEditEvaluation { + @Column() + status: string; +} + +export class updateKpiUserStatusEvaluation { + @Column() + status: string; +}