Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ import org.springframework.data.jpa.repository.Query
import org.springframework.data.repository.query.Param

interface PlaceLikeRepository: JpaRepository<PlaceLike, Long> {
fun findAllByPlaceIn(placeList: List<Place>): List<PlaceLike>

@Query("""
SELECT pl
FROM PlaceLike pl
JOIN FETCH pl.user
WHERE pl.place IN :placeList
""")
fun findAllByPlaceInFetchUser(@Param("placeList") placeList: List<Place>): List<PlaceLike>

@Query("SELECT pl FROM PlaceLike pl WHERE pl.place IN :places")
fun findLikeByPlace(@Param("places") placeList: List<Place>): List<PlaceLike>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PlaceQueryService(
val placeIdList: List<Long> = placeList.mapNotNull { it.id }

// 좋아요 리스트 조회
val placeLikes: List<PlaceLike> = placeLikeRepository.findAllByPlaceIn(placeList)
val placeLikes: List<PlaceLike> = placeLikeRepository.findAllByPlaceInFetchUser(placeList)

// 좋아요 수 계산: Map<Long, Int>
val likeCountMap: Map<Long, Int> = placeLikes
Expand Down