diff --git a/src/main/kotlin/busanVibe/busan/domain/home/service/HomeQueryService.kt b/src/main/kotlin/busanVibe/busan/domain/home/service/HomeQueryService.kt index 0ccb39f..b655654 100644 --- a/src/main/kotlin/busanVibe/busan/domain/home/service/HomeQueryService.kt +++ b/src/main/kotlin/busanVibe/busan/domain/home/service/HomeQueryService.kt @@ -97,7 +97,7 @@ class HomeQueryService( val currentUser = AuthService().getCurrentUser() val places = placeRepository.findAllWithFetch() - return places.take(5).map { place -> + return places.shuffled().take(5).map { place -> val congestion = placeRedisUtil.getRedisCongestion(place.id) diff --git a/src/main/kotlin/busanVibe/busan/domain/place/domain/Place.kt b/src/main/kotlin/busanVibe/busan/domain/place/domain/Place.kt index 07a65f3..5f7ca42 100644 --- a/src/main/kotlin/busanVibe/busan/domain/place/domain/Place.kt +++ b/src/main/kotlin/busanVibe/busan/domain/place/domain/Place.kt @@ -2,6 +2,7 @@ package busanVibe.busan.domain.place.domain import busanVibe.busan.domain.common.BaseEntity import busanVibe.busan.domain.place.enums.PlaceType +import busanVibe.busan.domain.place.util.checkImageUrl import jakarta.persistence.CascadeType import jakarta.persistence.Column import jakarta.persistence.Entity @@ -66,8 +67,10 @@ class Place( ) : BaseEntity(){ fun addImage(imgUrl: String) { - val image = PlaceImage(imgUrl = imgUrl, place = this) - placeImages.add(image) + if(checkImageUrl(imgUrl)) { + val image = PlaceImage(imgUrl = imgUrl, place = this) + placeImages.add(image) + } } fun removeImage(image: PlaceImage) { diff --git a/src/main/kotlin/busanVibe/busan/domain/place/enums/PlaceType.kt b/src/main/kotlin/busanVibe/busan/domain/place/enums/PlaceType.kt index eb9145d..ac288aa 100644 --- a/src/main/kotlin/busanVibe/busan/domain/place/enums/PlaceType.kt +++ b/src/main/kotlin/busanVibe/busan/domain/place/enums/PlaceType.kt @@ -19,8 +19,8 @@ enum class PlaceType( ; companion object{ - fun fromTourApiTypeId(code: String): PlaceType? { - return values().find { it.tourApiTypeId == code } + fun fromTourApiTypeId(code: String?): PlaceType { + return values().find { it.tourApiTypeId == code } ?: SIGHT } } diff --git a/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceQueryService.kt b/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceQueryService.kt index a6c4ef1..33ee4ca 100644 --- a/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceQueryService.kt +++ b/src/main/kotlin/busanVibe/busan/domain/place/service/PlaceQueryService.kt @@ -11,7 +11,6 @@ import busanVibe.busan.domain.place.repository.PlaceImageRepository import busanVibe.busan.domain.place.repository.PlaceLikeRepository import busanVibe.busan.domain.place.repository.PlaceRepository import busanVibe.busan.domain.place.util.PlaceRedisUtil -import busanVibe.busan.domain.place.util.checkImageUrl import busanVibe.busan.domain.place.util.nullIfBlank import busanVibe.busan.domain.user.data.User import busanVibe.busan.domain.user.service.login.AuthService diff --git a/src/main/kotlin/busanVibe/busan/domain/tourApi/controller/TourAPIController.kt b/src/main/kotlin/busanVibe/busan/domain/tourApi/controller/TourAPIController.kt index 1a92c5a..e029f5b 100644 --- a/src/main/kotlin/busanVibe/busan/domain/tourApi/controller/TourAPIController.kt +++ b/src/main/kotlin/busanVibe/busan/domain/tourApi/controller/TourAPIController.kt @@ -23,7 +23,7 @@ class TourAPIController( } @PostMapping("/place") -// @Operation(hidden = true) + @Operation(hidden = true) fun savePlace(@RequestParam("place-type") placeType: PlaceType, @RequestParam("pageColumns") pageSize: Int, @RequestParam("page") pageNum: Int ){ tourCommandService.getPlace(placeType, pageSize, pageNum) } diff --git a/src/main/kotlin/busanVibe/busan/domain/tourApi/dto/TourPlaceImagesDTO.kt b/src/main/kotlin/busanVibe/busan/domain/tourApi/dto/TourPlaceImagesDTO.kt index 6851663..506caf8 100644 --- a/src/main/kotlin/busanVibe/busan/domain/tourApi/dto/TourPlaceImagesDTO.kt +++ b/src/main/kotlin/busanVibe/busan/domain/tourApi/dto/TourPlaceImagesDTO.kt @@ -19,7 +19,7 @@ data class PlaceImageHeader( ) data class PlaceImageBody( - val items: PlaceImageItems, + val items: PlaceImageItems?, val numOfRows: Int, val pageNo: Int, val totalCount: Int diff --git a/src/main/kotlin/busanVibe/busan/domain/tourApi/service/TourCommandService.kt b/src/main/kotlin/busanVibe/busan/domain/tourApi/service/TourCommandService.kt index 5484b1a..df173f3 100644 --- a/src/main/kotlin/busanVibe/busan/domain/tourApi/service/TourCommandService.kt +++ b/src/main/kotlin/busanVibe/busan/domain/tourApi/service/TourCommandService.kt @@ -65,7 +65,7 @@ class TourCommandService( val place = Place( contentId = apiItem.contentId, name = apiItem.title.orNoInfo().removeTag(), - type = placeType, + type = PlaceType.fromTourApiTypeId(apiItem.contentTypeId), latitude = apiItem.mapY?.toBigDecimal()?.setScale(4, RoundingMode.HALF_UP), longitude = apiItem.mapX?.toBigDecimal()?.setScale(4, RoundingMode.HALF_UP), address = apiItem.addr1.orNoInfo().removeTag(), @@ -157,3 +157,4 @@ class TourCommandService( } } + diff --git a/src/main/kotlin/busanVibe/busan/domain/tourApi/util/TourPlaceUtil.kt b/src/main/kotlin/busanVibe/busan/domain/tourApi/util/TourPlaceUtil.kt index 1a0df9c..d4e5230 100644 --- a/src/main/kotlin/busanVibe/busan/domain/tourApi/util/TourPlaceUtil.kt +++ b/src/main/kotlin/busanVibe/busan/domain/tourApi/util/TourPlaceUtil.kt @@ -40,6 +40,8 @@ class TourPlaceUtil( // json 변환 위한 objectMapper val objectMapper = jacksonObjectMapper() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true) + fun getPlace(placeType: PlaceType, pageSize: Int, pageNum: Int): PlaceApiResponseWrapper { val placeTypeCode = placeType.tourApiTypeId