Skip to content

Commit

Permalink
[feat] : QuestionPost 단건조회 메서드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dudxo committed Nov 23, 2024
1 parent 9463711 commit 49f801e
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public AnswerDetailResponse registerAnswer(
RegisterAnswerRequest request,
Member member
) {
QuestionPost questionPost = findQuestionPostById(questionPostId);
QuestionPost questionPost = getQuestionPostById(questionPostId);
Answer answer = AnswerMapper.toAnswer(questionPostId, questionPost.isQuestioner(member.getId()), request,
member);
Answer savedAnswer = answerRepository.save(answer);
Expand Down Expand Up @@ -108,6 +108,11 @@ private Answer getAnswerById(Long answerId) {
.orElseThrow(() -> new NotFoundException(AnswerErrorCode.NOT_FOUND_ANSWER));
}

private QuestionPost getQuestionPostById(Long questionPostId) {
return questionPostRepository.findById(questionPostId)
.orElseThrow(() -> new NotFoundException(QuestionPostErrorCode.NOT_FOUND_QUESTION_POST));
}

private QuestionPost findQuestionPostById(Long questionPostId) {
return questionPostSimpleQueryRepository.findQuestionPostById(questionPostId)
.orElseThrow(() -> new NotFoundException(QuestionPostErrorCode.NOT_FOUND_QUESTION_POST));
Expand Down

0 comments on commit 49f801e

Please sign in to comment.