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

refactor(user): desperate user service #42

Merged
merged 2 commits into from
Dec 17, 2024
Merged

Conversation

waterfogSW
Copy link
Member

@waterfogSW waterfogSW commented Dec 17, 2024

Summary by CodeRabbit

  • New Features

    • 사용자 맞춤형 파트너 선호도 업데이트 기능 추가.
    • 사용자 프로필 이미지 업로드, 완료 및 삭제 기능 추가.
    • 사용자 프로필 정보 업데이트 및 위젯 관리 기능 추가.
  • Bug Fixes

    • 사용자 등록 기능을 단순화하여 오류 가능성 감소.
  • Refactor

    • 사용자 서비스 클래스 구조 조정 및 불필요한 메서드 제거.

@waterfogSW waterfogSW requested a review from dojinyou as a code owner December 17, 2024 12:29
@waterfogSW waterfogSW self-assigned this Dec 17, 2024
Copy link

coderabbitai bot commented Dec 17, 2024

워크스루

이 풀 리퀘스트는 사용자 관련 서비스 클래스들의 리팩토링을 포함합니다. 세 개의 새로운 서비스 클래스(UserDesiredPartnerService, UserProfileImageService, UserProfileService)가 추가되었으며, 기존 UserService에서 여러 메서드들이 제거되었습니다. 이러한 변경은 사용자 프로필, 이미지, 선호 파트너 관리 기능을 별도의 서비스로 분리하여 관심사 분리 원칙을 적용한 것입니다.

변경 사항

파일 변경 요약
application/.../UserDesiredPartnerService.kt 새로운 서비스 클래스 추가, 사용자 선호 파트너 업데이트 기능 구현
application/.../UserProfileImageService.kt 새로운 서비스 클래스 추가, 프로필 이미지 업로드/삭제 기능 구현
application/.../UserProfileService.kt 새로운 서비스 클래스 추가, 사용자 정보 및 위젯 관리 기능 구현
application/.../UserService.kt 기존 다중 인터페이스 구현 제거, 사용자 등록 기능만 유지

시 (Poem)

🐰 코드의 토끼가 노래하네 ~
서비스들이 춤추는 리팩토링의 날
관심사 분리, 깔끔한 설계
각자의 역할 명확하게
코드는 자유를 노래하네! 🌈


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 1

🧹 Nitpick comments (2)
application/src/main/kotlin/com/threedays/application/user/service/UserProfileService.kt (1)

22-33: userRepository.save(it) 호출 중복을 줄이기 위한 리팩토링 제안

각 메서드에서 userRepository.save(it) 호출이 반복되고 있습니다. 코드의 중복을 줄이고 유지보수성을 높이기 위해 이 부분을 별도의 공통 함수나 확장 함수로 추출하는 것을 고려해보세요.

application/src/main/kotlin/com/threedays/application/user/service/UserProfileImageService.kt (1)

38-45: alsolet 함수 사용의 일관성 유지

CompleteUserProfileImageUpload 메서드에서 let을 사용하여 userRepository.save(it)를 호출하고 있고, 다른 메서드에서는 also를 사용하고 있습니다. 코드의 일관성을 위해 동일한 스코프 함수를 사용하는 것을 추천드립니다.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2afb97 and d5101dd.

📒 Files selected for processing (4)
  • application/src/main/kotlin/com/threedays/application/user/service/UserDesiredPartnerService.kt (1 hunks)
  • application/src/main/kotlin/com/threedays/application/user/service/UserProfileImageService.kt (1 hunks)
  • application/src/main/kotlin/com/threedays/application/user/service/UserProfileService.kt (1 hunks)
  • application/src/main/kotlin/com/threedays/application/user/service/UserService.kt (2 hunks)
🔇 Additional comments (4)
application/src/main/kotlin/com/threedays/application/user/service/UserProfileService.kt (2)

