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-48) modify my page #49

Merged
merged 5 commits into from
Oct 8, 2024
Merged

Conversation

meltapplee
Copy link
Member

@meltapplee meltapplee commented Oct 8, 2024

close #48
แ„†แ…กแ„‹แ…ตแ„‘แ…ฆแ„‹แ…ตแ„Œแ…ต แ„‰แ…ฎแ„Œแ…ฅแ†ผ

Summary by CodeRabbit

  • ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ

    • ์‚ฌ์šฉ์ž ํ”„๋กœํ•„ ์—…๋ฐ์ดํŠธ ๊ธฐ๋Šฅ ๊ฐœ์„ : ์ด๋ฆ„๊ณผ ๋“ฑ๋ก ํ•™๊ต๋ฅผ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ ์ถ”๊ฐ€.
    • ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ์ˆ˜์ •ํ•˜๊ธฐ ์œ„ํ•œ ์ƒˆ๋กœ์šด ์š”์ฒญ DTO์ธ UserModifyRequest ์ถ”๊ฐ€.
    • ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ์กฐํšŒํ•˜๊ธฐ ์œ„ํ•œ ์ƒˆ๋กœ์šด ์„œ๋น„์Šค QueryMyPageService ์ถ”๊ฐ€.
    • ์‚ฌ์šฉ์ž ID๋กœ ์กฐํšŒ ์‹œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ๊ฐœ์„ ์œผ๋กœ ์‚ฌ์šฉ์ž ์กฐํšŒ ์‹œ ๋” ์•ˆ์ „ํ•œ ํ๋ฆ„ ์ œ๊ณต.
    • ์‚ฌ์šฉ์ž ์กฐํšŒ ๋ฉ”์„œ๋“œ์—์„œ null ์ฒดํฌ ์ถ”๊ฐ€๋กœ ์•ˆ์ „์„ฑ ํ–ฅ์ƒ.
  • ๋ฒ„๊ทธ ์ˆ˜์ •

    • ์‚ฌ์šฉ์ž ์กฐํšŒ ์‹œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ์ œ๊ฑฐ๋กœ ์ธํ•ด ๋” ๊ฐ„๋‹จํ•œ ํ๋ฆ„์œผ๋กœ ๋ณ€๊ฒฝ.
  • ๋ฆฌํŒฉํ† ๋ง

    • UploadProfileService๊ฐ€ ModifyUserInfoService๋กœ ์ด๋ฆ„ ๋ณ€๊ฒฝ ๋ฐ ๊ธฐ๋Šฅ ๊ฐœ์„ .
    • MyPageService๊ฐ€ QueryMyPageService๋กœ ์ด๋ฆ„ ๋ณ€๊ฒฝ.

@meltapplee meltapplee self-assigned this Oct 8, 2024
Copy link

coderabbitai bot commented Oct 8, 2024

Walkthrough

์ด ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ User ํด๋ž˜์Šค, UserRepository ์ธํ„ฐํŽ˜์ด์Šค, UserFacade ํด๋ž˜์Šค, UserController ํด๋ž˜์Šค ๋ฐ ๊ด€๋ จ ์„œ๋น„์Šค ํด๋ž˜์Šค์— ๋Œ€ํ•œ ์—ฌ๋Ÿฌ ์ˆ˜์ • ์‚ฌํ•ญ์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค. ์ฃผ์š” ๋ณ€๊ฒฝ ์‚ฌํ•ญ์œผ๋กœ๋Š” User ํด๋ž˜์Šค์˜ ์†์„ฑ ๊ฐ€์‹œ์„ฑ์„ ์ˆ˜์ •ํ•˜๊ณ , updateProfile ๋ฉ”์„œ๋“œ์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ํ™•์žฅํ•˜๋ฉฐ, UserRepository ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ JPA์—์„œ ์ผ๋ฐ˜ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์‚ฌ์šฉ์ž ๊ฒ€์ƒ‰ ๋ฉ”์„œ๋“œ์—์„œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ , ์ƒˆ๋กœ์šด DTO ๋ฐ ์„œ๋น„์Šค ํด๋ž˜์Šค๊ฐ€ ๋„์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Changes

ํŒŒ์ผ ๊ฒฝ๋กœ ๋ณ€๊ฒฝ ์š”์•ฝ
src/main/kotlin/org/meogo/domain/user/domain/User.kt name ๋ฐ enrolledSchool ์†์„ฑ์„ var๋กœ ๋ณ€๊ฒฝํ•˜๊ณ , updateProfile ๋ฉ”์„œ๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ์„ธ ๊ฐœ์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ฐ›๋„๋ก ๋ณ€๊ฒฝ.
src/main/kotlin/org/meogo/domain/user/domain/UserRepository.kt JpaRepository์—์„œ Repository๋กœ ๋ณ€๊ฒฝํ•˜๊ณ , findById ๋ฉ”์„œ๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉฐ, findByAccountId ๋ฉ”์„œ๋“œ๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ๋ฐ˜ํ™˜ ํƒ€์ž…์„ ๋ณ€๊ฒฝ.
src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt getUserByAccountId ๋ฐ getUserById ๋ฉ”์„œ๋“œ์—์„œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ , ๋ฐ˜ํ™˜ ํƒ€์ž…์„ nullable๋กœ ๋ณ€๊ฒฝ.
src/main/kotlin/org/meogo/domain/user/presentation/UserController.kt ๋‘ ๊ฐœ์˜ ์ƒˆ๋กœ์šด DTO๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , myPage ๋ฉ”์„œ๋“œ๋ฅผ ์ˆ˜์ •ํ•˜๋ฉฐ, updateProfile ๋ฉ”์„œ๋“œ์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ๋ณ€๊ฒฝ.
src/main/kotlin/org/meogo/domain/user/presentation/dto/request/UserModifyRequest.kt UserModifyRequest๋ผ๋Š” ์ƒˆ๋กœ์šด ๋ฐ์ดํ„ฐ ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€.
src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt UploadProfileService๋ฅผ ModifyUserInfoService๋กœ ์ด๋ฆ„ ๋ณ€๊ฒฝํ•˜๊ณ , ๋ฉ”์„œ๋“œ ๋ฐ ์ƒ์„ฑ์ž ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ˆ˜์ •.
src/main/kotlin/org/meogo/domain/user/service/QueryMyPageService.kt MyPageService๋ฅผ QueryMyPageService๋กœ ์ด๋ฆ„ ๋ณ€๊ฒฝ.
src/main/kotlin/org/meogo/domain/user/service/UserSignInService.kt UserNotFoundException ์ž„ํฌํŠธ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ , ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ˆ˜์ •.
src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt loadUserByUsername ๋ฉ”์„œ๋“œ์—์„œ ์‚ฌ์šฉ์ž ๊ฒ€์ƒ‰ ์‹œ null ์ฒดํฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , ์‚ฌ์šฉ์ž ๋ฏธ๋ฐœ๊ฒฌ ์‹œ UserNotFoundException์„ ๋ฐœ์ƒ์‹œํ‚ค๋„๋ก ๋ณ€๊ฒฝ.
src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt ์‚ฌ์šฉ์ž ๊ฒ€์ƒ‰ ์‹œ null ์ฒดํฌ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ , ์‚ฌ์šฉ์ž ๋ฏธ๋ฐœ๊ฒฌ ์‹œ UserNotFoundException์„ ๋ฐœ์ƒ์‹œํ‚ค๋„๋ก ๋ณ€๊ฒฝ.

Possibly related PRs

  • ๐Ÿ„ :: (Meogo-3) userย #4: User ํด๋ž˜์Šค์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ PR #4์˜ User ํด๋ž˜์Šค ์ˆ˜์ •๊ณผ ๊ด€๋ จ์ด ์žˆ์œผ๋ฉฐ, ์‚ฌ์šฉ์ž ์ •๋ณด ๊ด€๋ฆฌ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•œ ๋ณ€๊ฒฝ์„ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.
  • ๐Ÿ„ :: (Meogo-5) signup signin checkย #6: PR #6์˜ UserController ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ ์‚ฌ์šฉ์ž ๊ด€๋ฆฌ ๊ธฐ๋Šฅ ์—…๋ฐ์ดํŠธ์™€ ๊ด€๋ จ์ด ์žˆ์œผ๋ฉฐ, User ํด๋ž˜์Šค ๋ฐ ํ•ด๋‹น ๋ฉ”์„œ๋“œ์™€ ์ง์ ‘ ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค.
  • ๐Ÿ„ :: (Meogo-20) user my pageย #21: PR #21์˜ MyPageService ๋ฐ MyPageResponse ์—…๋ฐ์ดํŠธ๋Š” ์‚ฌ์šฉ์ž ์ •๋ณด ๊ฒ€์ƒ‰ ๋ฐ ํ‘œํ˜„๊ณผ ๊ด€๋ จ์ด ์žˆ์œผ๋ฉฐ, User ํด๋ž˜์Šค์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ๊ณผ ์—ฐ๊ด€๋ฉ๋‹ˆ๋‹ค.
  • ๐Ÿ„ :: (Meogo-36) detault imageย #37: ํ”„๋กœํ•„ ์ฒ˜๋ฆฌ์™€ ๊ด€๋ จ๋œ User ํด๋ž˜์Šค์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์€ ์‚ฌ์šฉ์ž ํ”„๋กœํ•„ ๊ด€๋ฆฌ์™€ ์ƒํ˜ธ ์ž‘์šฉํ•  ์ˆ˜ ์žˆ๋Š” PR #37์˜ ์ˆ˜์ • ์‚ฌํ•ญ๊ณผ ๊ด€๋ จ์ด ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๐Ÿ„ :: (Meogo-40) question tag detailย #41: User ํด๋ž˜์Šค์˜ ์ˆ˜์ • ์‚ฌํ•ญ์€ ์‚ฌ์šฉ์ž ์ƒํ˜ธ ์ž‘์šฉ๊ณผ ๊ด€๋ จ๋œ ๊ธฐ๋Šฅ ํ–ฅ์ƒ์„ ๋ชฉํ‘œ๋กœ ํ•˜๋Š” PR #41๊ณผ๋„ ๊ด€๋ จ์ด ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ‡ ๋ณ€ํ™”์˜ ๋ฐ”๋žŒ์ด ๋ถˆ์–ด์™€
์‚ฌ์šฉ์ž ์ •๋ณด๊ฐ€ ์ƒˆ๋กœ์›Œ์ ธ์š”.
ํ”„๋กœํ•„ ์—…๋ฐ์ดํŠธ, ๋” ๊ฐ„ํŽธํ•˜๊ฒŒ,
๋ชจ๋‘์˜ ์ด์•ผ๊ธฐ๊ฐ€ ๋‹ด๊ธธ ๊ฑฐ์˜ˆ์š”!
ํ•จ๊ป˜ ๋›ฐ์–ด๋†€๋ฉฐ, ๋” ๋‚˜์€ ์„ธ์ƒ์œผ๋กœ,
์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๊ฟˆ์„ ์ด๋ค„๊ฐ€์š”! ๐ŸŒŸ


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?

