Skip to content

Conversation

@minjee2758
Copy link
Collaborator

@minjee2758 minjee2758 commented Aug 31, 2025

PR 생성 시 아래 항목을 채워주세요.

제목 예시: feat : Pull request template 작성

(작성 후 이 안내 문구는 삭제해주세요)


작업 내용

  • 어떤 기능(또는 수정 사항)을 구현했는지 간략하게 설명해주세요.
  • 예) "회원가입 API에 이메일 중복 검사 기능 추가"

변경 사항

  • 구현한 주요 로직, 클래스, 메서드 등을 bullet 형식으로 기술해주세요.
  • 예)
    • UserService.createUser() 메서드 추가
    • @Email 유효성 검증 적용

트러블 슈팅

  • 구현 중 마주한 문제와 해결 방법을 기술해주세요.
  • 예)
    • 문제: @Transactional이 적용되지 않음
    • 해결: 메서드 호출 방식 변경 (this.AopProxyUtils. 사용)

해결해야 할 문제

  • 기능은 동작하지만 리팩토링이나 논의가 필요한 부분을 적어주세요.
  • 예)D
    • UserController에서 비즈니스 로직 일부 처리 → 서비스로 이전 고려 필요

참고 사항

  • 기타 공유하고 싶은 정보나 참고한 문서(링크 등)가 있다면 작성해주세요.

코드 리뷰 전 확인 체크리스트

  • 불필요한 콘솔 로그, 주석 제거
  • 커밋 메시지 컨벤션 준수 (type : )
  • 기능 정상 동작 확인

Summary by CodeRabbit

  • 신기능
    • 사용자 언어 설정이 안정적으로 반영되어, 프로필에서 언어 선호도를 일관되게 표시합니다.
  • 버그 수정
    • 사용자 정보 조회 시 언어 값이 비어 있는 계정에도 기본 언어가 자동 적용되어 빈 값 표시나 조회 오류를 방지합니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 31, 2025

Walkthrough

UserService의 getUserInfo 트랜잭션을 읽기 전용에서 읽기/쓰기로 변경하고, 사용자 언어가 null인 경우 LanguageDomainService에서 기본 언어(1L)를 조회해 User에 설정한 뒤 응답을 생성합니다. User 엔티티에 공개 setter setLanguage가 추가되었습니다.

Changes

Cohort / File(s) Summary
UserService 트랜잭션/언어 기본값 처리
src/main/java/org/ezcode/codetest/application/usermanagement/user/service/UserService.java
@Transactional(readOnly = true)@Transactional로 변경. getUserInfo에서 user.getLanguage()가 null이면 languageDomainService.getLanguage(1L)로 기본 언어를 로드하고 user.setLanguage(...)로 주입 후 응답 구성.
User 엔티티 언어 setter 추가
src/main/java/org/ezcode/codetest/domain/user/model/entity/User.java
public void setLanguage(Language userLanguage) 메서드 추가로 language 필드 설정 가능. 기존 엔티티 동작에 다른 변경 없음.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant UserService
  participant UserRepository as UserRepo
  participant LanguageDomainService as LangSvc

  Client->>UserService: getUserInfo(authUser)
  UserService->>UserRepo: findById(authUser.userId)
  UserRepo-->>UserService: User
  alt 사용자 언어가 null
    UserService->>LangSvc: getLanguage(1L)
    LangSvc-->>UserService: Language(default)
    UserService->>UserService: user.setLanguage(default)
  else 사용자 언어가 존재
    Note over UserService: 언어 유지
  end
  UserService-->>Client: UserInfoResponse(언어 포함)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • refactor : language response #182: getUserInfo 언어 처리 변경과 응답 변환(LanguageResponse) 수정이 포함되어 본 PR의 언어 기본값/설정 로직과 직접 연관.
  • Feature/user language select #180: UserService의 언어 로직과 User 엔티티의 언어 접근자 관련 수정이 있어 본 PR의 setter 추가 및 기본 언어 주입과 밀접히 관련.

Poem

새싹 코드 밭에 바람 살랑,
언어 없던 유저에 말 한 줌 장착! 🐇
트랜잭션 옷도 갈아입고,
기본값 1L로 길을 찾네.
찍-찍! 응답에 말꽃이 폈다.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/user-info-table

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/ezcode/codetest/application/usermanagement/user/service/UserService.java (1)

