diff --git a/src/controllers/DevelopmentController.ts b/src/controllers/DevelopmentController.ts index 2841e91..ee4caf4 100644 --- a/src/controllers/DevelopmentController.ts +++ b/src/controllers/DevelopmentController.ts @@ -1925,6 +1925,38 @@ export class DevelopmentController extends Controller { return new HttpSuccess({ data: development, total }); } + /** + * API ลบรายชื่อผู้ผ่านการอบรม + * + * @summary ลบรายชื่อผู้ผ่านการอบรม + * + * @param {string} id Id ผู้ผ่านการอบรม + */ + @Delete("delete/{id}") + async DeleteDevelopmentBy(@Path() id: string, @Request() request: RequestWithUser) { + await new permission().PermissionDelete(request, "SYS_DEV_PROJECT"); + const developmentHis = await this.developmentHistoryRepository.findOne({ + where: { id }, + }); + if (!developmentHis) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรายชื่อผู้ผ่านการอบรม"); + } + if (developmentHis.isProfile) { + if (developmentHis.isDone || developmentHis.isDoneIDP) { + await new CallAPI() + .PostData(request, "/org/profile/training/delete-byId", { + type: developmentHis.type, + profileId: developmentHis.profileId, + developmentId: developmentHis.developmentId, + }) + .then((x) => {}) + .catch((x) => {}); + } + } + await this.developmentHistoryRepository.delete({ id }); + return new HttpSuccess(); + } + /** * API ลบโครงการ/หลักสูตรการฝึกอบรม *