diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/AnswersRepository.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/AnswersRepository.kt index d8ba209..0dc5495 100644 --- a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/AnswersRepository.kt +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/AnswersRepository.kt @@ -61,8 +61,8 @@ class CustomAnswerRepositoryImpl( private fun JPAQuery.getAnswerDetailDto(): MutableList { val like = QLike("likes") val dislike = QLike("dislikes") - return rightJoin(user).on(user.id.eq(answers.writer.id)) - .rightJoin(post).on(post.id.eq(answers.post.id)) + return innerJoin(user).on(user.id.eq(answers.writer.id)) + .innerJoin(post).on(post.id.eq(answers.post.id)) .leftJoin(like).on(like.post.id.eq(post.id).and(like.isLiked.isTrue)) .leftJoin(dislike).on(dislike.post.id.eq(post.id).and(dislike.isLiked.isFalse)) .leftJoin(comments).on(comments.post.eq(answers.post)) diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt index a7d3057..c92f43f 100644 --- a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt @@ -6,6 +6,7 @@ import com.querydsl.jpa.impl.JPAQueryFactory import kr.hs.dsm.inq.common.util.PageResponse import kr.hs.dsm.inq.common.util.PageUtil import kr.hs.dsm.inq.domain.question.persistence.* +import kr.hs.dsm.inq.domain.question.persistence.QAnswers.answers import kr.hs.dsm.inq.domain.question.persistence.QComments.comments import kr.hs.dsm.inq.domain.question.persistence.QFavorite.favorite import kr.hs.dsm.inq.domain.question.persistence.QPost.post @@ -112,8 +113,7 @@ class CustomQuestionSetsRepositoryImpl( .on(questionSolvingHistory.user.id.eq(user.id)).on(questionSolvingHistory.problem.eq(questionSets.problem)) .innerJoin(author).on(author.id.eq(questionSets.author.id)) .innerJoin(post).on(post.id.eq(questionSets.post.id)) - .rightJoin(favorite).on(favorite.problem.eq(questions.problem)) -// .rightJoin(answers).on(answers.writer.eq(user).and(answers.questions.eq(questions))) + .leftJoin(favorite).on(favorite.problem.id.eq(questionSets.problem.id).and(favorite.user.id.eq(user.id))) .transform( GroupBy.groupBy(questionSets.id) .list( diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionsRepository.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionsRepository.kt index 9a68fd9..4c91e85 100644 --- a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionsRepository.kt +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionsRepository.kt @@ -7,6 +7,7 @@ import kr.hs.dsm.inq.common.util.PageResponse import kr.hs.dsm.inq.common.util.PageUtil import kr.hs.dsm.inq.domain.question.persistence.Category import kr.hs.dsm.inq.domain.question.persistence.QAnswers.answers +import kr.hs.dsm.inq.domain.question.persistence.QFavorite import kr.hs.dsm.inq.domain.question.persistence.QFavorite.favorite import kr.hs.dsm.inq.domain.question.persistence.QQuestionSets import kr.hs.dsm.inq.domain.question.persistence.QQuestionSets.questionSets @@ -115,11 +116,11 @@ class CustomQuestionRepositoryImpl( private fun JPAQuery.getQuestionDto(user: User): MutableList { val writer = QUser("writer") - return innerJoin(questionTags).on(questionTags.problems.eq(questions.problem)) - .innerJoin(tags).on(tags.id.eq(questionTags.id.tagId)) + return leftJoin(questionTags).on(questionTags.problems.eq(questions.problem)) + .leftJoin(tags).on(tags.id.eq(questionTags.id.tagId)) .innerJoin(writer).on(writer.id.eq(questions.author.id)) - .rightJoin(favorite).on(favorite.problem.id.eq(questions.problem.id)) -// .rightJoin(answers).on(answers.writer.eq(user).and(answers.questions.eq(questions))) + .leftJoin(favorite).on(favorite.problem.id.eq(questions.problem.id).and(favorite.user.id.eq(user.id))) + .leftJoin(answers).on(answers.writer.id.eq(user.id).and(answers.questions.id.eq(questions.id))) .transform( GroupBy.groupBy(questions) .list( @@ -131,7 +132,7 @@ class CustomQuestionRepositoryImpl( /* job = */ writer.job, /* jobDuration = */ writer.jobDuration, /* tagList = */ GroupBy.list(tags), - /* isAnswered = */ questions.isNull, // answers.isNotNull, + /* isAnswered = */ answers.isNotNull, /* isFavorite = */ favorite.isNotNull, /* createdAt = */ questions.createdAt ) @@ -154,11 +155,11 @@ class CustomQuestionRepositoryImpl( val author = QUser("writer") - return@run rightJoin(questionTags).on(questionTags.problems.eq(questions.problem)) - .rightJoin(tags).on(tags.id.eq(questionTags.id.tagId)) - .rightJoin(favorite).on(favorite.id.problemId.eq(questions.problem.id)) -// .rightJoin(answers).on(answers.writer.eq(user).and(answers.questions.eq(questions))) - .rightJoin(author).on(author.eq(questions.author)) + return@run leftJoin(questionTags).on(questionTags.problems.eq(questions.problem)) + .leftJoin(tags).on(tags.id.eq(questionTags.id.tagId)) + .leftJoin(favorite).on(favorite.problem.id.eq(questions.problem.id)) + .leftJoin(answers).on(answers.writer.eq(user).and(answers.questions.eq(questions))) + .innerJoin(author).on(author.eq(questions.author)) .transform( GroupBy.groupBy(questions) .list( @@ -193,11 +194,10 @@ class CustomQuestionRepositoryImpl( fun JPAQuery.getUserQuestionListDto(user: User): List = run { val writer = QUser("writer") - return@run innerJoin(questionTags).on(questionTags.problems.eq(questions.problem)) - .innerJoin(tags).on(tags.id.eq(questionTags.id.tagId)) - .rightJoin(favorite).on(favorite.id.problemId.eq(questions.problem.id)) - .innerJoin(answers).on(answers.questions.id.eq(questions.id)) - .rightJoin(writer).on(writer.id.eq(user.id)) + return@run leftJoin(questionTags).on(questionTags.problems.eq(questions.problem)) + .leftJoin(tags).on(tags.id.eq(questionTags.id.tagId)) + .leftJoin(answers).on(answers.questions.id.eq(questions.id)) + .innerJoin(writer).on(writer.id.eq(user.id)) .transform( GroupBy.groupBy(questions) .list(