Skip to content

Commit

Permalink
⚡️: fix 코드리뷰 반영 수정(빠진 코드, null) #38
Browse files Browse the repository at this point in the history
  • Loading branch information
sookyungg committed Apr 12, 2024
1 parent 1941c82 commit 50565d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class AnswerService(
return EveryAnswerInfoResponse.of(todayQuestion, answerCount)
}

@Transactional(readOnly = true)
fun findAllAnswersLikeTopN(getCount: Long): EveryAnswerRetrieveResponses {
val todayQuestion = questionExplorer.findTodayQuestion()
val answers = answerRepository.findPublicAnswersLikeTopN(todayQuestion.id, getCount)
Expand All @@ -92,16 +93,7 @@ class AnswerService(

return try {
answerRegister.registerAnswer(memberEntity, questionEntity, answerWriting.body, answerWriting.open).let {
WritingAnswerResult(
questionId = questionEntity.id,
questionTitle = questionEntity.title,
questionContent = questionEntity.content,
questionExposedAt = questionEntity.exposedAt,
questionElementType = questionEntity.elementType,
questionAnswered = true,
answerId = it.id,
answerBody = it.content,
reactionLikeCount = 0 // 최초 생성시는 0
WritingAnswerResult(questionId = questionEntity.id, questionTitle = questionEntity.title, questionContent = questionEntity.content, questionExposedAt = questionEntity.exposedAt, questionElementType = questionEntity.elementType, questionAnswered = true, answerId = it.id, answerBody = it.content, reactionLikeCount = 0 // 최초 생성시는 0
)
}
} catch (e: DataIntegrityViolationException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class QuestionExplorer(
private val questionRepository: QuestionRepository,
) {
fun findQuestion(id: Long): Question =
questionRepository.findById(id).orElse(null)
?: throw NotFoundException(ErrorCode.NOT_FOUND_QUESTION_EXCEPTION, "존재하지 않는 질문 $id 입니다")
questionRepository.findById(id).orElseThrow {
NotFoundException(ErrorCode.NOT_FOUND_QUESTION_EXCEPTION, "존재 하지 않는 질문 $id 입니다")
}

fun findQuestionByDateTime(dateTime: LocalDateTime): Question {
// 입력된 dateTime이 밤 10시 이후인지 확인
Expand Down

0 comments on commit 50565d2

Please sign in to comment.