Skip to content

Commit abab3c3

Browse files
committed
[fix/#91] Q클래스 import문 추가
1 parent c134599 commit abab3c3

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

src/main/java/com/moplus/moplus_server/domain/problemset/repository/ProblemSetGetRepositoryCustom.java

+27-26
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.moplus.moplus_server.domain.problemset.repository;
22

3+
import static com.moplus.moplus_server.admin.publish.domain.QPublish.*;
4+
import static com.moplus.moplus_server.domain.concept.domain.QConceptTag.*;
5+
import static com.moplus.moplus_server.domain.problem.domain.problem.QProblem.*;
6+
37
import com.moplus.moplus_server.admin.problemset.dto.response.ProblemSetGetResponse;
48
import com.moplus.moplus_server.admin.problemset.dto.response.ProblemSummaryResponse;
5-
import com.moplus.moplus_server.admin.publish.domain.QPublish;
6-
import com.moplus.moplus_server.domain.concept.domain.QConceptTag;
7-
import com.moplus.moplus_server.domain.problem.domain.problem.QProblem;
89
import com.moplus.moplus_server.domain.problemset.domain.ProblemSet;
910
import com.querydsl.core.Tuple;
1011
import com.querydsl.jpa.impl.JPAQueryFactory;
@@ -22,51 +23,51 @@ public class ProblemSetGetRepositoryCustom {
2223
public ProblemSetGetResponse getProblemSet(ProblemSet problemSet) {
2324
// 발행 날짜 조회 쿼리
2425
List<LocalDate> publishedDates = queryFactory
25-
.select(QPublish.publish.publishedDate)
26-
.from(QPublish.publish)
27-
.where(QPublish.publish.problemSetId.eq(problemSet.getId()))
26+
.select(publish.publishedDate)
27+
.from(publish)
28+
.where(publish.problemSetId.eq(problemSet.getId()))
2829
.fetch();
2930

3031
// 문제 조회 쿼리 (문제 자체 정보만 조회)
3132
List<Tuple> problemData = queryFactory
3233
.select(
33-
QProblem.problem.id,
34-
QProblem.problem.problemCustomId.id,
35-
QProblem.problem.title.title,
36-
QProblem.problem.memo,
37-
QProblem.problem.mainProblemImageUrl
34+
problem.id,
35+
problem.problemCustomId.id,
36+
problem.title.title,
37+
problem.memo,
38+
problem.mainProblemImageUrl
3839
)
39-
.from(QProblem.problem)
40-
.where(QProblem.problem.id.in(problemSet.getProblemIds()))
40+
.from(problem)
41+
.where(problem.id.in(problemSet.getProblemIds()))
4142
.distinct()
4243
.fetch();
4344

4445
// 태그 조회 쿼리 (각 문제별 태그만 조회)
4546
Map<Long, Set<String>> conceptTagMap = queryFactory
46-
.select(QProblem.problem.id, QConceptTag.conceptTag.name)
47-
.from(QProblem.problem)
48-
.leftJoin(QConceptTag.conceptTag)
49-
.on(QConceptTag.conceptTag.id.in(QProblem.problem.conceptTagIds))
50-
.where(QProblem.problem.id.in(problemSet.getProblemIds()))
47+
.select(problem.id, conceptTag.name)
48+
.from(problem)
49+
.leftJoin(conceptTag)
50+
.on(conceptTag.id.in(problem.conceptTagIds))
51+
.where(problem.id.in(problemSet.getProblemIds()))
5152
.fetch()
5253
.stream()
5354
.collect(
5455
HashMap::new,
5556
(map, tuple) -> map
56-
.computeIfAbsent(tuple.get(QProblem.problem.id), k -> new HashSet<>())
57-
.add(tuple.get(QConceptTag.conceptTag.name)),
57+
.computeIfAbsent(tuple.get(problem.id), k -> new HashSet<>())
58+
.add(tuple.get(conceptTag.name)),
5859
HashMap::putAll
5960
);
6061

6162
// 문제 요약 정보 생성
6263
List<ProblemSummaryResponse> problemSummaries = problemData.stream()
6364
.map(tuple -> ProblemSummaryResponse.builder()
64-
.problemId(tuple.get(QProblem.problem.id))
65-
.problemCustomId(tuple.get(QProblem.problem.problemCustomId.id))
66-
.problemTitle(tuple.get(QProblem.problem.title.title))
67-
.memo(tuple.get(QProblem.problem.memo))
68-
.mainProblemImageUrl(tuple.get(QProblem.problem.mainProblemImageUrl))
69-
.tagNames(conceptTagMap.getOrDefault(tuple.get(QProblem.problem.id), new HashSet<>()))
65+
.problemId(tuple.get(problem.id))
66+
.problemCustomId(tuple.get(problem.problemCustomId.id))
67+
.problemTitle(tuple.get(problem.title.title))
68+
.memo(tuple.get(problem.memo))
69+
.mainProblemImageUrl(tuple.get(problem.mainProblemImageUrl))
70+
.tagNames(conceptTagMap.getOrDefault(tuple.get(problem.id), new HashSet<>()))
7071
.build()
7172
)
7273
.toList();

0 commit comments

Comments
 (0)