Skip to content

[refactor] 유저 엔티티 (장애유형,이동보조수단) 복수 선택 가능을 위한 리팩토링 진행 #86

Merged
seung-in-Yoo merged 7 commits into
developfrom
feature/seungin
Jul 30, 2025
Merged

[refactor] 유저 엔티티 (장애유형,이동보조수단) 복수 선택 가능을 위한 리팩토링 진행 #86
seung-in-Yoo merged 7 commits into
developfrom
feature/seungin

Conversation

@seung-in-Yoo

@seung-in-Yoo seung-in-Yoo commented Jul 30, 2025

Copy link
Copy Markdown
Member

✔️ 연관 이슈

📝 작업 내용

  1. List 필드를 데이터베이스의 단일 컬럼에 JSON 문자열로 변환/저장하기 위한 StringListConverter 클래스를 추가했습니다.
  2. 장애 유형, 이동 보조 수단 등 복수 선택 필드를 DB 컬럼에 List로 매핑할 수 있도록 하여, JSON 직렬화/역직렬화가 자동으로 동작하게 변경했습니다.
  3. 기존 단일 String에서 List으로 타입을 변경한 disabilityType, mobilityAid의 필드 선언 및 setter를 수정했습니다.

스크린샷 (선택)

유저 정보 등록

유저정보등록리팩(1)

유저 정보 수정

유저정보수정리팩(1)

💬 리뷰 요청 사항(선택)

Summary by CodeRabbit

  • 신규 기능

    • 장애 유형 및 보조기구 정보를 여러 개 입력할 수 있도록 지원합니다.
    • 장애 유형 및 보조기구 정보를 데이터베이스에 JSON 형식으로 저장하고 불러오는 기능이 추가되었습니다.
  • 버그 수정

    • 장애 유형 및 보조기구 입력 시 단일 값이 아닌 복수 값(List) 저장 및 조회가 가능합니다.

@seung-in-Yoo seung-in-Yoo self-assigned this Jul 30, 2025
@seung-in-Yoo seung-in-Yoo added 💡 feature 기능 구현 및 개발 🔧 refactor 코드 리팩토링 labels Jul 30, 2025
@coderabbitai

coderabbitai Bot commented Jul 30, 2025

Copy link
Copy Markdown

Walkthrough

disabilityTypemobilityAid 필드가 String에서 List<String> 타입으로 변경되었습니다. 이에 따라 DTO와 엔티티, 그리고 JPA 변환기(StringListConverter)가 새로 추가되어 리스트와 JSON 문자열 간 변환을 처리합니다. 일부 불필요한 import도 제거되었습니다.

Changes

Cohort / File(s) Change Summary
String 리스트 변환기 도입
src/main/java/com/wayble/server/common/converter/StringListConverter.java
JPA에서 List<String>과 JSON 문자열 간 변환을 위한 StringListConverter 클래스 신설
UserInfo DTO 필드 타입 변경
src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java, src/main/java/com/wayble/server/user/dto/UserInfoUpdateRequestDto.java
disabilityType, mobilityAid 필드를 String에서 List<String>으로 변경
User 엔티티 필드 및 세터 변경
src/main/java/com/wayble/server/user/entity/User.java
disabilityType, mobilityAid 필드를 List<String>으로 변경 및 @Convert 적용, 관련 setter 시그니처 변경
불필요한 import 제거
src/main/java/com/wayble/server/user/controller/UserController.java
JwtTokenProvider, AuthService import 삭제 (기능 변화 없음)

Sequence Diagram(s)

sequenceDiagram
    participant DTO as UserInfoRegister/UpdateRequestDto
    participant Controller
    participant Entity as User Entity
    participant Converter as StringListConverter
    participant DB

    DTO->>Controller: disabilityType, mobilityAid as List<String>
    Controller->>Entity: setDisabilityType(List<String>), setMobilityAid(List<String>)
    Entity->>Converter: convertToDatabaseColumn(List<String>)
    Converter->>DB: JSON String 저장
    DB->>Converter: JSON String 로드
    Converter->>Entity: convertToEntityAttribute(String) → List<String>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
