diff --git a/src/controller/historyController.ts b/src/controller/historyController.ts index 4da499a..cd054c8 100644 --- a/src/controller/historyController.ts +++ b/src/controller/historyController.ts @@ -32,7 +32,22 @@ const getInterviewDetail = async (req: Request, res: Response, next: NextFunctio } }; +const deleteInterview = async (req: Request, res: Response, next: NextFunction) => { + const {interviewId} = req.params; + + try { + const data = await historyService.deleteInterview(+interviewId); + + return res + .status(statusCode.CREATED) + .send(success(statusCode.CREATED, message.DELETE_INTERVIEW_SUCCESS, data)); + } catch (error) { + next(error); + } +}; + export default { getInterviewList, getInterviewDetail, + deleteInterview, }; \ No newline at end of file diff --git a/src/module/constant/responseMessage.ts b/src/module/constant/responseMessage.ts index 2d9db63..3220ef9 100644 --- a/src/module/constant/responseMessage.ts +++ b/src/module/constant/responseMessage.ts @@ -16,4 +16,5 @@ export default { FIRST_RESULT_INTERVIEW_SUCCESS: "첫번째 인터뷰 결과 조회 성공", GET_INTERVIEWLIST_SUCCESS: "면접 기록 리스트 조회 성공", GET_INTERVIEWDETAIL_SUCCESS: "면접 기록 상세 조회 성공", + DELETE_INTERVIEW_SUCCESS: "면접 기록 삭제 성공", }; \ No newline at end of file diff --git a/src/router/historyRouter.ts b/src/router/historyRouter.ts index 04a6541..b6e3601 100644 --- a/src/router/historyRouter.ts +++ b/src/router/historyRouter.ts @@ -23,4 +23,14 @@ router.get( errorValidator, historyController.getInterviewDetail, ) + +router.delete( + '/:interviewId', + [ + param('interviewId').notEmpty(), + ], + errorValidator, + historyController.deleteInterview, + +) export default router; \ No newline at end of file diff --git a/src/service/historyService.ts b/src/service/historyService.ts index 35cf3a0..66c9b23 100644 --- a/src/service/historyService.ts +++ b/src/service/historyService.ts @@ -125,7 +125,7 @@ const getQuestionDetails = async (interviewId: number) => { return questionDetails; } -const getInterviewDetail = async(interviewId: number) => { +const getInterviewDetail = async (interviewId: number) => { try { const questionDetails = await getQuestionDetails(interviewId) const findInterview = await prisma.interview.findFirst({ @@ -177,7 +177,36 @@ const getInterviewDetail = async(interviewId: number) => { } }; +const deleteInterview = async (interviewId: number) => { + try { + const deleteInterview = await prisma.interview.delete({ + where: { + id: interviewId, + } + }); + const deleteAnswer = await prisma.answer.deleteMany({ + where: { + interviewId: interviewId, + } + }); + const deleteFeedback = await prisma.feedback.deleteMany({ + where: { + interviewId: interviewId, + } + }); + const deleteInterviewQuestion = await prisma.interviewQuestion.deleteMany({ + where: { + interviewId: interviewId, + } + }); + } catch(error) { + throw error; + } +} + + export default { getInterviewList, getInterviewDetail, + deleteInterview, }; \ No newline at end of file