โค๏ธ Share
๐Ÿชง Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

๐Ÿงน Outside diff range and nitpick comments (3)
src/main/kotlin/org/meogo/domain/user/service/QueryMyPageService.kt (1)

10-10: ํด๋ž˜์Šค ์ด๋ฆ„ ๋ณ€๊ฒฝ์ด ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค.

ํด๋ž˜์Šค ์ด๋ฆ„์„ MyPageService์—์„œ QueryMyPageService๋กœ ๋ณ€๊ฒฝํ•œ ๊ฒƒ์€ CQRS ํŒจํ„ด์˜ Query ๋ถ€๋ถ„๊ณผ ์ผ์น˜ํ•˜์—ฌ ์ข‹์€ ๋ณ€๊ฒฝ์ž…๋‹ˆ๋‹ค. ์ด๋Š” ์„œ๋น„์Šค์˜ ๋ชฉ์ ์„ ๋” ๋ช…ํ™•ํžˆ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.

ํ•˜๋‚˜์˜ ์ž‘์€ ๊ฐœ์„  ์‚ฌํ•ญ์„ ์ œ์•ˆ๋“œ๋ฆฝ๋‹ˆ๋‹ค:

execute() ๋ฉ”์„œ๋“œ์—์„œ userFacade.currentUser()์˜ ๊ฒฐ๊ณผ๋ฅผ ์ฒ˜๋ฆฌํ•  ๋•Œ, ์—˜๋น„์Šค ์—ฐ์‚ฐ์ž(?:) ๋Œ€์‹  requireNotNull()์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋” ๋ช…์‹œ์ ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ฝ”๋“œ์˜ ์˜๋„๊ฐ€ ๋” ๋ช…ํ™•ํ•ด์ง‘๋‹ˆ๋‹ค.

fun execute(): MyPageResponse {
    val user = requireNotNull(userFacade.currentUser()) { "User not found" }
    
    return MyPageResponse(
        user.name,
        user.accountId,
        user.enrolledSchool,
        user.profile
    )
}

์ด ๋ณ€๊ฒฝ์€ ์„ ํƒ์‚ฌํ•ญ์ด๋ฉฐ, ํ˜„์žฌ ๊ตฌํ˜„๋„ ์ถฉ๋ถ„ํžˆ ๋ช…ํ™•ํ•˜๊ณ  ํšจ๊ณผ์ ์ž…๋‹ˆ๋‹ค.

src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt (1)

currentUser ๋ฉ”์„œ๋“œ ์‚ฌ์šฉ ์‹œ ์•ˆ์ „ํ•œ null ์ฒ˜๋ฆฌ ํ•„์š”

currentUser ๋ฉ”์„œ๋“œ๊ฐ€ nullable ํƒ€์ž…์„ ๋ฐ˜ํ™˜ํ•˜๋ฏ€๋กœ, ์ผ๋ถ€ ์„œ๋น„์Šค ํด๋ž˜์Šค์—์„œ !! ์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ•์ œ๋กœ ์–ธ๋ž˜ํ•‘ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” NullPointerException์„ ์œ ๋ฐœํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, ๋‹ค์Œ ํŒŒ์ผ๋“ค์—์„œ null ์ฒ˜๋ฆฌ๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ๊ตฌํ˜„ํ•˜๋„๋ก ์ˆ˜์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค:

  • src/main/kotlin/org/meogo/domain/comment/service/DeleteCommentService.kt
  • src/main/kotlin/org/meogo/domain/post/service/DeletePostService.kt
๐Ÿ”— Analysis chain

Line range hint 15-18: currentUser ๋ฉ”์„œ๋“œ ๊ฒ€ํ†  ํ•„์š”

getUserByAccountId ๋ฉ”์„œ๋“œ๊ฐ€ ์ด์ œ nullable ํƒ€์ž…์„ ๋ฐ˜ํ™˜ํ•˜๋ฏ€๋กœ, currentUser ๋ฉ”์„œ๋“œ์˜ ๊ตฌํ˜„์„ ๊ฒ€ํ† ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  1. currentUser ๋ฉ”์„œ๋“œ๋Š” ์—ฌ์ „ํžˆ User?๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์žˆ์–ด ํƒ€์ž… ์ธก๋ฉด์—์„œ๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
  2. ํ•˜์ง€๋งŒ getUserByAccountId์˜ ๋ณ€๊ฒฝ์œผ๋กœ ์ธํ•ด currentUser ๋ฉ”์„œ๋“œ์˜ ๋™์ž‘์ด ์˜๋„ํ•œ ๋Œ€๋กœ์ธ์ง€ ํ™•์ธ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
  3. null ์ฒ˜๋ฆฌ ๋กœ์ง์ด ์ ์ ˆํ•œ์ง€ ๊ฒ€ํ† ํ•˜๊ณ , ํ•„์š”ํ•˜๋‹ค๋ฉด ์ถ”๊ฐ€์ ์ธ null ์ฒดํฌ๋ฅผ ๊ณ ๋ คํ•ด๋ณด์„ธ์š”.

currentUser ๋ฉ”์„œ๋“œ์˜ ํ˜ธ์ถœ ์ง€์ ๋“ค์„ ํ™•์ธํ•˜์—ฌ null ์ฒ˜๋ฆฌ๊ฐ€ ์ ์ ˆํžˆ ์ด๋ฃจ์–ด์ง€๊ณ  ์žˆ๋Š”์ง€ ๊ฒ€์ฆํ•ด ๋ณด์„ธ์š”. ๋‹ค์Œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜์—ฌ currentUser์˜ ์‚ฌ์šฉ ํŒจํ„ด์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

๐Ÿ Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of currentUser() method
rg --type kotlin "\.currentUser\(\)" -A 5

Length of output: 14407

src/main/kotlin/org/meogo/domain/user/presentation/UserController.kt (1)

32-33: ์˜์กด์„ฑ ์ฃผ์ž…์ด ์ ์ ˆํžˆ ์—…๋ฐ์ดํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ƒˆ๋กœ์šด ์„œ๋น„์Šค ํด๋ž˜์Šค๋“ค์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ฃผ์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์ปจํŠธ๋กค๋Ÿฌ ๋ฉ”์„œ๋“œ์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ๊ณผ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€๋…์„ฑ ํ–ฅ์ƒ์„ ์œ„ํ•ด ์˜์กด์„ฑ ์ฃผ์ž… ์ˆœ์„œ๋ฅผ ์•ŒํŒŒ๋ฒณ ์ˆœ์œผ๋กœ ์ •๋ ฌํ•˜๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ•ด ๋ณด์„ธ์š”. ์˜ˆ๋ฅผ ๋“ค์–ด:

class UserController(
    private val checkAccountIdService: CheckAccountIdService,
    private val modifyUserInfoService: ModifyUserInfoService,
    private val queryMyPageService: QueryMyPageService,
    private val userSignInService: UserSignInService,
    private val userSignUpService: UserSignUpService
) {
    // ...
}
๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

๐Ÿ“ฅ Commits

Files that changed from the base of the PR and between e8146f0 and 04ad08f.

๐Ÿ“’ Files selected for processing (8)
  • src/main/kotlin/org/meogo/domain/user/domain/User.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/user/domain/UserRepository.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/user/presentation/UserController.kt (3 hunks)
  • src/main/kotlin/org/meogo/domain/user/presentation/dto/request/UserModifyRequest.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt (2 hunks)
  • src/main/kotlin/org/meogo/domain/user/service/QueryMyPageService.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/user/service/UserSignInService.kt (0 hunks)
๐Ÿ’ค Files with no reviewable changes (1)
  • src/main/kotlin/org/meogo/domain/user/service/UserSignInService.kt
๐Ÿงฐ Additional context used
๐Ÿ”‡ Additional comments (7)
src/main/kotlin/org/meogo/domain/user/presentation/dto/request/UserModifyRequest.kt (1)

1-6: ์ „๋ฐ˜์ ์ธ ๊ตฌ์กฐ์™€ ๋ช…๋ช…์ด ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค.

๋ฐ์ดํ„ฐ ํด๋ž˜์Šค์˜ ์‚ฌ์šฉ๊ณผ ์†์„ฑ ์ด๋ฆ„์ด ๋ช…ํ™•ํ•˜๊ณ  ์ดํ•ดํ•˜๊ธฐ ์‰ฝ์Šต๋‹ˆ๋‹ค. DTO๋กœ์„œ์˜ ์—ญํ• ์„ ์ž˜ ์ˆ˜ํ–‰ํ•  ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.

src/main/kotlin/org/meogo/domain/user/domain/User.kt (2)

15-15: name ์†์„ฑ์˜ ๊ฐ€๋ณ€์„ฑ ๋ณ€๊ฒฝ์— ๋Œ€ํ•œ ๊ณ ๋ ค ํ•„์š”

name ์†์„ฑ์„ val์—์„œ var๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ๊ฐ์ฒด์˜ ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•ด์ง‘๋‹ˆ๋‹ค. ์ด๋Š” ์˜๋„๋œ ๋ณ€๊ฒฝ์ด์ง€๋งŒ, ๋‹ค์Œ ์‚ฌํ•ญ์„ ๊ณ ๋ คํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

  1. ์Šค๋ ˆ๋“œ ์•ˆ์ „์„ฑ: ์—ฌ๋Ÿฌ ์Šค๋ ˆ๋“œ์—์„œ ๋™์‹œ์— ์ด ์†์„ฑ์— ์ ‘๊ทผํ•  ๊ฒฝ์šฐ ๋™๊ธฐํ™” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  2. ๋ถˆ๋ณ€์„ฑ ์†์‹ค: ๊ฐ์ฒด์˜ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•˜๊ธฐ ์–ด๋ ค์›Œ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ์˜ˆ์ธก ๊ฐ€๋Šฅ์„ฑ ๊ฐ์†Œ: ๊ฐ์ฒด์˜ ์ƒํƒœ๊ฐ€ ์–ธ์ œ๋“  ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์–ด ์ฝ”๋“œ์˜ ์˜ˆ์ธก ๊ฐ€๋Šฅ์„ฑ์ด ๋‚ฎ์•„์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ ๋ณ€๊ฒฝ์ด ํ•„์š”ํ•œ ์ด์œ ์™€ ์ž ์žฌ์ ์ธ ์˜ํ–ฅ์„ ํŒ€๊ณผ ๋…ผ์˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

#!/bin/bash
# ๋‹ค๋ฅธ ํŒŒ์ผ์—์„œ User ๊ฐ์ฒด์˜ name ์†์„ฑ์„ ์ง์ ‘ ๋ณ€๊ฒฝํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ
rg --type kotlin 'user\.name\s*=' -g '!**/User.kt'

23-23: enrolledSchool ์†์„ฑ์˜ ๊ฐ€๋ณ€์„ฑ ๋ณ€๊ฒฝ์— ๋Œ€ํ•œ ๊ฒ€ํ†  ํ•„์š”

enrolledSchool ์†์„ฑ์„ val์—์„œ var๋กœ ๋ณ€๊ฒฝํ•œ ๊ฒƒ์€ name ์†์„ฑ๊ณผ ์œ ์‚ฌํ•œ ์˜ํ–ฅ์„ ๋ฏธ์นฉ๋‹ˆ๋‹ค:

  1. ์Šค๋ ˆ๋“œ ์•ˆ์ „์„ฑ: ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ํ™˜๊ฒฝ์—์„œ ๋™๊ธฐํ™” ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  2. ๋ถˆ๋ณ€์„ฑ ์†์‹ค: ๊ฐ์ฒด์˜ ์ผ๊ด€์„ฑ ์œ ์ง€๊ฐ€ ๋” ์–ด๋ ค์›Œ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ์˜ˆ์ธก ๊ฐ€๋Šฅ์„ฑ ๊ฐ์†Œ: ๊ฐ์ฒด์˜ ์ƒํƒœ ๋ณ€๊ฒฝ์ด ๋” ์ž์œ ๋กœ์›Œ์ ธ ์ฝ”๋“œ์˜ ์˜ˆ์ธก์ด ์–ด๋ ค์›Œ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋˜ํ•œ, enrolledSchool์ด Int? ํƒ€์ž…์ด๋ฉฐ ๊ธฐ๋ณธ๊ฐ’์ด 0์ธ ๊ฒƒ์— ๋Œ€ํ•ด ๊ณ ๋ คํ•ด ๋ณด์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. 0์ด ์œ ํšจํ•œ ๊ฐ’์ธ์ง€, ์•„๋‹ˆ๋ฉด null์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋” ์ ์ ˆํ•œ์ง€ ๊ฒ€ํ† ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

์ด ๋ณ€๊ฒฝ์˜ ํ•„์š”์„ฑ๊ณผ ์ž ์žฌ์  ์˜ํ–ฅ์— ๋Œ€ํ•ด ํŒ€ ๋‚ด์—์„œ ๋…ผ์˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

โœ… Verification successful

enrolledSchool ์†์„ฑ ๋ณ€๊ฒฝ ๊ฒ€์ฆ ์™„๋ฃŒ

๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ํ™•์ธํ•œ ๊ฒฐ๊ณผ, ๋‹ค๋ฅธ ํŒŒ์ผ์—์„œ enrolledSchool ์†์„ฑ์„ ์ง์ ‘ ๋ณ€๊ฒฝํ•˜๋Š” ์ฝ”๋“œ๋Š” ๋ฐœ๊ฒฌ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ, enrolledSchool์„ var๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐ ๋”ฐ๋ฅธ ์™ธ๋ถ€ ์˜ํ–ฅ์€ ์—†์Œ์„ ํ™•์ธํ–ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# ๋‹ค๋ฅธ ํŒŒ์ผ์—์„œ User ๊ฐ์ฒด์˜ enrolledSchool ์†์„ฑ์„ ์ง์ ‘ ๋ณ€๊ฒฝํ•˜๋Š” ์ฝ”๋“œ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ
rg --type kotlin 'user\.enrolledSchool\s*=' -g '!**/User.kt'

Length of output: 518

src/main/kotlin/org/meogo/domain/user/presentation/UserController.kt (3)

4-4: ์ƒˆ๋กœ์šด import ๋ฌธ์ด ์ ์ ˆํžˆ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ƒˆ๋กœ์šด DTO์™€ ์„œ๋น„์Šค ํด๋ž˜์Šค์— ๋Œ€ํ•œ import ๋ฌธ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ถ”๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์ปจํŠธ๋กค๋Ÿฌ ํด๋ž˜์Šค์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ๊ณผ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.

Also applies to: 9-10


53-53: myPage ๋ฉ”์„œ๋“œ๊ฐ€ ์ ์ ˆํžˆ ์—…๋ฐ์ดํŠธ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

myPage ๋ฉ”์„œ๋“œ๊ฐ€ ์ƒˆ๋กœ์šด queryMyPageService๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ˆ˜์ •๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋ฉ”์„œ๋“œ ์‹œ๊ทธ๋‹ˆ์ฒ˜์™€ ๋ฐ˜ํ™˜ ํƒ€์ž…์ด ์œ ์ง€๋˜์–ด API ๊ณ„์•ฝ์„ ์ž˜ ์ง€ํ‚ค๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.


