Skip to content

Commit

Permalink
feat: parse open hour from avocado/lemon
Browse files Browse the repository at this point in the history
  • Loading branch information
KimDoubleB committed Aug 18, 2024
1 parent 6307dee commit 956d9ef
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data class AvocadoPlaceInfoResponse(
val businessType: String?,
val category: String?,
val microReview: String?,
val businessHours: String?,
val buttons: Buttons,
@JsonProperty("x")
val longitude: Double?,
Expand All @@ -40,6 +41,7 @@ data class AvocadoPlaceInfoResponse(
latitude = latitude,
reviewCount = visitorReviewCount ?: 0,
category = category,
openingHours = businessHours,
origin = Origin.AVOCADO,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ data class LemonPlaceInfoResponse(
latitude = basicInfo.latitude,
reviewCount = basicInfo.feedback.countOfBlogReview,
category = basicInfo.category.firstCategoryName,
openingHours = basicInfo.openHour.toPrintFormat(),
origin = Origin.LEMON,
)
}
Expand Down Expand Up @@ -106,13 +107,33 @@ data class LemonPlaceInfoResponse(
@JsonIgnoreProperties(ignoreUnknown = true)
data class OpenHour(
val periodList: List<Period>?,
)
val offdayList: List<Offday>?,
) {
fun toPrintFormat(): String? {
val openingHour = periodList
?.first { it.periodName == OPEN_HOUR_PERIOD_NAME }
?.toPrintFormat()
val offdaySchedule = offdayList
?.map { it.toPrintFormat() }
?.joinToString { JOINER }
return "$openingHour$JOINER$offdaySchedule"
}

companion object {
const val OPEN_HOUR_PERIOD_NAME = "영업기간"
const val JOINER = "\n"
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
data class Period(
val periodName: String,
val timeList: List<Time>?,
)
) {
fun toPrintFormat(): String? {
return timeList?.joinToString(OpenHour.JOINER) { "${it.timeName}: ${it.dayOfWeek} ${it.timeSE}" }
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
data class Time(
Expand All @@ -121,6 +142,17 @@ data class LemonPlaceInfoResponse(
val dayOfWeek: String,
)

@JsonIgnoreProperties(ignoreUnknown = true)
data class Offday(
val holidayName: String,
val weekAndDay: String,
val temporaryHolidays: String,
) {
fun toPrintFormat(): String {
return "$holidayName: $weekAndDay"
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
data class Comment(
val kamapComntcnt: Int,
Expand Down

0 comments on commit 956d9ef

Please sign in to comment.