api ลบรายชื่อกรรมการ และ รายการการประชุม #2399
This commit is contained in:
parent
8fc32940c5
commit
96ea1a2141
1 changed files with 68 additions and 0 deletions
|
|
@ -3361,4 +3361,72 @@ export class EvaluationController {
|
||||||
} else throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, error);
|
} 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue