add field and api update result

This commit is contained in:
AdisakKanthawilang 2024-12-20 10:24:50 +07:00
parent 9acca2f4c3
commit a25a133406
3 changed files with 215 additions and 159 deletions

View file

@ -658,6 +658,42 @@ export class EvaluationController {
return error.status;
}
}
/**
* API
*
* @summary
*
* @param {string} id id
*/
@Put("changeEvaluationResult/{id}")
async changeEvaluationResult(
@Request() request: RequestWithUser,
@Path() id: string,
@Body() body: { result: string },
) {
try {
if (body.result != "PASS" && body.result != "NOTPASS") {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบผลลัพธ์ดังกล่าว");
}
const evaluation = await this.evaluationRepository.findOne({
where: { id },
});
if (!evaluation) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
}
// evaluation.evaluationResult = body.result;
evaluation.lastUpdateUserId = request.user.sub;
evaluation.lastUpdateFullName = request.user.name;
evaluation.lastUpdatedAt = new Date();
await this.evaluationRepository.save(evaluation, { data: request });
return new HttpSuccess();
} catch (error: any) {
return error.status;
}
}
/**
*
*