9
9
import com .jeju .nanaland .domain .common .data .Category ;
10
10
import com .jeju .nanaland .domain .common .data .Language ;
11
11
import com .jeju .nanaland .domain .common .dto .PostPreviewDto ;
12
+ import com .jeju .nanaland .domain .common .dto .QPostPreviewDto ;
12
13
import com .jeju .nanaland .domain .experience .dto .ExperienceCompositeDto ;
13
14
import com .jeju .nanaland .domain .experience .dto .ExperienceResponse ;
14
15
import com .jeju .nanaland .domain .experience .dto .QExperienceCompositeDto ;
@@ -38,7 +39,7 @@ public class ExperienceRepositoryImpl implements ExperienceRepositoryCustom {
38
39
private final JPAQueryFactory queryFactory ;
39
40
40
41
@ Override
41
- public ExperienceCompositeDto findCompositeDtoById (Long id , Language language ) {
42
+ public ExperienceCompositeDto findExperienceCompositeDto (Long id , Language language ) {
42
43
return queryFactory
43
44
.select (new QExperienceCompositeDto (
44
45
experience .id ,
@@ -60,7 +61,10 @@ public ExperienceCompositeDto findCompositeDtoById(Long id, Language language) {
60
61
.from (experience )
61
62
.leftJoin (experience .firstImageFile , imageFile )
62
63
.leftJoin (experience .experienceTrans , experienceTrans )
63
- .where (experience .id .eq (id ).and (experienceTrans .language .eq (language )))
64
+ .where (
65
+ experience .id .eq (id ),
66
+ experienceTrans .language .eq (language )
67
+ )
64
68
.fetchOne ();
65
69
}
66
70
@@ -92,10 +96,12 @@ public Page<ExperienceCompositeDto> searchCompositeDtoByKeyword(String keyword,
92
96
.leftJoin (experience .firstImageFile , imageFile )
93
97
.leftJoin (experience .experienceTrans , experienceTrans )
94
98
.on (experienceTrans .language .eq (language ))
95
- .where (experienceTrans .title .contains (keyword )
96
- .or (experienceTrans .addressTag .contains (keyword ))
97
- .or (experienceTrans .content .contains (keyword ))
98
- .or (experience .id .in (idListContainAllHashtags )))
99
+ .where (
100
+ experienceTrans .title .contains (keyword )
101
+ .or (experienceTrans .addressTag .contains (keyword ))
102
+ .or (experienceTrans .content .contains (keyword ))
103
+ .or (experience .id .in (idListContainAllHashtags ))
104
+ )
99
105
.orderBy (experienceTrans .createdAt .desc ())
100
106
.offset (pageable .getOffset ())
101
107
.limit (pageable .getPageSize ())
@@ -107,10 +113,12 @@ public Page<ExperienceCompositeDto> searchCompositeDtoByKeyword(String keyword,
107
113
.leftJoin (experience .firstImageFile , imageFile )
108
114
.leftJoin (experience .experienceTrans , experienceTrans )
109
115
.on (experienceTrans .language .eq (language ))
110
- .where (experienceTrans .title .contains (keyword )
111
- .or (experienceTrans .addressTag .contains (keyword ))
112
- .or (experienceTrans .content .contains (keyword ))
113
- .or (experience .id .in (idListContainAllHashtags )));
116
+ .where (
117
+ experienceTrans .title .contains (keyword )
118
+ .or (experienceTrans .addressTag .contains (keyword ))
119
+ .or (experienceTrans .content .contains (keyword ))
120
+ .or (experience .id .in (idListContainAllHashtags ))
121
+ );
114
122
115
123
return PageableExecutionUtils .getPage (resultDto , pageable , countQuery ::fetchOne );
116
124
}
@@ -134,12 +142,16 @@ public Page<ExperienceResponse.PreviewDto> findAllExperiencePreviewDtoOrderByPri
134
142
.innerJoin (experience .experienceTrans , experienceTrans )
135
143
.innerJoin (experienceKeyword )
136
144
.on (experienceKeyword .experience .id .eq (experience .id ))
137
- .where (experienceTrans .language .eq (language )
138
- .and (experience .experienceType .eq (experienceType )) // 이색체험 타입(액티비티/문화예술)
139
- .and (addressTagCondition (addressFilterList )) // 지역필터
140
- .and (keywordCondition (keywordFilterList ))) // 키워드 필터
141
- .orderBy (experience .priority .desc (), // 우선순위 정렬
142
- experience .createdAt .desc ()) // 최신순 정렬
145
+ .where (
146
+ experienceTrans .language .eq (language ),
147
+ experience .experienceType .eq (experienceType ), // 이색체험 타입(액티비티/문화예술)
148
+ addressTagCondition (addressFilterList ), // 지역필터
149
+ keywordCondition (keywordFilterList ) // 키워드 필터
150
+ )
151
+ .orderBy (
152
+ experience .priority .desc (), // 우선순위 정렬
153
+ experience .createdAt .desc () // 최신순 정렬
154
+ )
143
155
.offset (pageable .getOffset ())
144
156
.limit (pageable .getPageSize ())
145
157
.fetch ();
@@ -151,10 +163,12 @@ public Page<ExperienceResponse.PreviewDto> findAllExperiencePreviewDtoOrderByPri
151
163
.innerJoin (experience .experienceTrans , experienceTrans )
152
164
.innerJoin (experienceKeyword )
153
165
.on (experienceKeyword .experience .id .eq (experience .id ))
154
- .where (experienceTrans .language .eq (language )
155
- .and (experience .experienceType .eq (experienceType ))
156
- .and (addressTagCondition (addressFilterList ))
157
- .and (keywordCondition (keywordFilterList )));
166
+ .where (
167
+ experienceTrans .language .eq (language ),
168
+ experience .experienceType .eq (experienceType ),
169
+ addressTagCondition (addressFilterList ),
170
+ keywordCondition (keywordFilterList )
171
+ );
158
172
159
173
return PageableExecutionUtils .getPage (resultDto , pageable , countQuery ::fetchOne );
160
174
}
@@ -193,34 +207,34 @@ public List<Long> findAllIds() {
193
207
194
208
@ Override
195
209
public PostPreviewDto findPostPreviewDto (Long postId , Language language ) {
196
- // return queryFactory
197
- // .select(new QPostPreviewDto(
198
- // experience.id,
199
- // experienceTrans.title,
200
- // imageFile.originUrl,
201
- // imageFile.thumbnailUrl
202
- // ))
203
- // .from(experience)
204
- // .innerJoin(experience.experienceTrans, experienceTrans)
205
- // .innerJoin(experience.firstImageFile, imageFile)
206
- // .where(
207
- // experience.id.eq(postId),
208
- // experienceTrans.language.eq(language))
209
- // .fetchOne();
210
- return null ;
210
+ return queryFactory
211
+ .select (new QPostPreviewDto (
212
+ experience .id ,
213
+ experienceTrans .title ,
214
+ imageFile .originUrl ,
215
+ imageFile .thumbnailUrl
216
+ ))
217
+ .from (experience )
218
+ .innerJoin (experience .experienceTrans , experienceTrans )
219
+ .innerJoin (experience .firstImageFile , imageFile )
220
+ .where (
221
+ experience .id .eq (postId ),
222
+ experienceTrans .language .eq (language ))
223
+ .fetchOne ();
211
224
}
212
225
213
226
private List <Long > getIdListContainAllHashtags (String keyword , Language language ) {
214
227
return queryFactory
215
228
.select (experience .id )
216
229
.from (experience )
217
230
.leftJoin (hashtag )
218
- .on (hashtag .post .id .eq (experience .id )
219
- .and (hashtag .category .eq (Category .EXPERIENCE ))
220
- .and (hashtag .language .eq (language )))
231
+ .on (hashtag .post .id .eq (experience .id ),
232
+ hashtag .category .eq (Category .EXPERIENCE ),
233
+ hashtag .language .eq (language )
234
+ )
221
235
.where (hashtag .keyword .content .in (splitKeyword (keyword )))
222
236
.groupBy (experience .id )
223
- .having (experience .id .count ().eq (splitKeyword (keyword ).stream (). count ()))
237
+ .having (experience .id .count ().eq (( long ) splitKeyword (keyword ).size ()))
224
238
.fetch ();
225
239
}
226
240
@@ -235,18 +249,11 @@ private List<String> splitKeyword(String keyword) {
235
249
}
236
250
237
251
private BooleanExpression addressTagCondition (List <String > addressFilterList ) {
238
- if (addressFilterList .isEmpty ()) {
239
- return null ;
240
- } else {
241
- return experienceTrans .addressTag .in (addressFilterList );
242
- }
252
+ return addressFilterList .isEmpty () ? null : experienceTrans .addressTag .in (addressFilterList );
243
253
}
244
254
245
255
private BooleanExpression keywordCondition (List <ExperienceTypeKeyword > keywordFilterList ) {
246
- if (keywordFilterList .isEmpty ()) {
247
- return null ;
248
- } else {
249
- return experienceKeyword .experienceTypeKeyword .in (keywordFilterList );
250
- }
256
+ return keywordFilterList .isEmpty () ? null
257
+ : experienceKeyword .experienceTypeKeyword .in (keywordFilterList );
251
258
}
252
259
}
0 commit comments