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
@@ -0,0 +1,21 @@
package com.pida.client.map

import com.pida.place.LandmarkCategory

private enum class KakaoCategoryCode(
val landmarkCategory: LandmarkCategory,
) {
SW8(LandmarkCategory.SUBWAY),
AT4(LandmarkCategory.TOUR_SPOT),
CE7(LandmarkCategory.CAFE),
FD6(LandmarkCategory.RESTAURANT),
;

companion object {
private val CODE_MAP = entries.associateBy { it.name }

fun from(code: String): KakaoCategoryCode? = CODE_MAP[code]
}
}

fun KakaoPlaceDocument.toLandmarkCategory(): LandmarkCategory? = KakaoCategoryCode.from(categoryGroupCode)?.landmarkCategory
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class KakaoMapClient internal constructor(
x = document.x.toDouble(),
y = document.y.toDouble(),
region = document.addressName.toRegion(),
category = document.toLandmarkCategory(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ data class Landmark(
val address: String?,
val pinPoint: GeoJson, // Point GeoJson
val region: Region,
val category: LandmarkCategory?,
val deletedAt: LocalDateTime?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pida.place

enum class LandmarkCategory {
SUBWAY,
RESTAURANT,
CAFE,
TOUR_SPOT,
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data class NewLandmark(
val x: Double,
val y: Double,
val region: Region,
val category: LandmarkCategory?,
) {
fun toLandmark(): Landmark =
Landmark(
Expand All @@ -17,6 +18,7 @@ data class NewLandmark(
address = address,
pinPoint = GeoJson.Point(listOf(x, y)),
region = region,
category = category,
deletedAt = null,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class PlaceFacade(
private const val MIN_LANDMARK_SEARCH_COUNT = 2
private const val MAX_LANDMARK_SEARCH_COUNT = 5
private val SEARCH_REGIONS = setOf(Region.SEOUL, Region.GYEONGGI)
private val LANDMARK_CATEGORY_PRIORITY =
listOf(
LandmarkCategory.SUBWAY,
// ์ •๋ ฌ ์šฐ์„ ์ˆœ์œ„ ์—ฌ๊ธฐ์— ์ถ”๊ฐ€
)
}

suspend fun search(
Expand Down Expand Up @@ -50,7 +55,11 @@ class PlaceFacade(

PlaceSearchResult(
districts = districtsDeferred.await().take(MAX_DISTRICT_SEARCH_COUNT),
landmarks = landmarks.filter { it.region in SEARCH_REGIONS }.take(MAX_LANDMARK_SEARCH_COUNT),
landmarks =
landmarks
.filter { it.region in SEARCH_REGIONS }
.sortedBy { LANDMARK_CATEGORY_PRIORITY.indexOf(it.category).takeIf { i -> i >= 0 } ?: Int.MAX_VALUE }
.take(MAX_LANDMARK_SEARCH_COUNT),
flowerSpots = flowerSpotsDeferred.await(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LandmarkCoreRepository(
address = it.address,
pinPoint = GEOMETRY_FACTORY.createPoint(Coordinate(it.x, it.y)),
region = it.region,
category = it.category,
)
}
landmarkJpaRepository.saveAll(entities)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pida.storage.db.core.landmark

import com.pida.place.Landmark
import com.pida.place.LandmarkCategory
import com.pida.storage.db.core.support.BaseEntity
import com.pida.support.geo.GeoJson
import com.pida.support.geo.Region
Expand Down Expand Up @@ -28,6 +29,9 @@ class LandmarkEntity(
@Enumerated(value = EnumType.STRING)
@Column(columnDefinition = "varchar(50)")
val region: Region,
@Enumerated(value = EnumType.STRING)
@Column(columnDefinition = "varchar(50)")
val category: LandmarkCategory? = null,
) : BaseEntity() {
fun toLandmark(): Landmark =
Landmark(
Expand All @@ -36,6 +40,7 @@ class LandmarkEntity(
address = address,
pinPoint = GeoJson.Point(listOf(pinPoint.x, pinPoint.y)),
region = region,
category = category,
deletedAt = deletedAt,
)
}
Loading