Skip to content

Commit

Permalink
fix: 편지 상세 조회, 자유롭게 쓰는 질문에 대한 처리 #3
Browse files Browse the repository at this point in the history
  • Loading branch information
623nana committed Aug 26, 2021
1 parent cdfa7f9 commit ceece5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/com/nexters/covid/letter/domain/Letter.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ public void updateLetterSendOption(SendOption sendOption) {
public boolean unpostedSendOption() {
return sendOption.isUnpostedLetter();
}

public boolean isFreeQuestion() {
return questionId == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ public LetterResponse findLetterByEncryptedId(String encryptedId) {
Letter letter = letterRepository.findLetterByEncryptedId(encryptedId)
.orElseThrow(() -> new IllegalArgumentException("해당 ID의 편지가 없습니다."));

Question question = questionRepository.findQuestionById(letter.getQuestionId());
if (letter.isFreeQuestion()) {
return new LetterResponse(letter);
}

Question question = questionRepository.findQuestionById(letter.getQuestionId());
return new LetterResponse(letter, question);
}

Expand Down

0 comments on commit ceece5b

Please sign in to comment.