Skip to content

Commit

Permalink
modify :: pic response
Browse files Browse the repository at this point in the history
  • Loading branch information
meltapplee committed Nov 20, 2024
1 parent 8bf6a31 commit 1193e70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package org.meogo.domain.review.presentation.dto.response

data class ReviewPictureResponse(
val year: Int,
val image: String
val image: List<String>
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ class QueryReviewPictureService(
@Transactional
fun queryReviewPicture(schoolId: Int): List<ReviewPictureResponse> {
val reviews = reviewRepository.findAllBySchoolId(schoolId)?.sortedByDescending { it.id } ?: return emptyList()

val pictures = reviews
println(reviews)
val picturesByYear = reviews
.flatMap { review ->
val year = review.date.year
review.picture?.split(",")?.map { pic ->
val pictureUrl = fileUtil.generateObjectUrl(pic.trim(), Path.REVIEW)
ReviewPictureResponse(year, pictureUrl)
val imgUrl = fileUtil.generateObjectUrl(pic.trim(), Path.REVIEW)
Pair(year, imgUrl)
} ?: emptyList()
}
.groupBy { it.first }

return pictures
return picturesByYear.map { (year, urls) ->
ReviewPictureResponse(year, urls.map { it.second })
}
}
}

0 comments on commit 1193e70

Please sign in to comment.