-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
Walkthroughμ΄ Pull Requestμμλ Changes
Possibly related PRs
Suggested labels
π Recent review detailsConfiguration used: CodeRabbit UI π Files selected for processing (1)
π§ Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
π§Ή Outside diff range and nitpick comments (4)
src/main/kotlin/org/meogo/domain/review/presentation/dto/response/ReviewPictureResponse.kt (1)
4-6
: API λ³κ²½μ¬νμ λν λ¬Έμν μ μμ΄λ¬ν μ£Όμ λ³κ²½μ¬νμ API λ¬Έμμ λͺ νν κΈ°λ‘λμ΄μΌ ν©λλ€.
λ€μκ³Ό κ°μ λ¬Έμνλ₯Ό μ μλ립λλ€:
data class ReviewPictureResponse( + /** 리뷰 μ΄λ―Έμ§μ μ°λ */ val year: Int, + /** ν΄λΉ μ°λμ 리뷰 μ΄λ―Έμ§ URL λͺ©λ‘ */ val image: List<String> )src/main/kotlin/org/meogo/domain/review/service/QueryReviewPictureService.kt (1)
20-28
: μ½λ κ°λ μ± κ°μ μ΄ νμν©λλ€νμ¬ μ½λλ κΈ°λ₯μ μΌλ‘λ μ ννλ, λ€μκ³Ό κ°μ κ°μ μ¬νμ μ μν©λλ€:
- URL μμ± λ‘μ§μ λ³λ ν¨μλ‘ μΆμΆ
- 볡μ‘ν λ³ν λ‘μ§μ λν μ£Όμ μΆκ°
+ private fun generatePictureUrlPairs(review: Review): List<Pair<Int, String>> { + return review.picture?.split(",")?.map { pic -> + val imgUrl = fileUtil.generateObjectUrl(pic.trim(), Path.REVIEW) + Pair(review.date.year, imgUrl) + } ?: emptyList() + } + @Transactional fun queryReviewPicture(schoolId: Int): List<ReviewPictureResponse> { val reviews = reviewRepository.findAllBySchoolId(schoolId)?.sortedByDescending { it.id } ?: return emptyList() - val picturesByYear = reviews - .flatMap { review -> - val year = review.date.year - review.picture?.split(",")?.map { pic -> - val imgUrl = fileUtil.generateObjectUrl(pic.trim(), Path.REVIEW) - Pair(year, imgUrl) - } ?: emptyList() - } - .groupBy { it.first } + // 리뷰 λ°μ΄ν°λ₯Ό μ°λλ³ μ΄λ―Έμ§ URLλ‘ λ³ννκ³ κ·Έλ£Ήν + val picturesByYear = reviews + .flatMap { generatePictureUrlPairs(it) } + .groupBy { it.first }src/main/kotlin/org/meogo/global/s3/FileUtil.kt (2)
75-77
: νμΌ κ²μ¦ λ‘μ§ κ°μ μ΄ νμν©λλ€νμ¬ κ΅¬νμ "webp" νμ₯μλ₯Ό μΆκ°ν κ²μ μ’μ λ³κ²½μ΄μ§λ§, λ€μκ³Ό κ°μ κ°μ μ¬νμ μ μλ립λλ€:
- νμ©λ νμ₯μλ₯Ό μμλ‘ λΆλ¦¬νμ¬ κ΄λ¦¬
- ꡬ체μ μΈ μμΈ ν΄λμ€ μ¬μ©
- νμΌ ν¬κΈ° μ ν μΆκ°
- MIME νμ κ²μ¦ μΆκ°
λ€μκ³Ό κ°μ΄ κ°μ νλ κ²μ μΆμ²λ립λλ€:
+ companion object { + const val EXP_TIME = 1000 * 60 * 60 * 1 + private val ALLOWED_EXTENSIONS = setOf("jpg", "jpeg", "png", "heic", "hwp", "pptx", "webp") + private const val MAX_FILE_SIZE = 10 * 1024 * 1024 // 10MB + } private fun verificationFile(file: MultipartFile): String { if (file.isEmpty || file.originalFilename == null) { - throw NullPointerException() + throw IllegalArgumentException("νμΌμ΄ λΉμ΄μκ±°λ νμΌλͺ μ΄ μμ΅λλ€") + } + + if (file.size > MAX_FILE_SIZE) { + throw IllegalArgumentException("νμΌ ν¬κΈ°λ 10MBλ₯Ό μ΄κ³Όν μ μμ΅λλ€") } 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" || ext == "webp")) { - throw Exception() + if (!ALLOWED_EXTENSIONS.contains(ext)) { + throw IllegalArgumentException("μ§μνμ§ μλ νμΌ νμμ λλ€: $ext") } + // MIME νμ κ²μ¦ + val contentType = file.contentType + if (contentType == null || !contentType.startsWith("image/")) { + throw IllegalArgumentException("μ ν¨νμ§ μμ μ΄λ―Έμ§ νμΌμ λλ€") + } return ext }π§° Tools
πͺ detekt
[warning] 76-76: A call to the default constructor of an exception was detected. Instead one of the constructor overloads should be called. This allows to provide more meaningful exceptions.
(detekt.exceptions.ThrowingExceptionsWithoutMessageOrCause)
Line range hint
29-44
: 보μ κ°μ μ¬ν κ²ν κ° νμν©λλ€νμΌ μ λ‘λ κΈ°λ₯μ λ€μκ³Ό κ°μ 보μ κ°μ μ΄ νμν©λλ€:
- νμΌλͺ κ²μ¦ λ° μ΄κ· μ²λ¦¬
- URL μμ± μμ²μ λν μλ μ ν
λ€μκ³Ό κ°μ 보μ κΈ°λ₯ μΆκ°λ₯Ό κ³ λ €ν΄μ£ΌμΈμ:
- νμΌλͺ κ²μ¦μ μν μ νΈλ¦¬ν° ν¨μ μΆκ°
- Rate Limiter ꡬν (μ: Redis κΈ°λ°)
- μ μ± νμΌ κ²μ¬
νμνμλ€λ©΄ 보μ κ°μ μ μν μμΈ κ΅¬ν μμλ₯Ό μ 곡ν΄λ릴 μ μμ΅λλ€.
π§° Tools
πͺ detekt
[warning] 76-76: A call to the default constructor of an exception was detected. Instead one of the constructor overloads should be called. This allows to provide more meaningful exceptions.
(detekt.exceptions.ThrowingExceptionsWithoutMessageOrCause)
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
π Files selected for processing (3)
src/main/kotlin/org/meogo/domain/review/presentation/dto/response/ReviewPictureResponse.kt
(1 hunks)src/main/kotlin/org/meogo/domain/review/service/QueryReviewPictureService.kt
(1 hunks)src/main/kotlin/org/meogo/global/s3/FileUtil.kt
(1 hunks)
π Additional comments (3)
src/main/kotlin/org/meogo/domain/review/presentation/dto/response/ReviewPictureResponse.kt (1)
4-6
:
λ³κ²½λ μλ΅ κ΅¬μ‘°μ μν₯ νμΈ νμ
image
νλκ° λ¨μΌ λ¬Έμμ΄μμ λ¬Έμμ΄ λ¦¬μ€νΈλ‘ λ³κ²½λμ΄ API μλ΅ κ΅¬μ‘°κ° λ³κ²½λμμ΅λλ€. μ΄λ APIλ₯Ό μ¬μ©νλ ν΄λΌμ΄μΈνΈ μΈ‘μ μν₯μ λ―ΈμΉ μ μλ μ£Όμ λ³κ²½μ¬νμ
λλ€.
λ€μ μ€ν¬λ¦½νΈλ₯Ό μ€ννμ¬ κ΄λ ¨ μλΉμ€λ€μ΄ μ΄ λ³κ²½μ¬νμ μ¬λ°λ₯΄κ² μ²λ¦¬νλμ§ νμΈνκ² μ΅λλ€:
β Verification successful
Let me check the implementation of QueryReviewPictureService to verify how it handles the change:
API μλ΅ κ΅¬μ‘° λ³κ²½μ΄ μμ νκ² μ²λ¦¬λμμμ νμΈνμ΅λλ€
QueryReviewPictureServiceμ ꡬνμ κ²ν ν κ²°κ³Ό, λ€μκ³Ό κ°μ΄ λ³κ²½μ¬νμ΄ μ¬λ°λ₯΄κ² μ²λ¦¬λκ³ μμ΅λλ€:
- μλΉμ€ κ³μΈ΅μμ
urls.map { it.second }
λ₯Ό ν΅ν΄ List ννλ‘ μ μ ν λ³ννμ¬ μλ΅ - λ°μ΄ν° λ³ν λ‘μ§μ΄ μΌκ΄λκ² μ μ©λ¨
π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: ReviewPictureResponse μ¬μ© νν© νμΈ
# ReviewPictureResponseλ₯Ό μ¬μ©νλ μλΉμ€ λ° μ»¨νΈλ‘€λ¬ κ²μ
echo "=== ReviewPictureResponse μ¬μ© νν© ==="
rg -l "ReviewPictureResponse" src/main/kotlin/org/meogo/domain/review/
# μ΄λ―Έμ§ μ²λ¦¬ κ΄λ ¨ λ‘μ§ κ²μ
echo -e "\n=== μ΄λ―Έμ§ μ²λ¦¬ λ‘μ§ κ²μ ==="
ast-grep --pattern 'fun $_ ($$$) {
$$$
ReviewPictureResponse($$$)
$$$
}'
Length of output: 457
Script:
#!/bin/bash
# QueryReviewPictureService ꡬν νμΈ
echo "=== QueryReviewPictureService ꡬν ==="
rg -A 10 "class QueryReviewPictureService" src/main/kotlin/org/meogo/domain/review/service/QueryReviewPictureService.kt
# ReviewPictureResponse μμ± λ‘μ§ νμΈ
echo -e "\n=== ReviewPictureResponse μμ± λ‘μ§ ==="
rg -B 2 -A 5 "ReviewPictureResponse" src/main/kotlin/org/meogo/domain/review/service/QueryReviewPictureService.kt
Length of output: 1642
src/main/kotlin/org/meogo/domain/review/service/QueryReviewPictureService.kt (2)
30-32
: μλ΅ λ³ν λ‘μ§μ΄ μ μ ν©λλ€
μ°λλ³λ‘ κ·Έλ£Ήνλ λ°μ΄ν°λ₯Ό ReviewPictureResponseλ‘ λ³ννλ λ‘μ§μ΄ κΉλνκ³ λͺ νν©λλ€.
20-32
: μλ΅ κ΅¬μ‘° λ³κ²½μ λ°λ₯Έ μν₯λ νμΈμ΄ νμν©λλ€
λ¨μΌ μ΄λ―Έμ§μμ λ€μ€ μ΄λ―Έμ§ μλ΅μΌλ‘μ λ³κ²½μ API μλΉμμκ² μν₯μ μ€ μ μμ΅λλ€.
β Verification successful
Let me gather more information about the response type and its usage.
Let me try one more search to find any API endpoints and tests.
Let me try one final search focusing on the controller and API endpoints.
Let me check the ReviewController content to see how the endpoint is exposed.
API μλ΅ κ΅¬μ‘° λ³κ²½μ μμ ν©λλ€
리뷰 μ¬μ§ μ‘°ν API(GET /review/pic
)λ μλ‘ μΆκ°λ μλν¬μΈνΈμ΄λ©°, κΈ°μ‘΄ APIλ₯Ό μμ ν κ²μ΄ μλλλ€. μλ΅ νμ
μΈ ReviewPictureResponse
λ μλ‘ μ μλ DTOμ
λλ€. λ°λΌμ κΈ°μ‘΄ μ½λμ μν₯μ μ£Όμ§ μμΌλ©° νμ νΈνμ± λ¬Έμ κ° λ°μνμ§ μμ΅λλ€.
π Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# API μλ΅ κ΅¬μ‘°λ₯Ό μ¬μ©νλ νλ‘ νΈμλ μ½λ κ²μ
rg -t typescript -t javascript "ReviewPictureResponse"
# μλ΅ νμ
μ μ°Έμ‘°νλ λ€λ₯Έ λ°±μλ μ½λ κ²μ
rg "ReviewPictureResponse"
Length of output: 688
Script:
#!/bin/bash
# Check the response type definition
cat src/main/kotlin/org/meogo/domain/review/presentation/dto/response/ReviewPictureResponse.kt
# Look for API endpoints using this response
ast-grep --pattern 'fun $FUNC($$$): $RET<$$$ReviewPictureResponse$$$>'
# Search for any tests using this response type
rg -g "**/*Test*" "ReviewPictureResponse"
Length of output: 502
Script:
#!/bin/bash
# Look for controller endpoints
rg -A 5 "@.*Mapping.*ReviewPicture"
# Search for tests with correct glob pattern
rg --glob "*Test*.kt" "ReviewPictureResponse"
# Find any references to review pictures in frontend code
rg -g "*.{js,jsx,ts,tsx}" "review.*picture"
Length of output: 427
Script:
#!/bin/bash
# Find the controller class that uses this service
rg -l "class.*Review.*Controller"
# Look for any REST controller annotations
rg "@RestController" -A 3 -g "*.kt"
# Find the endpoint that returns ReviewPictureResponse
ast-grep --pattern 'class $CLASS {
$$$
fun $FUNC($$$): List<ReviewPictureResponse> {
$$$
}
$$$
}'
Length of output: 3941
Script:
#!/bin/bash
# Check the ReviewController implementation
cat src/main/kotlin/org/meogo/domain/review/presentation/ReviewController.kt
# Look for any client-side code in common web directories
fd -g "*.{js,jsx,ts,tsx}" -d 3 src/main/resources/static
fd -g "*.{js,jsx,ts,tsx}" -d 3 frontend
Length of output: 4288
@@ -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) |
There was a problem hiding this comment.
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.
close #55
Summary by CodeRabbit
μλ‘μ΄ κΈ°λ₯
λ²κ·Έ μμ
λ¬Έμν
리ν©ν°λ§
μ€νμΌ
ν μ€νΈ
μ‘μΌ
λλ리기