Skip to content

Commit

Permalink
🎨 ai 통신 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
uuuuuuuk committed Apr 16, 2024
1 parent 8b484ad commit f1b2763
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import andreas311.miso.domain.recyclables.domain.RecyclablesType
import andreas311.miso.thirdparty.aws.s3.util.S3Util
import org.springframework.beans.factory.annotation.Value
import org.springframework.web.multipart.MultipartFile
import org.springframework.web.reactive.function.BodyInserters
import org.springframework.web.reactive.function.client.WebClient

@ReadOnlyRollbackService
Expand All @@ -23,13 +24,16 @@ class ProcessRecyclablesService(
private val url: String = ""

override fun execute(multipartFile: MultipartFile): ListDetailRecyclablesDto {
val resultList = webClient.post()
.uri(url)
.bodyValue(s3Util.execute(multipartFile))
.retrieve()
.bodyToMono(List::class.java)
.map { it as List<String> }
.block() ?: throw RecyclablesNotFoundException()
val imageUrl = s3Util.execute(multipartFile)

val resultList =
webClient.post()
.uri(url)
.body(BodyInserters.fromValue(mapOf("imageURL" to imageUrl)))
.retrieve()
.bodyToMono(List::class.java)
.map { it as List<String> }
.block() ?: throw RecyclablesNotFoundException()

val detailRecyclablesList = resultList.map { recyclablesType ->
queryRecyclablesPort.findByRecyclablesTypeOrNull(RecyclablesType.valueOf(recyclablesType))
Expand All @@ -39,4 +43,4 @@ class ProcessRecyclablesService(

return ListDetailRecyclablesDto(recyclablesList)
}
}
}

0 comments on commit f1b2763

Please sign in to comment.