유저 정보 등록/수정 API가 iOS 연동에 맞게 동작하도록 DTO, 엔티티 구조 개선 (#79)
기타 유저 API, 웨이블존, 리뷰, 장소 관련 API 연동 (#79) 이 변경은 오직 유저 정보 등록/수정 관련 구조에 한정됨. 나머지 API에 대한 변경은 없음.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
불필요한 import 제거 (src/main/java/com/wayble/server/user/controller/UserController.java) 이 변경은 기능과 무관하며, linked issue의 목적과 직접적 관련이 없음. 그러나 코드 정리에 해당하므로 영향은 미미함.

Possibly related PRs

  • [feat] 유저 정보 등록 API 구현  #72: User 엔티티의 disabilityTypemobilityAid 필드를 단순 String에서 List으로 변경하고 JPA 변환기를 도입하는 주요 PR과 관련 있음.
    해당 PR은 같은 필드를 단순 String 타입으로 추가하는 내용이며, 본 PR은 타입 변경과 변환기 적용을 포함함.

Suggested reviewers

  • KiSeungMin

Poem

🐇
리스트로 바뀐 장애와 보조,
JSON 변환기도 새로이 도입됐죠!
iOS와 연동할 준비는 끝,
DTO, 엔티티 모두 새 모습으로 빛.
깔끔한 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 111d37d and b1c6711.

📒 Files selected for processing (1)
  • src/main/java/com/wayble/server/common/converter/StringListConverter.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/wayble/server/common/converter/StringListConverter.java
✨ 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.
    • @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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

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.
  • @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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (2)
src/main/java/com/wayble/server/common/converter/StringListConverter.java (2)

13-13: ObjectMapper를 static으로 선언하여 성능 최적화

ObjectMapper는 스레드 안전하고 생성 비용이 높으므로 static 필드로 선언하는 것이 더 효율적입니다.

-    private final ObjectMapper objectMapper = newObjectMapper();
+    private static final ObjectMapper objectMapper = new ObjectMapper();

16-32: 예외 처리 시 로깅 추가 고려

현재 모든 예외를 무시하고 기본값을 반환하고 있어 직렬화/역직렬화 오류를 디버깅하기 어려울 수 있습니다. 로깅을 추가하여 문제 상황을 추적할 수 있도록 개선을 고려해보세요.

+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
 @Converter
 public class StringListConverter implements AttributeConverter<List<String>, String> {
     public String convertToDatabaseColumn(List<String> list) {
         try {
             return list == null ? "[]" : objectMapper.writeValueAsString(list);
         } catch (Exception e) {
+            log.warn("Failed to convert list to JSON string: {}", list, e);
             return "[]";
         }
     }
     public List<String> convertToEntityAttribute(String json) {
         try {
             if (json == null || json.isBlank()) return Collections.emptyList();
             return objectMapper.readValue(json, new TypeReference<List<String>>() {});
         } catch (Exception e) {
+            log.warn("Failed to convert JSON string to list: {}", json, e);
             return Collections.emptyList();
         }
     }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 072182b and 111d37d.

📒 Files selected for processing (5)
  • src/main/java/com/wayble/server/common/converter/StringListConverter.java (1 hunks)
  • src/main/java/com/wayble/server/user/controller/UserController.java (0 hunks)
  • src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java (2 hunks)
  • src/main/java/com/wayble/server/user/dto/UserInfoUpdateRequestDto.java (1 hunks)
  • src/main/java/com/wayble/server/user/entity/User.java (3 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/com/wayble/server/user/controller/UserController.java
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/wayble/server/user/entity/User.java (1)

Learnt from: seung-in-Yoo
PR: #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 없이 사용 가능하다.

🔇 Additional comments (8)
src/main/java/com/wayble/server/common/converter/StringListConverter.java (1)

11-33: 구현이 올바르게 되어있습니다

JPA AttributeConverter 인터페이스를 올바르게 구현했고, List과 JSON 문자열 간의 변환을 적절히 처리합니다. null 입력 처리와 안전한 기본값 반환도 잘 구현되어 있습니다.

src/main/java/com/wayble/server/user/dto/UserInfoRegisterRequestDto.java (2)

11-11: 올바른 import 추가

List 타입 사용을 위한 import가 적절히 추가되었습니다.


28-29: 다중 선택을 위한 필드 타입 변경이 적절합니다

disabilityTypemobilityAid 필드를 String에서 List<String>으로 변경하여 여러 값을 선택할 수 있도록 개선되었습니다. 필드 주석도 명확하게 작성되어 있습니다.

src/main/java/com/wayble/server/user/dto/UserInfoUpdateRequestDto.java (2)

7-7: 일관된 import 추가

register DTO와 동일하게 List 타입 사용을 위한 import가 추가되었습니다.


15-16: 일관된 필드 타입 변경

register DTO와 동일하게 disabilityTypemobilityAid 필드가 List<String> 타입으로 변경되어 일관성이 유지되고 있습니다. 업데이트 DTO의 nullable 특성도 적절히 유지되었습니다.

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

3-3: 컨버터 사용을 위한 import 추가

StringListConverter 사용을 위한 import가 적절히 추가되었습니다.


62-69: 엔티티 필드의 다중 선택 지원 구현이 올바릅니다

@Convert(converter = StringListConverter.class) 어노테이션을 통해 List<String> 타입 필드의 데이터베이스 저장/조회가 올바르게 구현되었습니다. JSON 직렬화/역직렬화가 자동으로 처리됩니다.


124-126: setter 메서드가 새로운 필드 타입에 맞게 업데이트되었습니다

disabilityTypemobilityAid setter 메서드가 List<String> 타입을 받도록 올바르게 수정되어 필드 타입과 일관성이 유지되었습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💡 feature 기능 구현 및 개발 🔧 refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] iOS 연동: 인증, 유저, 웨이블존 (목록,리뷰,장소) 관련 프론트 API 통신

2 participants