From 96ea1a21413a47246ac898ffdb746c8c818b7394 Mon Sep 17 00:00:00 2001 From: harid Date: Fri, 3 Apr 2026 17:15:18 +0700 Subject: [PATCH] =?UTF-8?q?api=20=E0=B8=A5=E0=B8=9A=E0=B8=A3=E0=B8=B2?= =?UTF-8?q?=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=81=E0=B8=A3?= =?UTF-8?q?=E0=B8=A3=E0=B8=A1=E0=B8=81=E0=B8=B2=E0=B8=A3=20=E0=B9=81?= =?UTF-8?q?=E0=B8=A5=E0=B8=B0=20=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=A3?= =?UTF-8?q?=E0=B8=B0=E0=B8=8A=E0=B8=B8=E0=B8=A1=20#2399?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EvaluationController.ts | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/controllers/EvaluationController.ts b/src/controllers/EvaluationController.ts index 09a09bc..5bd7ca2 100644 --- a/src/controllers/EvaluationController.ts +++ b/src/controllers/EvaluationController.ts @@ -3361,4 +3361,72 @@ export class EvaluationController { } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); } } + + /** + * API สำหรับลบกรรมการออกจากการประเมิน + * @summary ลบกรรมการในการประเมิน (ADMIN) + * @param {string} id id ของ evaluation_directors_director + */ + @Delete("del-director/{id}") + async removeEvaluationDirector( + @Path() id: string, + @Request() request: RequestWithUser, + ) { + try { + const evaluationDirector = + await this.evaluation_directors_directorRepository.findOneBy({ id }); + + if (!evaluationDirector) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกรรมการ"); + } + + await this.evaluation_directors_directorRepository.remove(evaluationDirector, { + data: request, + }); + + return new HttpSuccess(); + } catch (error: any) { + if (error instanceof HttpError) { + throw error; + } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); + } + } + + /** + * API สำหรับลบการประชุมออกจากการประเมิน + * @summary ลบการประชุมในการประเมิน (ADMIN) + * @param {string} evaluationId id ของ evaluation + * @param {string} meetingId id ของ meeting + */ + @Delete("del-meeting/{evaluationId}/{meetingId}") + async removeMeetingFromEvaluation( + @Path() evaluationId: string, + @Path() meetingId: string, + @Request() request: RequestWithUser, + ) { + try { + const evaluation = await this.evaluationRepository.findOne({ + where: { id: evaluationId }, + relations: { meetings: true }, + }); + + if (!evaluation) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประเมิน"); + } + + const meetingExists = evaluation.meetings.some((m) => m.id === meetingId); + if (!meetingExists) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการประชุมในการประเมินนี้"); + } + + evaluation.meetings = evaluation.meetings.filter((m) => m.id !== meetingId); + await this.evaluationRepository.save(evaluation, { data: request }); + + return new HttpSuccess(); + } catch (error: any) { + if (error instanceof HttpError) { + throw error; + } else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error); + } + } }