API change-status , req-edit
This commit is contained in:
parent
dddb53ae7f
commit
113e1643e9
1 changed files with 78 additions and 0 deletions
|
|
@ -500,4 +500,82 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
await this.kpiUserEvalutionRepository.remove(kpiUserEvaluation);
|
await this.kpiUserEvalutionRepository.remove(kpiUserEvaluation);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้สถานะแบบประเมินตามรายการที่เลือก
|
||||||
|
*
|
||||||
|
* @summary แก้สถานะแบบประเมินตามรายการที่เลือก
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("admin/change-status")
|
||||||
|
async ChangeStatus(
|
||||||
|
@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.evaluationStatus = requestBody.status.trim().toUpperCase();
|
||||||
|
item.lastUpdateUserId = request.user.sub;
|
||||||
|
item.lastUpdateFullName = request.user.name;
|
||||||
|
await this.kpiUserEvalutionRepository.save(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API อนุมัติการขอแก้ไขแบบประเมินตามรายการที่เลือก
|
||||||
|
*
|
||||||
|
* @summary อนุมัติการขอแก้ไขแบบประเมินตามรายการที่เลือก
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("admin/req-edit")
|
||||||
|
async RequestEdit(
|
||||||
|
@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.evaluationReqEdit = 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