Skip to content

Commit

Permalink
Merge pull request #56 from MEOGO-DSM/55-modify-review-picture-response
Browse files Browse the repository at this point in the history
🏄 :: (Meogo-55) modify review picture response
  • Loading branch information
meltapplee authored Nov 21, 2024
2 parents f114e8a + 6bfc5fa commit 55d37c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 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,18 @@ class QueryReviewPictureService(
@Transactional
fun queryReviewPicture(schoolId: Int): List<ReviewPictureResponse> {
val reviews = reviewRepository.findAllBySchoolId(schoolId)?.sortedByDescending { it.id } ?: return emptyList()

val pictures = 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 })
}
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/org/meogo/global/s3/FileUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class FileUtil(
val originalFilename = file.originalFilename!!
val ext = originalFilename.substring(originalFilename.lastIndexOf(".") + 1).lowercase(Locale.getDefault())

if (!(ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "heic" || ext == "hwp" || ext == "pptx")) {
if (!(ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "heic" || ext == "hwp" || ext == "pptx" || ext == "webp")) {
throw Exception()
}

Expand Down

0 comments on commit 55d37c8

Please sign in to comment.