1
1
package com .moplus .moplus_server .domain .problemset .repository ;
2
2
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
+
3
7
import com .moplus .moplus_server .admin .problemset .dto .response .ProblemSetGetResponse ;
4
8
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 ;
8
9
import com .moplus .moplus_server .domain .problemset .domain .ProblemSet ;
9
10
import com .querydsl .core .Tuple ;
10
11
import com .querydsl .jpa .impl .JPAQueryFactory ;
@@ -22,51 +23,51 @@ public class ProblemSetGetRepositoryCustom {
22
23
public ProblemSetGetResponse getProblemSet (ProblemSet problemSet ) {
23
24
// 발행 날짜 조회 쿼리
24
25
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 ()))
28
29
.fetch ();
29
30
30
31
// 문제 조회 쿼리 (문제 자체 정보만 조회)
31
32
List <Tuple > problemData = queryFactory
32
33
.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
38
39
)
39
- .from (QProblem . problem )
40
- .where (QProblem . problem .id .in (problemSet .getProblemIds ()))
40
+ .from (problem )
41
+ .where (problem .id .in (problemSet .getProblemIds ()))
41
42
.distinct ()
42
43
.fetch ();
43
44
44
45
// 태그 조회 쿼리 (각 문제별 태그만 조회)
45
46
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 ()))
51
52
.fetch ()
52
53
.stream ()
53
54
.collect (
54
55
HashMap ::new ,
55
56
(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 )),
58
59
HashMap ::putAll
59
60
);
60
61
61
62
// 문제 요약 정보 생성
62
63
List <ProblemSummaryResponse > problemSummaries = problemData .stream ()
63
64
.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 <>()))
70
71
.build ()
71
72
)
72
73
.toList ();
0 commit comments