Skip to content

[refactor] 유저 정보 조회 필드 null 가능하도록 수정 + 유저 닉네임 중복 확인 API 관련 리팩토링 #100

Merged
seung-in-Yoo merged 4 commits into
developfrom
feature/seungin
Aug 5, 2025
Merged

[refactor] 유저 정보 조회 필드 null 가능하도록 수정 + 유저 닉네임 중복 확인 API 관련 리팩토링 #100
seung-in-Yoo merged 4 commits into
developfrom
feature/seungin

Conversation

@seung-in-Yoo

@seung-in-Yoo seung-in-Yoo commented Aug 5, 2025

Copy link
Copy Markdown
Member

✔️ 연관 이슈

📝 작업 내용

  1. 원래 로직은 회원가입(로그인) 후, 유저 정보 등록을 바로 가도록 구현하였습니다.
  2. 하지만 프론트쪽에서 로직이 바뀌어서, 로그인 후 정보 조회를 해보고 유저가 등록한 해당 정보가 없으면 유저 정보 등록으로 넘어가도록 수정하였습니다.
  3. 때문에 원래는 유저 정보 조회에서 필드가 null이라면 에러 처리를 했지만, 유저 정보 조회에서 정보가 아무것도 없더라도 get으로 조회가 가능하도록 수정하였습니다.
  4. 원래는 유저 타입을 기본값 GENERAL로 설정했어서, 데이터 값이 비어있는지 여부 따라서 화면이 바뀌기때문에 해당 기본값을 NULL로 바꾸었고, 해당 수정으로 인해 바꿔야하는 부분도 수정하였습니다.
  5. 코드리뷰(코드래빗)에 따라 유저 닉네임 중복 확인 관련 리팩토링을 진행하였습니다.

스크린샷 (선택)

화면 캡처 2025-08-05 173841

Summary by CodeRabbit

  • 버그 수정

    • 사용자 유형이 없는 경우 발생할 수 있는 토큰 생성 오류를 방지했습니다.
    • 사용자 정보 조회 시 닉네임, 생년월일, 성별이 없어도 정상적으로 정보를 반환하도록 개선했습니다.
  • 리팩터

    • 불필요한 import 문을 정리하고, DTO 및 예외 클래스의 import 방식을 명확하게 변경했습니다.
    • 일부 컬렉션 테이블 명칭을 더 명확하게 수정했습니다.
    • User 엔티티의 userType 필드를 nullable로 변경하여, 기본값 없이 생성될 수 있도록 했습니다.

@seung-in-Yoo seung-in-Yoo self-assigned this Aug 5, 2025
@seung-in-Yoo seung-in-Yoo added 🔧 refactor 코드 리팩토링 🛠️ fix 기능 오류 및 코드 개선이 필요한 곳 수정 labels Aug 5, 2025
@coderabbitai

coderabbitai Bot commented Aug 5, 2025

Copy link
Copy Markdown

Walkthrough

JWT 토큰 생성 시 userType이 null일 경우를 고려하여 null 체크가 추가되었습니다. User 엔티티의 userType 컬럼이 nullable로 변경되고, createUser 메서드에서 userType 기본값 할당이 제거되었습니다. UserInfoService의 사용자 정보 조회 시 필드 null 검증 로직이 삭제되었습니다. 일부 import 정리도 함께 이루어졌습니다.

Changes

Cohort / File(s) Change Summary
JWT 토큰 생성 시 userType null 체크
src/main/java/com/wayble/server/auth/service/AuthService.java, src/main/java/com/wayble/server/auth/service/KakaoLoginService.java
JWT 토큰 생성 시 userType이 null일 경우 null을 전달하도록 null 체크 추가.
User 엔티티 및 생성 로직 변경
src/main/java/com/wayble/server/user/entity/User.java
userType 컬럼을 nullable로 변경, createUser에서 userType 기본값 할당 제거, 컬렉션 테이블명 일부 변경.
UserInfoService 사용자 정보 조회 검증 삭제
src/main/java/com/wayble/server/user/service/UserInfoService.java
getUserInfo에서 nickname, birthDate, gender의 null 검증 및 예외처리 로직 삭제.
불필요한/와일드카드 import 정리
src/main/java/com/wayble/server/user/controller/UserController.java, src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java, src/main/java/com/wayble/server/user/dto/UserInfoUpdateRequestDto.java, src/main/java/com/wayble/server/user/exception/UserErrorCase.java
사용하지 않는 import 및 와일드카드 import를 명시적 import로 정리.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AuthService
    participant User
    participant TokenProvider

    Client->>AuthService: 로그인/토큰 재발급 요청
    AuthService->>User: 사용자 조회
    User-->>AuthService: User 객체 반환 (userType nullable)
    AuthService->>TokenProvider: generateToken(userId, userType?.name())
    TokenProvider-->>AuthService: JWT 토큰 반환
    AuthService-->>Client: 토큰 응답
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐇
JWT에 null이 오면,
토끼는 깡총 뛰며 체크해요.
userType이 비어 있어도
이제 더는 멈추지 않죠!
import도 깔끔하게,
토끼의 코드밭은 한결 산뜻해졌답니다.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0b3a1db and 6ba090a.

