@@ -16,6 +16,8 @@ import com.pokit.out.persistence.content.persist.QContentEntity.contentEntity
1616import com.pokit.out.persistence.content.persist.QReportedContentEntity.reportedContentEntity
1717import com.pokit.out.persistence.content.persist.toDomain
1818import com.pokit.out.persistence.log.persist.QUserLogEntity.userLogEntity
19+ import com.pokit.out.persistence.user.persist.QUserEntity.userEntity
20+ import com.pokit.out.persistence.user.persist.QUserImageEntity.userImageEntity
1921import com.pokit.user.model.InterestType
2022import com.querydsl.core.types.OrderSpecifier
2123import com.querydsl.core.types.Predicate
@@ -71,11 +73,20 @@ class ContentAdapter(
7173 reportedContentEntity.isDeleted.isFalse
7274 )
7375
74- val query = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count(), bookmarkEntity.count())
76+ val query = queryFactory.select(
77+ contentEntity,
78+ categoryEntity.name,
79+ userLogEntity.count(),
80+ bookmarkEntity.count(),
81+ userEntity.nickname,
82+ userImageEntity.url
83+ )
7584 .from(contentEntity)
7685 .leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id))
7786 .join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId))
7887 .leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id).and (bookmarkEntity.deleted.isFalse))
88+ .join(userEntity).on(userEntity.id.eq(contentEntity.userId))
89+ .leftJoin(userImageEntity).on(userImageEntity.id.eq(userEntity.image.id))
7990
8091 if (condition.favorites == true ) { // 즐겨찾기 필터링
8192 query.where(bookmarkEntity.isNotNull)
@@ -92,7 +103,7 @@ class ContentAdapter(
92103 containsWord(condition.searchWord),
93104 )
94105 .offset(pageable.offset)
95- .groupBy(contentEntity)
106+ .groupBy(contentEntity, userEntity.nickname, userImageEntity.url )
96107 .orderBy(getSortOrder(contentEntity.createdAt, " createdAt" , pageable))
97108 .limit(pageable.pageSize + 1L )
98109
@@ -105,26 +116,37 @@ class ContentAdapter(
105116 it[contentEntity]!! .toDomain(),
106117 it[categoryEntity.name]!! ,
107118 it[userLogEntity.count()]!! ,
108- it[bookmarkEntity.count()]!!
119+ it[bookmarkEntity.count()]!! ,
120+ it[userEntity.nickname]!! ,
121+ it[userImageEntity.url]
109122 )
110123 }
111124
112125 return SliceImpl (contents, pageable, hasNext)
113126 }
114127
115128 override fun loadByUserIdAndCategoryName (userId : Long , categoryName : String , pageable : Pageable ): Slice <ContentsResult > {
116- val contents = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count(), bookmarkEntity.count())
129+ val contents = queryFactory.select(
130+ contentEntity,
131+ categoryEntity.name,
132+ userLogEntity.count(),
133+ bookmarkEntity.count(),
134+ userEntity.nickname,
135+ userImageEntity.url
136+ )
117137 .from(contentEntity)
118138 .leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id))
119139 .join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId))
120140 .leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id).and (bookmarkEntity.deleted.isFalse))
141+ .join(userEntity).on(userEntity.id.eq(contentEntity.userId))
142+ .leftJoin(userImageEntity).on(userImageEntity.id.eq(userEntity.image.id))
121143 .where(
122144 categoryEntity.userId.eq(userId),
123145 categoryEntity.name.eq(categoryName),
124146 contentEntity.deleted.isFalse,
125147 )
126148 .offset(pageable.offset)
127- .groupBy(contentEntity)
149+ .groupBy(contentEntity, userEntity.nickname, userImageEntity.url )
128150 .limit((pageable.pageSize + 1 ).toLong())
129151 .orderBy(getSortOrder(contentEntity.createdAt, " createdAt" , pageable))
130152 .fetch()
@@ -136,28 +158,39 @@ class ContentAdapter(
136158 it[contentEntity]!! .toDomain(),
137159 it[categoryEntity.name]!! ,
138160 it[userLogEntity.count()]!! ,
139- it[bookmarkEntity.count()]!!
161+ it[bookmarkEntity.count()]!! ,
162+ it[userEntity.nickname]!! ,
163+ it[userImageEntity.url]
140164 )
141165 }
142166
143167 return SliceImpl (contentResults, pageable, hasNext)
144168 }
145169
146170 override fun loadBookmarkedContentsByUserId (userId : Long , pageable : Pageable ): Slice <ContentsResult > {
147- val contents = queryFactory.select(contentEntity, categoryEntity.name, userLogEntity.count(), bookmarkEntity.count())
171+ val contents = queryFactory.select(
172+ contentEntity,
173+ categoryEntity.name,
174+ userLogEntity.count(),
175+ bookmarkEntity.count(),
176+ userEntity.nickname,
177+ userImageEntity.url
178+ )
148179 .from(contentEntity)
149180 .leftJoin(userLogEntity).on(userLogEntity.contentId.eq(contentEntity.id))
150181 .join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId))
151182 .leftJoin(reportedContentEntity).on(reportedContentEntity.contentId.eq(contentEntity.id))
152183 .leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id).and (bookmarkEntity.deleted.isFalse))
184+ .join(userEntity).on(userEntity.id.eq(contentEntity.userId))
185+ .leftJoin(userImageEntity).on(userImageEntity.id.eq(userEntity.image.id))
153186 .where(
154187 categoryEntity.userId.eq(userId),
155188 reportedContentEntity.reporterId.ne(userId).or (reportedContentEntity.reporterId.isNull),
156189 contentEntity.deleted.isFalse,
157190 bookmarkEntity.deleted.isFalse,
158191 )
159192 .offset(pageable.offset)
160- .groupBy(contentEntity)
193+ .groupBy(contentEntity, userEntity.nickname, userImageEntity.url )
161194 .limit((pageable.pageSize + 1 ).toLong())
162195 .orderBy(getSortOrder(contentEntity.createdAt, " createdAt" , pageable))
163196 .fetch()
@@ -169,7 +202,9 @@ class ContentAdapter(
169202 it[contentEntity]!! .toDomain(),
170203 it[categoryEntity.name]!! ,
171204 it[userLogEntity.count()]!! ,
172- it[bookmarkEntity.count()]!!
205+ it[bookmarkEntity.count()]!! ,
206+ it[userEntity.nickname]!! ,
207+ it[userImageEntity.url]
173208 )
174209 }
175210
@@ -230,10 +265,18 @@ class ContentAdapter(
230265 }
231266
232267 override fun loadAllByKeyword (userId : Long , searchKeywords : List <InterestType >, pageable : Pageable ): Slice <ContentsResult > {
233- val contents = queryFactory.select(contentEntity, categoryEntity.name, categoryEntity.keyword)
268+ val contents = queryFactory.select(
269+ contentEntity,
270+ categoryEntity.name,
271+ categoryEntity.keyword,
272+ userEntity.nickname,
273+ userImageEntity.url
274+ )
234275 .from(contentEntity)
235276 .join(categoryEntity).on(contentEntity.categoryId.eq(categoryEntity.id))
236277 .leftJoin(reportedContentEntity).on(reportedContentEntity.contentId.eq(contentEntity.id))
278+ .join(userEntity).on(userEntity.id.eq(contentEntity.userId))
279+ .leftJoin(userImageEntity).on(userImageEntity.id.eq(userEntity.image.id))
237280 .where(
238281 reportedContentEntity.reporterId.ne(userId).or (reportedContentEntity.reporterId.isNull),
239282 categoryEntity.openType.eq(OpenType .PUBLIC ),
@@ -242,7 +285,7 @@ class ContentAdapter(
242285 contentEntity.deleted.isFalse
243286 )
244287 .offset(pageable.offset)
245- .groupBy(contentEntity)
288+ .groupBy(contentEntity, userEntity.nickname, userImageEntity.url )
246289 .limit((pageable.pageSize + 1 ).toLong())
247290 .orderBy(getSortOrder(contentEntity.createdAt, " createdAt" , pageable))
248291 .fetch()
@@ -253,8 +296,10 @@ class ContentAdapter(
253296 ContentsResult .of(
254297 it[contentEntity]!! .toDomain(),
255298 it[categoryEntity.name]!! ,
256- 0 ,
257- 0 ,
299+ 0L ,
300+ 0L ,
301+ it[userEntity.nickname]!! ,
302+ it[userImageEntity.url],
258303 it[categoryEntity.keyword]!! .kor
259304 )
260305 }
0 commit comments