107-110: 신규 프로필 업로드 직후 “신규 이미지”가 삭제되는 치명적 버그

user.modifyProfileImage(profileImageUrl)로 새 URL을 세팅한 뒤, 삭제 시 user.getProfileImageUrl()를 사용해 방금 업로드한 이미지를 지웁니다. 반드시 이전 URL(oldImageUrl)을 삭제해야 합니다.

- user.modifyProfileImage(profileImageUrl);
- if (oldImageUrl!=null) {
- 	s3Uploader.delete(user.getProfileImageUrl(), "profile");
- }
+ user.modifyProfileImage(profileImageUrl);
+ if (oldImageUrl != null) {
+ 	s3Uploader.delete(oldImageUrl, "profile");
+ }
🧹 Nitpick comments (3)
src/main/java/org/ezcode/codetest/domain/user/model/entity/User.java (1)

219-222: 공개 setter 추가로 엔티티 불변성 약화 + 널 가드 부재

서비스 레이어 어디서든 임의 언어로 변경 가능해져 도메인 무결성이 약해집니다. 또한 null 전달에 대한 방어가 없습니다. 최소한 null 가드를 두고, 가능하면 “없을 때만 기본 언어를 적용”하는 도메인 메서드로 의도를 드러내는 편이 안전합니다.

다음처럼 방어 로직을 추가해 주세요(최소 변경):

- public void setLanguage(Language userLanguage) {
- 	this.language = userLanguage;
- }
+ public void setLanguage(Language userLanguage) {
+ 	if (userLanguage == null) {
+ 		throw new IllegalArgumentException("userLanguage must not be null");
+ 	}
+ 	this.language = userLanguage;
+ }

또는 “조회 시 기본 언어만 주입” 의도를 엔티티가 스스로 보장하도록:

+ public void applyDefaultLanguageIfAbsent(Language defaultLanguage) {
+ 	if (this.language == null) {
+ 		if (defaultLanguage == null) {
+ 			throw new IllegalArgumentException("defaultLanguage must not be null");
+ 		}
+ 		this.language = defaultLanguage;
+ 	}
+ }

서비스의 호출부는 user.applyDefaultLanguageIfAbsent(...)로 교체 가능합니다.

src/main/java/org/ezcode/codetest/application/usermanagement/user/service/UserService.java (2)

59-59: getUserInfo가 쓰기 트랜잭션으로 변경됨 — 의도 확인 필요

조회 메서드에서 DB 업데이트가 발생합니다(기본 언어 자동 설정). 재시도/캐시 계층/리드 레플리카 사용 환경에서 부작용이 될 수 있어 팀 합의가 필요합니다. 로그인 시점 또는 일회성 마이그레이션/배치로 보정하는 대안도 고려 바랍니다.


67-70: 기본 언어 ID 하드코딩(1L) 제거 및 도메인 위임 권장

매직 넘버 1L 대신 상수/설정 또는 도메인 서비스 메서드로 의도를 명확히 해 주세요. 또한 null 체크 로직을 엔티티 메서드로 위임하면 재사용성과 안전성이 좋아집니다.

서비스 최소 수정안:

- if (user.getLanguage() == null) {
- 	Language userLanguage = languageDomainService.getLanguage(1L);
- 	user.setLanguage(userLanguage);
- }
+ if (user.getLanguage() == null) {
+ 	Language defaultLanguage = languageDomainService.getLanguage(DEFAULT_LANGUAGE_ID);
+ 	user.setLanguage(defaultLanguage); // 또는 user.applyDefaultLanguageIfAbsent(defaultLanguage)
+ }

클래스 상단에 상수 추가(권장):

private static final long DEFAULT_LANGUAGE_ID = 1L;

또는 도메인 서비스에 전가:

Language defaultLanguage = languageDomainService.getDefaultLanguage();
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f6679f8 and 8eb45f9.

📒 Files selected for processing (2)
  • src/main/java/org/ezcode/codetest/application/usermanagement/user/service/UserService.java (1 hunks)
  • src/main/java/org/ezcode/codetest/domain/user/model/entity/User.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

@minjee2758 minjee2758 merged commit dd15a92 into dev Aug 31, 2025
2 checks passed
@minjee2758 minjee2758 deleted the refactor/user-info-table branch August 31, 2025 11:57
@coderabbitai coderabbitai bot mentioned this pull request Sep 5, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants