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 @@ -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)

Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/busanVibe/busan/domain/place/domain/Place.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -157,3 +157,4 @@ class TourCommandService(
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down