Skip to content

Commit

Permalink
feat: 오늘의 질문 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaisqls committed Nov 6, 2023
1 parent d9eea0d commit c87c76d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface CustomQuestionRepository {
fun queryQuestionDtoOrderByAnswerCount(user: User, page: Long): PageResponse<QuestionDto>
fun queryQuestionDtoById(id: Long, user: User): QuestionDto?
fun queryQuestionDetailDtoById(user: User, questionId: Long): QuestionDetailDto?
fun queryQuestionDto(user: User): List<QuestionDto>
}

@Repository
Expand Down Expand Up @@ -65,6 +66,15 @@ class CustomQuestionRepositoryImpl(
)
}

override fun queryQuestionDto(
user: User,
): List<QuestionDto> {
return queryFactory
.selectFrom(questions)
.orderBy(questions.likeCount.asc())
.getQuestionDto(user)
}

override fun queryQuestionDtoOrderByAnswerCount(user: User, page: Long): PageResponse<QuestionDto> {
val questionList = queryFactory
.selectFrom(questions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class QuestionService(

fun getTodayQuestion(): QuestionResponse {
val user = SecurityUtil.getCurrentUser()
val todayQuestion = questionsRepository.queryQuestionDtoById(1L, user) ?: throw QuestionNotFoundException
val todayQuestion = questionsRepository.queryQuestionDto(user = user).get(0)
return QuestionResponse.of(todayQuestion)
}

Expand Down

0 comments on commit c87c76d

Please sign in to comment.