Skip to content

Commit

Permalink
[feat] 면접 끝 API
Browse files Browse the repository at this point in the history
  • Loading branch information
cha2y0ung committed Mar 28, 2024
1 parent 1d45478 commit 0e95a90
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/controller/interviewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,24 @@ const saveEmotion = async (req: Request, res: Response, next: NextFunction) => {
}
}

const endInterview = async (req: Request, res: Response, next: NextFunction) => {
const {interviewQuestionId} = req.params
const endDateTime = req.body

try {
const data = await interviewService.endInterview(endDateTime, +interviewQuestionId);

return res
.status(statusCode.CREATED)
.send(success(statusCode.CREATED, message.END_INTERVIEW_SUCCESS, data));
} catch (error) {
next(error);
}
}

export default {
startInterview,
makeFeedback,
saveEmotion,
endInterview,
};
1 change: 1 addition & 0 deletions src/module/constant/responseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export default {
SAVE_EMOTION_SUCCESS: "감정 저장 성공",
ACCESS_USERINFO_SUCCESS: "프로필 조회 성공",
UPDATE_USERINFO_SUCCESS: "프로필 수정 성공",
END_INTERVIEW_SUCCESS: "인터뷰 종료 성공",
};
10 changes: 10 additions & 0 deletions src/router/interviewRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,15 @@ router.post(
interviewController.saveEmotion,
);

router.patch(
'/:interviewQuestionId',
[
param('interviewQuestionId').notEmpty(),
body('endDateTime'),
],
errorValidator,
interviewController.endInterview,
);


export default router;
29 changes: 29 additions & 0 deletions src/service/interviewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,37 @@ const saveEmotion = async (saveEmotionDTO: saveEmotionDTO, interviewQuestionId:
}
};

const endInterview = async (endDateTime: string, interviewQuestionId: number) => {
try {
const findInterviewQuestion = await prisma.interviewQuestion.find({
where: {
id: interviewQuestionId,
},
select: {
interviewId: true,
}
});

const endInterview = await prisma.interview.update({
where: {
id: findInterviewQuestion.interviewId
},
data: {
id: true,
startDateTime: true,
endDateTime: endDateTime,
questionNum: true,
}
});
return endInterview;
} catch(error) {
throw error;
}
};

export default {
startInterview,
makeFeedback,
saveEmotion,
endInterview,
};

0 comments on commit 0e95a90

Please sign in to comment.