diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 7bc8fab..2ba0892 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -29,6 +29,7 @@ import { updateKpiUserPointEvaluation, updateKpiUserStatusEvaluation, updateKpiUserReqEditEvaluation, + updateKpiUserResultEvaluation, } from "../entities/kpiUserEvaluation"; import { Like, In, Brackets } from "typeorm"; import CallAPI from "../interfaces/call-api"; @@ -316,7 +317,35 @@ export class KpiUserEvaluationController extends Controller { 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("result/{id}") + async updateKpiUserResultEvaluation( + @Path() id: string, + @Body() requestBody: updateKpiUserResultEvaluation, + @Request() request: { user: Record }, + ) { + const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + where: { id: id }, + }); + if (!kpiUserEvaluation) { + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", + ); + } + kpiUserEvaluation.evaluationResults = requestBody.status.trim().toUpperCase(); + kpiUserEvaluation.lastUpdateUserId = request.user.sub; + kpiUserEvaluation.lastUpdateFullName = request.user.name; await this.kpiUserEvalutionRepository.save(kpiUserEvaluation); return new HttpSuccess(kpiUserEvaluation.id); } @@ -346,7 +375,6 @@ export class KpiUserEvaluationController extends Controller { 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); } diff --git a/src/entities/kpiUserEvaluation.ts b/src/entities/kpiUserEvaluation.ts index bf099dd..3bae4c8 100644 --- a/src/entities/kpiUserEvaluation.ts +++ b/src/entities/kpiUserEvaluation.ts @@ -213,3 +213,8 @@ export class updateKpiUserStatusEvaluation { @Column() status: string; } + +export class updateKpiUserResultEvaluation { + @Column() + status: string; +}