Skip to content

Commit

Permalink
feat : findAnswerByFormIdAndUserId가 null을 반환했을 때 예외처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
nonaninona committed Jan 3, 2025
1 parent 49a9ec2 commit 65b916a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public static AnswerDto from(Answer answer) {
.userId(answer.getUser().getId())
.build();
}

public static AnswerDto noAnswerDto = new AnswerDto(-1L, -1L, -1L, "");
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public List<Form> findFormsBySurveyId(Long surveyId) {

public AnswerDto findAnswerByFormIdAndUserId(Long formId, Long userId) {
Answer answer = answerRepository.findAnswerByFormIdAndUserId(formId, userId);
if(answer == null)
return AnswerDto.noAnswerDto;
return AnswerDto.from(answer);
}

Expand Down

0 comments on commit 65b916a

Please sign in to comment.