From f5b5152c05fab500620c326fbfcecd3f7ef80c3f Mon Sep 17 00:00:00 2001 From: junyong Date: Wed, 10 Sep 2025 01:19:33 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AA=85=EC=86=8C=20=ED=98=BC=EC=9E=A1?= =?UTF-8?q?=EB=8F=84=20=EA=B8=B0=EB=B3=B8=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=A2=8B=EC=95=84=EC=9A=94=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busan/domain/place/dto/PlaceMapResponseDTO.kt | 3 ++- .../domain/place/repository/PlaceRepository.kt | 1 + .../place/service/PlaceCongestionQueryService.kt | 13 +++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/busanVibe/busan/domain/place/dto/PlaceMapResponseDTO.kt b/src/main/kotlin/busanVibe/busan/domain/place/dto/PlaceMapResponseDTO.kt index eeb9304..940f0d9 100644 --- a/src/main/kotlin/busanVibe/busan/domain/place/dto/PlaceMapResponseDTO.kt +++ b/src/main/kotlin/busanVibe/busan/domain/place/dto/PlaceMapResponseDTO.kt @@ -33,7 +33,8 @@ class PlaceMapResponseDTO { val address: String, @get:JsonProperty("is_open") val isOpen: Boolean, - val imgList: List + val imgList: List, + val isLike: Boolean ) @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) diff --git a/src/main/kotlin/busanVibe/busan/domain/place/repository/PlaceRepository.kt b/src/main/kotlin/busanVibe/busan/domain/place/repository/PlaceRepository.kt index 317bfad..7ffef07 100644 --- a/src/main/kotlin/busanVibe/busan/domain/place/repository/PlaceRepository.kt +++ b/src/main/kotlin/busanVibe/busan/domain/place/repository/PlaceRepository.kt @@ -52,6 +52,7 @@ interface PlaceRepository: JpaRepository { """ SELECT p FROM Place p LEFT JOIN FETCH p.placeImages + LEFT JOIN FETCH p.placeLikes pl WHERE p.id = :placeId """ ) diff --git a/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceCongestionQueryService.kt b/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceCongestionQueryService.kt index f5ed1c1..09f43be 100644 --- a/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceCongestionQueryService.kt +++ b/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceCongestionQueryService.kt @@ -2,12 +2,14 @@ package busanVibe.busan.domain.place.service import busanVibe.busan.domain.place.domain.Place import busanVibe.busan.domain.place.domain.PlaceImage +import busanVibe.busan.domain.place.domain.PlaceLike import busanVibe.busan.domain.place.domain.VisitorDistribution import busanVibe.busan.domain.place.dto.PlaceMapResponseDTO import busanVibe.busan.domain.place.enums.PlaceType import busanVibe.busan.domain.place.repository.PlaceRepository import busanVibe.busan.domain.place.repository.VisitorDistributionRepository import busanVibe.busan.domain.place.util.PlaceRedisUtil +import busanVibe.busan.domain.user.service.login.AuthService import busanVibe.busan.global.apiPayload.code.status.ErrorStatus import busanVibe.busan.global.apiPayload.exception.GeneralException import busanVibe.busan.global.apiPayload.exception.handler.ExceptionHandler @@ -83,8 +85,11 @@ class PlaceCongestionQueryService( // Image -> list // Redis -> congestion + // 유저 조회 + val currentUser = AuthService().getCurrentUser() + // 명소 조회 - val place: Place? = placeRepository.findByIdWithReviewAndImage(placeId) + val place: Place? = placeRepository.findByIdWithLIkeAndImage(placeId) place?: throw ExceptionHandler(ErrorStatus.PLACE_NOT_FOUND) // 이미지 조회 @@ -94,6 +99,9 @@ class PlaceCongestionQueryService( .filter { it.imgUrl.isNotBlank() } .map { it.imgUrl } + // 좋아요 조회 + val placeLikes: Set = place.placeLikes + val isLike = placeLikes.any { it.user.id == currentUser.id } return PlaceMapResponseDTO.PlaceDefaultInfoDto( id = place.id, @@ -103,7 +111,8 @@ class PlaceCongestionQueryService( longitude = place.longitude, address = place.address, isOpen = true, - imgList = placeImageList + imgList = placeImageList, + isLike = isLike ) }