55-61: updateProfile ๋ฉ”์„œ๋“œ๊ฐ€ ์ ์ ˆํžˆ ๊ฐœ์„ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋ฉ”์„œ๋“œ ์ด๋ฆ„ ๋ณ€๊ฒฝ, ์ƒˆ๋กœ์šด ๋งค๊ฐœ๋ณ€์ˆ˜ ์ถ”๊ฐ€, ๊ทธ๋ฆฌ๊ณ  ์„œ๋น„์Šค ๋กœ์ง ๋ณ€๊ฒฝ์ด ์ž˜ ์ด๋ฃจ์–ด์กŒ์Šต๋‹ˆ๋‹ค. ์ด ๋ณ€๊ฒฝ์œผ๋กœ ์‚ฌ์šฉ์ž ์ •๋ณด ์ˆ˜์ •๊ณผ ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ๋ฅผ ํ•จ๊ป˜ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ ์‚ฌํ•ญ๋“ค์„ ํ™•์ธํ•ด ์ฃผ์„ธ์š”:

  1. modifyUserInfoService.execute() ๋ฉ”์„œ๋“œ๊ฐ€ file ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ null์ผ ๋•Œ ์ ์ ˆํžˆ ์ฒ˜๋ฆฌํ•˜๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.
  2. ํด๋ผ์ด์–ธํŠธ ์ธก์—์„œ ์ด API ๋ณ€๊ฒฝ์— ๋Œ€์‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋ฌธ์„œํ™”๊ฐ€ ์—…๋ฐ์ดํŠธ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜์„ธ์š”.

์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ์‹์„ ๊ณ ๋ คํ•ด ๋ณด์„ธ์š”:

@PatchMapping("/modify")
fun updateProfile(
    @RequestPart(name = "image", required = false) file: MultipartFile?,
    @Valid @RequestPart(name = "request") request: UserModifyRequest
) = modifyUserInfoService.execute(request, file)

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด request์— ๋Œ€ํ•œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ๊ฐ€ ์ž๋™์œผ๋กœ ์ˆ˜ํ–‰๋˜๋ฉฐ, file์ด ์„ ํƒ์ ์ž„์„ ๋ช…์‹œ์ ์œผ๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt (1)

31-31: ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ URL์ด null์ธ ๊ฒฝ์šฐ ์ฒ˜๋ฆฌ ํ™•์ธ ํ•„์š”

ํŒŒ์ผ์ด ์ œ๊ณต๋˜์ง€ ์•Š์„ ๊ฒฝ์šฐ url์ด null์ด ๋ฉ๋‹ˆ๋‹ค. updateProfile ๋ฉ”์„œ๋“œ๊ฐ€ url์ด null์ธ ๊ฒฝ์šฐ๋ฅผ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ฒ˜๋ฆฌํ•˜๋Š”์ง€ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์‹คํ–‰ํ•˜์—ฌ updateProfile ๋ฉ”์„œ๋“œ๊ฐ€ url์ด null์ธ ๊ฒฝ์šฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

โœ… Verification successful

ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ URL์ด null์ธ ๊ฒฝ์šฐ ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๋ฉ๋‹ˆ๋‹ค.

๐Ÿ Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: updateProfile ๋ฉ”์„œ๋“œ๊ฐ€ url์ด null์ธ ๊ฒฝ์šฐ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

# updateProfile ๋ฉ”์„œ๋“œ ์ •์˜๋ฅผ ๊ฒ€์ƒ‰ํ•˜์—ฌ url ๋งค๊ฐœ๋ณ€์ˆ˜๊ฐ€ nullable์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
rg --type kotlin 'fun updateProfile' -A 5

Length of output: 1224

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

๐Ÿงน Outside diff range and nitpick comments (2)
src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt (1)

14-15: LGTM: loadUserByUsername ๋ฉ”์„œ๋“œ์˜ ๊ฐœ์„ ๋œ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ

loadUserByUsername ๋ฉ”์„œ๋“œ์˜ ๋ณ€๊ฒฝ์€ ์‚ฌ์šฉ์ž๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์„ ๋•Œ ๋ช…์‹œ์ ์œผ๋กœ UserNotFoundException์„ ๋ฐœ์ƒ์‹œ์ผœ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ๋ฅผ ๊ฐœ์„ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์ฝ”๋“œ์˜ ์•ˆ์ •์„ฑ์„ ๋†’์ด๊ณ  ๋””๋ฒ„๊น…์„ ์šฉ์ดํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

๋” ๋‚˜์€ ๊ฐ€๋…์„ฑ์„ ์œ„ํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ฉ”์„œ๋“œ๋ฅผ ๋ถ„๋ฆฌํ•˜๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ•ด ๋ณด์„ธ์š”:

override fun loadUserByUsername(username: String): UserDetails {
    val user = getUserOrThrow(username)
    return AuthDetails(user.accountId, user.role)
}

private fun getUserOrThrow(username: String): User =
    userFacade.getUserByAccountId(username) ?: throw UserNotFoundException

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ฉ”์„œ๋“œ์˜ ์ฃผ์š” ๋กœ์ง๊ณผ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ๋ถ„๋ฆฌํ•˜์—ฌ ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ๊ณผ ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ๋”์šฑ ํ–ฅ์ƒ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt (1)

27-27: ์‚ฌ์šฉ์ž ์กฐํšŒ ๋กœ์ง ๊ฐœ์„  ์Šน์ธ ๋ฐ ์ œ์•ˆ

์‚ฌ์šฉ์ž๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์„ ๋•Œ UserNotFoundException์„ throwํ•˜๋Š” ๊ฒƒ์€ ์ข‹์€ ๊ฐœ์„ ์ž…๋‹ˆ๋‹ค. ์ด๋Š” null ํฌ์ธํ„ฐ ์˜ˆ์™ธ๋ฅผ ๋ฐฉ์ง€ํ•˜๊ณ  ๋” ๋ช…ํ™•ํ•œ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€๋…์„ฑ์„ ๋”์šฑ ๋†’์ด๊ธฐ ์œ„ํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด Elvis ์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ณ ๋ คํ•ด ๋ณด์„ธ์š”:

