API result-status
This commit is contained in:
parent
113e1643e9
commit
f0e3ad2664
1 changed files with 39 additions and 0 deletions
|
|
@ -578,4 +578,43 @@ export class KpiUserEvaluationController extends Controller {
|
|||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขสถานะผลการประเมิน
|
||||
*
|
||||
* @summary แก้ไขสถานะผลการประเมิน
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Post("admin/result-status")
|
||||
async ResultStatus(
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Body()
|
||||
requestBody: {
|
||||
status: string;
|
||||
id: string[];
|
||||
},
|
||||
) {
|
||||
const list = await this.kpiUserEvalutionRepository.find({
|
||||
where: { id: In(requestBody.id) },
|
||||
});
|
||||
if (!list || list.length === 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
const hasAllData = requestBody.id.every((id) => list.some((item) => item.id === id));
|
||||
|
||||
if (!hasAllData) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "พบบางไอดีผู้ประเมินที่ไม่มีข้อมูล");
|
||||
}
|
||||
|
||||
list.forEach(async (item) => {
|
||||
item.evaluationResults = requestBody.status.trim().toUpperCase();
|
||||
item.lastUpdateUserId = request.user.sub;
|
||||
item.lastUpdateFullName = request.user.name;
|
||||
await this.kpiUserEvalutionRepository.save(item);
|
||||
});
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue