Skip to content

Commit

Permalink
Merge pull request #39 from TEAM-ITERVIEW/#38
Browse files Browse the repository at this point in the history
[feat] 면접 기록 삭제 API
  • Loading branch information
cha2y0ung authored Mar 29, 2024
2 parents a005fdd + e8c14d4 commit 6f781f3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/controller/historyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
1 change: 1 addition & 0 deletions src/module/constant/responseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export default {
FIRST_RESULT_INTERVIEW_SUCCESS: "첫번째 인터뷰 결과 조회 성공",
GET_INTERVIEWLIST_SUCCESS: "면접 기록 리스트 조회 성공",
GET_INTERVIEWDETAIL_SUCCESS: "면접 기록 상세 조회 성공",
DELETE_INTERVIEW_SUCCESS: "면접 기록 삭제 성공",
};
10 changes: 10 additions & 0 deletions src/router/historyRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ router.get(
errorValidator,
historyController.getInterviewDetail,
)

router.delete(
'/:interviewId',
[
param('interviewId').notEmpty(),
],
errorValidator,
historyController.deleteInterview,

)
export default router;
31 changes: 30 additions & 1 deletion src/service/historyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
};

0 comments on commit 6f781f3

Please sign in to comment.