val user = userFacade.getUserById(review.userId) ?: throw UserNotFoundException()

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ฝ”๋“œ์˜ ์˜๋„๊ฐ€ ๋” ๋ช…ํ™•ํ•ด์ง€๊ณ  ๊ฐ„๊ฒฐํ•ด์ง‘๋‹ˆ๋‹ค.

๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

๐Ÿ“ฅ Commits

Files that changed from the base of the PR and between 04ad08f and c342b3c.

๐Ÿ“’ Files selected for processing (3)
  • src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt (2 hunks)
  • src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt (1 hunks)
  • src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt (2 hunks)
๐Ÿšง Files skipped from review as they are similar to previous changes (1)
  • src/main/kotlin/org/meogo/domain/user/facade/UserFacade.kt
๐Ÿงฐ Additional context used
๐Ÿ”‡ Additional comments (3)
src/main/kotlin/org/meogo/global/auth/AuthDetailsService.kt (1)

3-3: LGTM: UserNotFoundException ๊ฐ€์ ธ์˜ค๊ธฐ ์ถ”๊ฐ€

UserNotFoundException์„ ๊ฐ€์ ธ์˜ค๋Š” ๊ฒƒ์€ loadUserByUsername ๋ฉ”์„œ๋“œ์˜ ์ƒˆ๋กœ์šด ์˜ˆ์™ธ ์ฒ˜๋ฆฌ์— ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ๊ณผ ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ํ–ฅ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค.

src/main/kotlin/org/meogo/domain/review/service/QueryAllBySchoolIdService.kt (2)

6-6: import ๋ฌธ ์ถ”๊ฐ€ ์Šน์ธ

UserNotFoundException์„ importํ•˜๋Š” ๊ฒƒ์€ ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” queryAllBySchoolId ํ•จ์ˆ˜์—์„œ ์‚ฌ์šฉ์ž๋ฅผ ์ฐพ์ง€ ๋ชปํ–ˆ์„ ๋•Œ ์ด ์˜ˆ์™ธ๋ฅผ throwํ•˜๋Š” ์ƒˆ๋กœ์šด ๋กœ์ง๊ณผ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.


Line range hint 1-43: ์ „์ฒด ๊ฒ€ํ†  ์š”์•ฝ

์ด PR์˜ ๋ณ€๊ฒฝ ์‚ฌํ•ญ๋“ค์€ ์ „๋ฐ˜์ ์œผ๋กœ ์ฝ”๋“œ์˜ ํ’ˆ์งˆ์„ ํ–ฅ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค. UserNotFoundException์˜ ๋„์ž…๊ณผ ์‚ฌ์šฉ์€ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ๋ฅผ ๊ฐœ์„ ํ•˜๊ณ  ์ž ์žฌ์ ์ธ null ํฌ์ธํ„ฐ ์˜ˆ์™ธ๋ฅผ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ณ€๊ฒฝ์œผ๋กœ QueryAllBySchoolIdService์˜ ์•ˆ์ •์„ฑ๊ณผ ์‹ ๋ขฐ์„ฑ์ด ํ–ฅ์ƒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ œ์•ˆ๋œ ์ž‘์€ ๊ฐœ์„  ์‚ฌํ•ญ์„ ๊ณ ๋ คํ•ด ๋ณด์‹œ๊ณ , ๊ทธ ์™ธ์—๋Š” ์ด PR์„ ์Šน์ธํ•ด๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

๐Ÿ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

๐Ÿ“ฅ Commits

Files that changed from the base of the PR and between c342b3c and 6e53d22.

๐Ÿ“’ Files selected for processing (2)
  • src/main/kotlin/org/meogo/domain/user/domain/UserRepository.kt (1 hunks)
  • src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt (2 hunks)
๐Ÿงฐ Additional context used
๐Ÿ”‡ Additional comments (3)
src/main/kotlin/org/meogo/domain/user/domain/UserRepository.kt (1)

9-10: findById ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€ ์Šน์ธ

findById ๋ฉ”์„œ๋“œ์˜ ์ถ”๊ฐ€๋Š” ์ ์ ˆํ•ด ๋ณด์ž…๋‹ˆ๋‹ค:

  • UUID๋กœ ์‚ฌ์šฉ์ž๋ฅผ ์ฐพ๋Š” ๊ธฐ๋Šฅ์„ ๋ช…์‹œ์ ์œผ๋กœ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
  • ๋ฐ˜ํ™˜ ํƒ€์ž…์ด User?๋กœ ๋˜์–ด ์žˆ์–ด, ์‚ฌ์šฉ์ž๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š์„ ๊ฒฝ์šฐ๋ฅผ ์ ์ ˆํžˆ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ด๋Š” ์ด์ „ ๋ฆฌ๋ทฐ ์ฝ”๋ฉ˜ํŠธ์—์„œ ์ œ์•ˆ๋œ null ์ฒ˜๋ฆฌ ๋ฐฉ์‹๊ณผ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.
src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt (2)

15-20: ํด๋ž˜์Šค ์ด๋ฆ„ ๋ณ€๊ฒฝ ๋ฐ ์ƒ์„ฑ์ž ๋งค๊ฐœ๋ณ€์ˆ˜ ์ˆ˜์ •์ด ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค.

ํด๋ž˜์Šค ์ด๋ฆ„์„ UploadProfileService์—์„œ ModifyUserInfoService๋กœ ๋ณ€๊ฒฝํ•œ ๊ฒƒ์€ ๊ธฐ๋Šฅ์˜ ํ™•์žฅ์„ ์ž˜ ๋ฐ˜์˜ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ, ์ƒ์„ฑ์ž ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ์žฌ์ •๋ ฌ๊ณผ userFacade ์ถ”๊ฐ€๋Š” ๋…ผ๋ฆฌ์ ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค.


24-32: execute ๋ฉ”์„œ๋“œ์˜ ์ „๋ฐ˜์ ์ธ ๋ณ€๊ฒฝ์‚ฌํ•ญ์ด ์ ์ ˆํ•ฉ๋‹ˆ๋‹ค.

๋ฉ”์„œ๋“œ ์‹œ๊ทธ๋‹ˆ์ฒ˜ ๋ณ€๊ฒฝ๊ณผ ์ƒˆ๋กœ์šด ๋กœ์ง ๊ตฌํ˜„์ด ํ™•์žฅ๋œ ๊ธฐ๋Šฅ์„ ์ž˜ ๋ฐ˜์˜ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž ์ •๋ณด ์—…๋ฐ์ดํŠธ์™€ ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ ๊ด€๋ฆฌ๊ฐ€ ํšจ๊ณผ์ ์œผ๋กœ ํ†ตํ•ฉ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

fun findByAccountId(accountId: String): User?
fun findById(id: UUID): User?

fun findByAccountId(accountId: String): User
Copy link

Choose a reason for hiding this comment

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

โš ๏ธ Potential issue

findByAccountId ๋ฉ”์„œ๋“œ์˜ ๋ฐ˜ํ™˜ ํƒ€์ž… ๋ณ€๊ฒฝ์— ๋Œ€ํ•œ ์šฐ๋ ค

findByAccountId ๋ฉ”์„œ๋“œ์˜ ๋ฐ˜ํ™˜ ํƒ€์ž…์„ User?์—์„œ User๋กœ ๋ณ€๊ฒฝํ•œ ๊ฒƒ์€ ์ž ์žฌ์ ์ธ ๋ฌธ์ œ๋ฅผ ์•ผ๊ธฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • ์ด ๋ณ€๊ฒฝ์€ ๋ฉ”์„œ๋“œ๊ฐ€ ํ•ญ์ƒ User ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•ฉ๋‹ˆ๋‹ค.
  • ์กด์žฌํ•˜์ง€ ์•Š๋Š” accountId๋กœ ์กฐํšŒํ•  ๊ฒฝ์šฐ, ์˜ˆ๊ธฐ์น˜ ์•Š์€ NullPointerException์ด ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Kotlin์˜ null ์•ˆ์ „์„ฑ ์›์น™์— ์œ„๋ฐฐ๋ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค:

-fun findByAccountId(accountId: String): User
+fun findByAccountId(accountId: String): User?

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด accountId์— ํ•ด๋‹นํ•˜๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์—†์„ ๊ฒฝ์šฐ๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“ Committable suggestion

โ€ผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fun findByAccountId(accountId: String): User
fun findByAccountId(accountId: String): User?

val url = fileUtil.upload(file, Path.USER)
user.updateProfile(url)
userRepository.save(user)
if (file != null && user.profile != defaultImage) fileUtil.delete(user.profile, Path.USER)
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

ํ”„๋กœํ•„ ์ด๋ฏธ์ง€ ์‚ญ์ œ ์กฐ๊ฑด ๊ฐœ์„  ์ œ์•ˆ

ํ˜„์žฌ ๊ตฌํ˜„์€ ์ด์ „ ๋ฆฌ๋ทฐ ์˜๊ฒฌ์„ ๋ถ€๋ถ„์ ์œผ๋กœ ๋ฐ˜์˜ํ–ˆ์ง€๋งŒ, ๋” ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค:

if (file != null && user.profile != defaultImage) {
    fileUtil.delete(user.profile, Path.USER)
}

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ์ด ํ–ฅ์ƒ๋˜๊ณ , ์กฐ๊ฑด์˜ ์˜๋„๊ฐ€ ๋” ๋ช…ํ™•ํ•ด์ง‘๋‹ˆ๋‹ค.

) {

@Transactional
fun uploadProfile(file: MultipartFile) {
fun execute(request: UserModifyRequest, file: MultipartFile?) {
val user = userFacade.currentUser() ?: throw UserNotFoundException
Copy link

Choose a reason for hiding this comment

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

๐Ÿ› ๏ธ Refactor suggestion

UserNotFoundException ์ฒ˜๋ฆฌ ๊ฐœ์„  ๊ถŒ์žฅ

ํ˜„์žฌ UserNotFoundException์„ ๋˜์ง€๋Š” ๋ฐฉ์‹์ด ๊ฐœ์„ ๋˜์—ˆ์ง€๋งŒ, ๋” ๋‚˜์€ ์—๋Ÿฌ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค:

val user = userFacade.currentUser() ?: throw UserNotFoundException()

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์˜ˆ์™ธ์— ์ถ”๊ฐ€ ์ •๋ณด๋ฅผ ํฌํ•จ์‹œํ‚ฌ ์ˆ˜ ์žˆ๊ณ , ์˜ˆ์™ธ ์ฒ˜๋ฆฌ์˜ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@meltapplee meltapplee merged commit 54497b2 into main Oct 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

๋งˆ์ดํŽ˜์ด์ง€ ์ˆ˜์ • api
1 participant