38-41: userRepository.save(it) 호출 중복을 줄이기 위한 리팩토링 제안

putProfileWidget 메서드에서도 동일하게 userRepository.save(it) 호출이 반복됩니다. 앞서 언급한 리팩토링 방안을 적용하여 코드의 일관성과 가독성을 향상시킬 수 있습니다.


46-49: userRepository.save(it) 호출 중복을 줄이기 위한 리팩토링 제안

deleteProfileWidget 메서드에서도 userRepository.save(it) 호출이 반복되고 있습니다. 이전에 제안한 리팩토링을 고려하여 코드의 중복을 제거하시기 바랍니다.

application/src/main/kotlin/com/threedays/application/user/service/UserProfileImageService.kt (1)

38-45: userRepository.save(it) 호출 중복을 줄이기 위한 리팩토링 제안

여기서도 userRepository.save(it) 호출이 반복되고 있습니다. 이전에 제안한 리팩토링 방안을 적용하여 코드의 중복을 최소화하고 유지보수성을 향상시킬 수 있습니다.

application/src/main/kotlin/com/threedays/application/user/service/UserDesiredPartnerService.kt (1)

16-24: userRepository.save(it) 호출 중복을 줄이기 위한 리팩토링 제안

다른 서비스 클래스들과 마찬가지로 userRepository.save(it) 호출이 반복되고 있습니다. 앞서 제안된 리팩토링 방안을 참고하여 코드의 중복을 제거하고 일관성을 유지하시기 바랍니다.

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

🧹 Nitpick comments (1)
application/src/main/kotlin/com/threedays/application/user/service/UserService.kt (1)

Line range hint 24-52: 비즈니스 로직에 대한 예외 처리와 문서화가 필요합니다.

현재 구현은 기능적으로는 문제가 없으나, 다음 사항들을 고려해주시면 좋겠습니다:

  1. 입력값 유효성 검증 (예: 전화번호 형식, 생년월일 범위 등)
  2. 존재하지 않는 company/location ID에 대한 예외 처리
  3. 비즈니스 로직에 대한 문서화 (KDoc 추가)

다음과 같은 개선을 제안드립니다:

+ /**
+  * 새로운 사용자를 등록하고 로그인 토큰을 발급합니다.
+  *
+  * @param command 사용자 등록에 필요한 정보
+  * @throws EntityNotFoundException 존재하지 않는 company 또는 location ID 입력 시
+  * @throws IllegalArgumentException 유효하지 않은 입력값 제공 시
+  * @return 발급된 액세스 토큰과 리프레시 토큰
+  */
 @Transactional
 override fun invoke(command: RegisterUser.Command): RegisterUser.Result {
+    require(isValidPhoneNumber(command.phoneNumber)) { "유효하지 않은 전화번호 형식입니다" }
+    require(isValidBirthYear(command.userBirthYear)) { "유효하지 않은 생년월일입니다" }
+
     val userCompany: Company? = command.userCompanyId?.let { companyQueryRepository.get(it) }
     val userLocations: List<Location> =
         command.userLocationIds.map { locationQueryRepository.get(it) }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5101dd and 58612b9.

📒 Files selected for processing (1)
  • application/src/main/kotlin/com/threedays/application/user/service/UserService.kt (1 hunks)
🔇 Additional comments (1)
application/src/main/kotlin/com/threedays/application/user/service/UserService.kt (1)

Line range hint 1-22: 클래스 구조와 의존성이 잘 정리되었습니다!

서비스 클래스가 사용자 등록이라는 단일 책임에 맞게 깔끔하게 리팩토링되었습니다. 필요한 의존성만 주입받고 있으며, 포트와 어댑터 패턴을 잘 준수하고 있습니다.

@waterfogSW waterfogSW merged commit 0837f53 into main Dec 17, 2024
4 checks passed
@waterfogSW waterfogSW deleted the refactor/user-service branch December 17, 2024 13:59
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.

2 participants