add field and api update result
This commit is contained in:
parent
9acca2f4c3
commit
a25a133406
3 changed files with 215 additions and 159 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue