Skip to content

Commit fd7c7cf

Browse files
authored
feat : 북마크 필터링 시 북마크 not null 조건 추가 (#267)
1 parent 3fd5ca4 commit fd7c7cf

File tree

1 file changed

+3
-20
lines changed
  • adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl

1 file changed

+3
-20
lines changed

adapters/out-persistence/src/main/kotlin/com/pokit/out/persistence/content/impl/ContentAdapter.kt

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ import com.pokit.out.persistence.content.persist.QReportedContentEntity.reported
1717
import com.pokit.out.persistence.content.persist.toDomain
1818
import com.pokit.out.persistence.log.persist.QUserLogEntity.userLogEntity
1919
import com.pokit.user.model.InterestType
20-
import com.querydsl.core.Tuple
2120
import com.querydsl.core.types.OrderSpecifier
2221
import com.querydsl.core.types.Predicate
2322
import com.querydsl.core.types.dsl.DateTimePath
24-
import com.querydsl.jpa.impl.JPAQuery
2523
import com.querydsl.jpa.impl.JPAQueryFactory
2624
import org.springframework.data.domain.Pageable
2725
import org.springframework.data.domain.Slice
@@ -79,7 +77,9 @@ class ContentAdapter(
7977
.join(categoryEntity).on(categoryEntity.id.eq(contentEntity.categoryId))
8078
.leftJoin(bookmarkEntity).on(bookmarkEntity.contentId.eq(contentEntity.id).and(bookmarkEntity.deleted.isFalse))
8179

82-
FavoriteOrNot(condition.favorites, userId, query) // 북마크 조인 여부
80+
if(condition.favorites == true) { // 즐겨찾기 필터링
81+
query.where(bookmarkEntity.isNotNull)
82+
}
8383

8484
query.where(
8585
if (isPrivate) categoryEntity.userId.eq(userId) else null,
@@ -336,23 +336,6 @@ class ContentAdapter(
336336
contentRepository.deleteByUserId(userId)
337337
}
338338

339-
private fun FavoriteOrNot(
340-
favorites: Boolean?,
341-
userId: Long,
342-
query: JPAQuery<Tuple>
343-
): JPAQuery<Tuple>? {
344-
return favorites
345-
?.let {
346-
query
347-
.join(bookmarkEntity)
348-
.on(
349-
bookmarkEntity.contentId.eq(contentEntity.id)
350-
.and(bookmarkEntity.deleted.isFalse)
351-
)
352-
.where(categoryEntity.userId.eq(userId))
353-
}
354-
}
355-
356339
private fun getSortOrder(property: DateTimePath<LocalDateTime>, sortField: String, pageable: Pageable): OrderSpecifier<*> {
357340
val order = pageable.sort.getOrderFor(sortField)
358341
?.direction

0 commit comments

Comments
 (0)