Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ„ :: (Meogo-55) modify review picture response #56

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿ› ๏ธ Refactor suggestion

println ๋Œ€์‹  ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”

๋””๋ฒ„๊น…์„ ์œ„ํ•œ println ๋ฌธ์€ ํ”„๋กœ๋•์…˜ ์ฝ”๋“œ์— ์ ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. SLF4J๋‚˜ Log4j์™€ ๊ฐ™์€ ์ ์ ˆํ•œ ๋กœ๊น… ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.

-println(reviews)
+log.debug("Retrieved reviews: {}", reviews)

Committable suggestion skipped: line range outside the PR's diff.

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
Loading