📒 Files selected for processing (8)
  • src/main/java/com/wayble/server/auth/service/AuthService.java (2 hunks)
  • src/main/java/com/wayble/server/auth/service/KakaoLoginService.java (1 hunks)
  • src/main/java/com/wayble/server/user/controller/UserController.java (1 hunks)
  • src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java (0 hunks)
  • src/main/java/com/wayble/server/user/dto/UserInfoUpdateRequestDto.java (0 hunks)
  • src/main/java/com/wayble/server/user/entity/User.java (1 hunks)
  • src/main/java/com/wayble/server/user/exception/UserErrorCase.java (0 hunks)
  • src/main/java/com/wayble/server/user/service/UserInfoService.java (1 hunks)
💤 Files with no reviewable changes (3)
  • src/main/java/com/wayble/server/user/exception/UserErrorCase.java
  • src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java
  • src/main/java/com/wayble/server/user/dto/UserInfoUpdateRequestDto.java
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 im...
Learnt from: seung-in-Yoo
PR: Wayble-Project/wayble-spring#37
File: src/main/java/com/wayble/server/user/entity/User.java:61-62
Timestamp: 2025-07-13T15:08:59.318Z
Learning: Java에서 같은 패키지 내의 클래스들은 import 구문 없이 서로를 참조할 수 있다. com.wayble.server.user.entity 패키지 내의 클래스들은 명시적인 import 없이 사용 가능하다.

Applied to files:

  • src/main/java/com/wayble/server/user/controller/UserController.java
  • src/main/java/com/wayble/server/user/entity/User.java
🔇 Additional comments (7)
src/main/java/com/wayble/server/user/controller/UserController.java (1)

5-9: import 구문 정리 잘 되었습니다.

wildcard import에서 필요한 클래스만 명시적으로 import하도록 개선되어 코드 가독성과 명확성이 향상되었습니다.

src/main/java/com/wayble/server/user/service/UserInfoService.java (1)

108-121: 사용자 정보 조회 로직 수정이 올바릅니다.

null 필드 검증 로직을 제거하여 사용자 정보가 없어도 성공적으로 응답을 반환할 수 있게 되었습니다. 이는 새로운 프론트엔드 플로우 요구사항에 잘 맞습니다.

클라이언트에서는 응답의 각 필드가 null일 수 있음을 고려하여 적절한 처리를 해야 합니다.

src/main/java/com/wayble/server/auth/service/AuthService.java (2)

32-32: JWT 토큰 생성 시 null 안전성 개선이 우수합니다.

user.getUserType()이 null일 수 있는 상황에서 NullPointerException을 방지하기 위한 null 체크가 적절히 추가되었습니다.


75-75: 토큰 재발급 시에도 null 안전성이 일관되게 적용되었습니다.

reissue 메서드에서도 동일한 null 체크 패턴을 적용하여 일관성을 유지했습니다.

src/main/java/com/wayble/server/auth/service/KakaoLoginService.java (1)

63-66: 카카오 로그인에서도 null 안전성이 일관되게 적용되었습니다.

AuthService와 동일한 패턴으로 userType null 체크를 적용하여 새로 가입한 카카오 사용자의 경우에도 안전하게 JWT 토큰을 생성할 수 있습니다.

src/main/java/com/wayble/server/user/entity/User.java (2)

55-55: userType 필드의 nullable 변경이 적절합니다.

데이터베이스 스키마에서 user_type 컬럼을 nullable로 변경하여 새로운 사용자 플로우를 지원합니다. 이는 사용자 등록 시 타입을 나중에 설정할 수 있게 해줍니다.


62-62: 컬렉션 테이블 명명 규칙 개선이 좋습니다.

user_disability_type_mappinguser_mobility_aid_mapping으로 테이블명을 변경하여 더 명확하고 일관된 명명 규칙을 적용했습니다.

Also applies to: 68-68

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/seungin

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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @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 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

@seung-in-Yoo seung-in-Yoo merged commit e954670 into develop Aug 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🛠️ fix 기능 오류 및 코드 개선이 필요한 곳 수정 🔧 refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant