Skip to content

Conversation

@wjdrjs00
Copy link
Member

@wjdrjs00 wjdrjs00 commented Dec 11, 2025

[ PR Content ]

kotlin serialization은 enum class에 대해서 내부적으로 최적화된 데이터 변환 코드를 제공해준다는 사실을 알게되어 프로젝트에 적용해봤습니다. (우선은 해당 수정으로 인해 변경영향이 가장 적은 Report에 대해서 먼저 적용을 했습니다.)
주요 포인트는 Enum class를 명시하는 경우 빌드 타임에 플러그인이 @Serializable이 붙은 Enum을 분석한 뒤 해당 Enum이 어떤 이름과 순서를 가지고 있는지와 매핑 로직을 작성해준다는 점입니다. 이로 인해 수동으로 매핑로직을 작성하지 않아도 되고 DTO단계부터 타입을 명시할 수 있다는 장점이 있습니다. -> Link 1
변경 내용을 아래에 작성한 내용을 참고해주세요. 또한 관련 문서는 해당 링크를 통해 확인할 수 있습니다. -> Link 2

프로젝트 변경점

  • 기존(as-is):
    -> 서버로부터 받은 json 데이터를 Stirng 타입의 필드로 수신 후 수동 매퍼 로직을 통해 Enum class로 변환

  • 변경(to-be):
    -> DTO에서 Enum 클래스를 String으로 치환하지 않고 직접 타입으로 선언하여 사용하도록 변경.

Related issue

Screenshot 📸

  • N/A

Work Description

  • Report 관련 DTO에서 Enum 타입을 사용하도록 변경
  • 기존 Enum class의 변환(toString, fromString)로직 제거

To Reviewers 📢

  • 추후 점진적으로 도입하여 수정하는 것이 좋을거 같습니다.
  • 추가로 reportId 관련 스웨거 명세에서는 Long 타입으로 정의되어 있는데 확인한뒤 수정이 필요할거 같네용..!

Summary by CodeRabbit

릴리스 노트

  • Refactor

    • 보고서 상태 및 카테고리 표현을 문자열에서 강타입 열거형으로 전환하여 데이터 무결성 향상 및 매핑 간소화
    • 열거형 이름 규칙 통일로 프레젠테이션 매핑이 최신 이름에 맞춰 업데이트됨
  • Chores

    • 직렬화(Serialization) 지원 추가로 데이터 직렬화/역직렬화 안정성 강화

✏️ Tip: You can customize this high-level summary in your review settings.

@wjdrjs00 wjdrjs00 requested a review from l5x5l December 11, 2025 06:54
@wjdrjs00 wjdrjs00 self-assigned this Dec 11, 2025
@wjdrjs00 wjdrjs00 added 🔨 Refactor 기존 기능 개선 🧤 대현 labels Dec 11, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 11, 2025

Walkthrough

리포트 관련 DTO와 도메인 열거형의 직렬화 전략을 문자열 기반에서 열거형 기반으로 전환하고, ReportStatus 상수명을 대문자 형식으로 변경 및 fromString/toString 헬퍼를 제거했습니다.

Changes

코호트 / 파일(들) 변경 요약
데이터 전송 객체 (DTO)
data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt, data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt, data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt
DTO 필드 타입을 StringReportCategory/ReportStatus로 변경. DTO → 도메인 매핑에서 fromString() 변환 제거하고 열거형 값을 직접 할당하도록 수정.
도메인 모델
domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt, domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt
@Serializable 추가(직렬화 적용), fromString/toString 헬퍼(동반 객체) 제거. ReportStatus 상수명 변경: Pending, InProgress, CompletedPENDING, IN_PROGRESS, COMPLETED.
프레젠테이션 매핑
presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt, presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt
fromDomain 매핑에서 새로운 대문자 열거형 상수(PENDING, IN_PROGRESS, COMPLETED)를 사용하도록 분기 케이스 업데이트.
빌드 설정
domain/build.gradle.kts
Kotlinx Serialization 플러그인 추가 및 kotlinx.serialization.json 의존성 등록.

Estimated code review effort

🎯 3 (중간) | ⏱️ ~22분

  • 추가 검토가 필요한 부분:
    • 네트워크 직렬화/역직렬화(서버와의 계약)에 따른 DTO 직렬화 포맷(특히 서버가 기대하는 문자열 케이스) 검증
    • 코드베이스 내에서 제거된 fromString/toString 헬퍼를 호출하던 다른 경로 유무 확인
    • 프레젠테이션 레이어의 매핑 분기들이 모든 케이스를 커버하는지 확인
    • build.gradle 변경으로 인한 빌드/메타데이터 영향(버전 충돌 등) 간단 확인

Poem

🐰✨
깡충깡충 바이트를 건너,
문자열 껍질 벗은 열거형 춤.
대문자 별빛 아래 맞춰진 값들,
직렬화 길에 새 발자국 남기네.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경 사항의 핵심(Report DTO의 Enum 직렬화 전략 변경)을 명확하게 설명하고 있습니다.
Description check ✅ Passed PR 설명이 관련 이슈, 작업 내용, 리뷰어를 위한 체크포인트를 모두 포함하고 있으며 충분히 작성되어 있습니다.
Linked Issues check ✅ Passed 코드 변경이 이슈 #166의 요구사항을 완벽하게 충족합니다. Report DTO에서 Enum을 직렬화 전략으로 변경하고 수동 매핑 로직을 제거했습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #166의 범위 내에 있습니다. Report 관련 DTO의 Enum 직렬화 처리 변경에 집중되어 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#166-report-dto-serialization

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2d0af7 and 9093bae.

📒 Files selected for processing (7)
  • data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt (2 hunks)
  • data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt (2 hunks)
  • data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt (2 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt (0 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt (1 hunks)
  • presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt (1 hunks)
  • presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt (1 hunks)
💤 Files with no reviewable changes (1)
  • domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt
⏰ 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
🔇 Additional comments (6)
data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt (1)

15-15: LGTM! Enum 타입 직접 사용으로 코드가 간결해졌습니다.

수동 변환 로직이 제거되고 kotlinx.serialization이 자동으로 처리하도록 변경되어 코드가 더 명확하고 안전해졌습니다.

Also applies to: 30-30

presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt (1)

17-19: LGTM! 새로운 enum 상수명에 맞게 정확히 매핑되었습니다.

Domain의 변경된 enum 상수명(PENDING, IN_PROGRESS, COMPLETED)을 올바르게 참조하고 있습니다.

presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt (1)

16-18: LGTM! 새로운 enum 상수명에 맞게 정확히 매핑되었습니다.

Domain의 변경된 enum 상수명을 올바르게 참조하고 있습니다.

data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt (2)

14-14: LGTM! Enum 타입 직접 사용으로 매핑 로직이 간결해졌습니다.

String에서 enum으로 변경하여 수동 변환(fromString) 로직이 제거되고, 타입 안전성이 향상되었습니다.

Also applies to: 18-18, 28-28, 30-30


12-12: ReportItemDto의 reportId 타입은 도메인 모델의 ReportItem과 일관성 있게 Int로 정의되어 있으므로, 현재 코드에는 타입 불일치 문제가 없습니다. Swagger 명세에서 Long으로 정의되었다는 PR 코멘트 내용을 확인할 수 없으며, 이 Android 저장소에서는 관련 API 명세를 찾을 수 없습니다.

Likely an incorrect or invalid review comment.

data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt (1)

15-15: LGTM! Enum 타입 직접 사용으로 매핑 로직이 간결해졌습니다.

reportStatus와 reportCategory를 String에서 enum 타입으로 변경하여 수동 변환 로직이 제거되고, kotlinx.serialization이 자동으로 직렬화를 처리하도록 개선되었습니다.

Also applies to: 21-21, 32-32, 36-36

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9093bae and 07b3fb9.

📒 Files selected for processing (3)
  • domain/build.gradle.kts (1 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt (1 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt (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
🔇 Additional comments (2)
domain/build.gradle.kts (1)

3-3: LGTM! Kotlin Serialization 설정이 올바르게 추가되었습니다.

도메인 모듈에 kotlinx.serialization 플러그인과 의존성을 추가하여 @Serializable 어노테이션을 사용할 수 있는 환경이 구성되었습니다. 이는 Report 관련 enum 클래스들의 자동 직렬화를 위해 필수적입니다.

Also applies to: 7-7

domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt (1)

5-9: 서버 API 포맷이 대문자 언더스코어 형식이므로 현재 구현은 정확합니다.

이전 코드의 companion object에서 "IN_PROGRESS" 문자열로 매핑되었던 점을 확인했습니다. 현재 enum 상수명 IN_PROGRESS는 kotlinx.serialization의 기본 동작에 따라 그대로 "IN_PROGRESS" 문자열로 직렬화되므로, 서버 API와 일치합니다.

따라서 @SerialName 어노테이션 추가는 불필요합니다.

Copy link
Contributor

@l5x5l l5x5l left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 👍

여담으로 보내주신 Link 2상에서는 서버측에서 보내주는 데이터와 enum간 이름이 동일한 경우 굳이 Serializable 어노테이션이 없어도 될 것 같다는 생각이 들어서 Gemini에 물어보니, 아래처럼 답변하네요!

  • 기본적으로 Enum 이름 그래도 JSON으로 주고 받는 경우라면 굳이 붙일 필요가 없지만, 서버 데이터와 Enum 상수의 이름이 다른 경우가 흔하며 이 경우에는 반드시 Serializable 어노테이션이 필요
  • 이름이 동일하더라도 "이 Enum은 단순히 내부 로직용이 아니라, API 통신이나 데이터 저장에 사용되는 객체(DTO의 일부)"라는 것을 명확하게 알리는 용도로 사용할 수 있기에 관습적으로 붙여두는 것이 유지보수 측에서 유리

어노테이션이 직렬화/코드 생성과 같은 기능적인 부분 뿐만 아니라 Dto/Domain 모델과 같이 어느 레이어에서 사용되는 클래스인지를 표시할 때도 유용하게 사용될 수 있다는 점을 덕분에 알게 되었습니다!

@wjdrjs00 wjdrjs00 merged commit 6f82d71 into develop Dec 13, 2025
2 checks passed
@wjdrjs00 wjdrjs00 deleted the refactor/#166-report-dto-serialization branch December 13, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 Refactor 기존 기능 개선 🧤 대현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] Enum class 직렬화 전략을 변경합니다.

3 participants