diff --git a/piikii-application/src/main/kotlin/com/piikii/application/domain/generic/ThumbnailLinks.kt b/piikii-application/src/main/kotlin/com/piikii/application/domain/generic/ThumbnailLinks.kt index af3b66b1..7c01d702 100644 --- a/piikii-application/src/main/kotlin/com/piikii/application/domain/generic/ThumbnailLinks.kt +++ b/piikii-application/src/main/kotlin/com/piikii/application/domain/generic/ThumbnailLinks.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonProperty import java.io.Serializable -class ThumbnailLinks( +data class ThumbnailLinks( @JsonIgnore val contents: String?, ) : Serializable { diff --git a/piikii-application/src/main/kotlin/com/piikii/application/domain/place/OriginPlace.kt b/piikii-application/src/main/kotlin/com/piikii/application/domain/place/OriginPlace.kt index 33c1ac3f..ac4bc1de 100644 --- a/piikii-application/src/main/kotlin/com/piikii/application/domain/place/OriginPlace.kt +++ b/piikii-application/src/main/kotlin/com/piikii/application/domain/place/OriginPlace.kt @@ -3,7 +3,7 @@ package com.piikii.application.domain.place import com.piikii.application.domain.generic.Origin import com.piikii.application.domain.generic.ThumbnailLinks -class OriginPlace( +data class OriginPlace( val originMapId: Long, val url: String, val thumbnailLinks: ThumbnailLinks, diff --git a/piikii-application/src/main/kotlin/com/piikii/application/port/output/web/UrlClient.kt b/piikii-application/src/main/kotlin/com/piikii/application/port/output/web/UrlClient.kt new file mode 100644 index 00000000..8c435869 --- /dev/null +++ b/piikii-application/src/main/kotlin/com/piikii/application/port/output/web/UrlClient.kt @@ -0,0 +1,7 @@ +package com.piikii.application.port.output.web + +import com.piikii.application.domain.place.OriginPlace + +interface UrlClient { + fun get(url: String): OriginPlace +} diff --git a/piikii-bootstrap/build.gradle.kts b/piikii-bootstrap/build.gradle.kts index 16090e1f..1b6fce3a 100644 --- a/piikii-bootstrap/build.gradle.kts +++ b/piikii-bootstrap/build.gradle.kts @@ -5,6 +5,8 @@ dependencies { implementation(project(":piikii-output-cache:redis")) implementation(project(":piikii-output-cache:caffeine")) implementation(project(":piikii-output-storage:ncp")) + implementation(project(":piikii-output-web:avocado")) + implementation(project(":piikii-output-web:lemon")) implementation("org.springframework.boot:spring-boot-starter-web") } diff --git a/piikii-bootstrap/src/main/kotlin/com/piikii/bootstrap/PiikiiBootstrapApplication.kt b/piikii-bootstrap/src/main/kotlin/com/piikii/bootstrap/PiikiiBootstrapApplication.kt index aee4a7cf..a9222675 100644 --- a/piikii-bootstrap/src/main/kotlin/com/piikii/bootstrap/PiikiiBootstrapApplication.kt +++ b/piikii-bootstrap/src/main/kotlin/com/piikii/bootstrap/PiikiiBootstrapApplication.kt @@ -5,7 +5,7 @@ import org.springframework.boot.context.properties.ConfigurationPropertiesScan import org.springframework.boot.runApplication @SpringBootApplication(scanBasePackages = ["com.piikii"]) -@ConfigurationPropertiesScan("com.piikii.output.storage.ncp.config") +@ConfigurationPropertiesScan("com.piikii.output.storage.ncp.config", "com.piikii.output.web.lemon.config") class PiikiiBootstrapApplication fun main(args: Array) { diff --git a/piikii-bootstrap/src/main/resources/application.yml b/piikii-bootstrap/src/main/resources/application.yml index cc1c7be2..f26f35ec 100644 --- a/piikii-bootstrap/src/main/resources/application.yml +++ b/piikii-bootstrap/src/main/resources/application.yml @@ -3,6 +3,7 @@ spring: import: - classpath:http-config/application.yml - classpath:storage-config/application.yml + - classpath:lemon-config/application.yml application: name: "piikii" messages: diff --git a/piikii-common/src/main/kotlin/com/piikii/common/exception/ExceptionCode.kt b/piikii-common/src/main/kotlin/com/piikii/common/exception/ExceptionCode.kt index 5a1cd16c..677adc61 100644 --- a/piikii-common/src/main/kotlin/com/piikii/common/exception/ExceptionCode.kt +++ b/piikii-common/src/main/kotlin/com/piikii/common/exception/ExceptionCode.kt @@ -16,4 +16,5 @@ enum class ExceptionCode( // 500 SECRET_MANAGER_CONFIG_NOT_SET(500, "시크릿 매니저 설정 값이 입력되지 않았습니다."), + URL_PROCESS_ERROR(500, "URL에 해당하는 장소의 정보를 불러오는 중 예기치 못한 오류가 발생했습니다."), } diff --git a/piikii-output-web/build.gradle.kts b/piikii-output-web/build.gradle.kts new file mode 100644 index 00000000..a93e47ee --- /dev/null +++ b/piikii-output-web/build.gradle.kts @@ -0,0 +1,25 @@ +project(":piikii-output-web:avocado") { + dependencies { + implementation("org.springframework:spring-web") + } +} + +project(":piikii-output-web:lemon") { + dependencies { + implementation("org.springframework:spring-web") + } +} + +allprojects { + dependencies { + implementation(project(":piikii-application")) + } + + tasks.bootJar { + enabled = false + } + + tasks.jar { + enabled = true + } +} diff --git a/piikii-output-web/lemon/src/main/kotlin/com/piikii/output/web/lemon/UrlClientResponse.kt b/piikii-output-web/lemon/src/main/kotlin/com/piikii/output/web/lemon/UrlClientResponse.kt new file mode 100644 index 00000000..b4acad8a --- /dev/null +++ b/piikii-output-web/lemon/src/main/kotlin/com/piikii/output/web/lemon/UrlClientResponse.kt @@ -0,0 +1,135 @@ +package com.piikii.output.web.lemon + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.piikii.application.domain.generic.Origin +import com.piikii.application.domain.generic.ThumbnailLinks +import com.piikii.application.domain.place.OriginPlace + +@JsonIgnoreProperties(ignoreUnknown = true) +data class UrlClientResponse( + val isMapUser: String?, + val isExist: Boolean?, + val basicInfo: BasicInfo, + val comment: Comment, + val menuInfo: MenuInfo, + val photo: Photo, +) { + fun toOriginPlace(url: String): OriginPlace { + val fullAddress = "${basicInfo.address.region.newaddrfullname} ${basicInfo.address.newaddr.newaddrfull}".trim() + return OriginPlace( + originMapId = basicInfo.cid, + url = url, + thumbnailLinks = ThumbnailLinks(basicInfo.mainphotourl), + address = fullAddress, + phoneNumber = basicInfo.phonenum, + starGrade = basicInfo.feedback.calculateStarGrade(), + origin = Origin.LEMON, + ) + } + + @JsonIgnoreProperties(ignoreUnknown = true) + data class BasicInfo( + val cid: Long, + val placenamefull: String, + val mainphotourl: String, + val phonenum: String, + val address: Address, + val homepage: String, + val category: Category, + val feedback: Feedback, + val openHour: OpenHour, + ) + + @JsonIgnoreProperties(ignoreUnknown = true) + data class Address( + val newaddr: NewAddress, + val region: Region, + val addrbunho: String? = null, + ) + + @JsonIgnoreProperties(ignoreUnknown = true) + data class NewAddress( + val newaddrfull: String, + val bsizonno: String, + ) + + @JsonIgnoreProperties(ignoreUnknown = true) + data class Region( + val name3: String, + val fullname: String, + val newaddrfullname: String, + ) + + @JsonIgnoreProperties(ignoreUnknown = true) + data class Category( + val catename: String, + val cate1name: String, + ) + + @JsonIgnoreProperties(ignoreUnknown = true) + data class Feedback( + val scoresum: Int, + val scorecnt: Int, + ) { + fun calculateStarGrade(): Float? = if (scorecnt > 0) scoresum.toFloat() / scorecnt else null + } + + @JsonIgnoreProperties(ignoreUnknown = true) + data class OpenHour( + val periodList: List, + ) + + @JsonIgnoreProperties(ignoreUnknown = true) + data class Period( + val periodName: String, + val timeList: List