From 9093baecb337c93e438ead0603d57f26e2146e97 Mon Sep 17 00:00:00 2001 From: wjdrjs00 Date: Thu, 11 Dec 2025 14:32:37 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Refactor:=20reprot=20=EA=B4=80=EB=A0=A8=20D?= =?UTF-8?q?to=20Enum=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/model/request/ReportRequestDto.kt | 4 +-- .../report/model/response/ReportDetailDto.kt | 8 +++--- .../report/model/response/ReportItemDto.kt | 8 +++--- .../domain/report/model/ReportCategory.kt | 21 ---------------- .../domain/report/model/ReportStatus.kt | 25 +++---------------- .../reportdetail/model/ReportProcess.kt | 6 ++--- .../reporthistory/model/ReportProcess.kt | 6 ++--- 7 files changed, 19 insertions(+), 59 deletions(-) diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt b/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt index 3c82651f..e35790ff 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/model/request/ReportRequestDto.kt @@ -12,7 +12,7 @@ data class ReportRequestDto( @SerialName("reportContent") val reportContent: String, @SerialName("reportCategory") - val reportCategory: String, + val reportCategory: ReportCategory, @SerialName("reportImageUrls") val reportImageUrls: List, @SerialName("reportLocation") @@ -27,7 +27,7 @@ fun Report.toDto(): ReportRequestDto { return ReportRequestDto( reportTitle = this.title, reportContent = this.content, - reportCategory = ReportCategory.toString(this.category), + reportCategory = this.category, reportImageUrls = this.imageUrls, reportLocation = this.address, latitude = this.latitude, diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt index 3c9cb097..db949bfc 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportDetailDto.kt @@ -12,13 +12,13 @@ class ReportDetailDto( @SerialName("reportDate") val reportDate: String, @SerialName("reportStatus") - val reportStatus: String, + val reportStatus: ReportStatus, @SerialName("reportTitle") val reportTitle: String, @SerialName("reportContent") val reportContent: String, @SerialName("reportCategory") - val reportCategory: String, + val reportCategory: ReportCategory, @SerialName("reportLocation") val reportLocation: String, @SerialName("reportImageUrls") @@ -29,10 +29,10 @@ fun ReportDetailDto.toDomain(id: String?): ReportDetail = ReportDetail( id = id ?: "", date = LocalDate.parse(this.reportDate), - status = ReportStatus.fromString(this.reportStatus), + status = this.reportStatus, title = this.reportTitle, content = this.reportContent, - category = ReportCategory.fromString(this.reportCategory), + category = this.reportCategory, address = this.reportLocation, imageUrls = this.reportImageUrls, ) diff --git a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt index 1b26ff2a..aca22611 100644 --- a/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt +++ b/data/src/main/java/com/threegap/bitnagil/data/report/model/response/ReportItemDto.kt @@ -11,11 +11,11 @@ data class ReportItemDto( @SerialName("reportId") val reportId: Int, @SerialName("reportStatus") - val reportStatus: String, + val reportStatus: ReportStatus, @SerialName("reportTitle") val reportTitle: String, @SerialName("reportCategory") - val reportCategory: String, + val reportCategory: ReportCategory, @SerialName("reportLocation") val reportLocation: String, @SerialName("reportImageUrl") @@ -25,9 +25,9 @@ data class ReportItemDto( fun ReportItemDto.toDomain(): ReportItem = ReportItem( id = this.reportId, - status = ReportStatus.fromString(this.reportStatus), + status = this.reportStatus, title = this.reportTitle, - category = ReportCategory.fromString(this.reportCategory), + category = this.reportCategory, address = this.reportLocation, imageUrl = this.reportImageUrl, ) diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt index 51315b3c..ec701bd7 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt @@ -6,25 +6,4 @@ enum class ReportCategory { WATERFACILITY, AMENITY, ; - - companion object { - fun fromString(value: String): ReportCategory { - return when (value) { - "TRANSPORTATION" -> TRANSPORTATION - "LIGHTING" -> LIGHTING - "WATERFACILITY" -> WATERFACILITY - "AMENITY" -> AMENITY - else -> throw IllegalArgumentException("Invalid ReportCategory value: $value") - } - } - - fun toString(value: ReportCategory): String { - return when (value) { - TRANSPORTATION -> "TRANSPORTATION" - LIGHTING -> "LIGHTING" - WATERFACILITY -> "WATERFACILITY" - AMENITY -> "AMENITY" - } - } - } } diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt index a618d0db..00436e75 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt @@ -1,27 +1,8 @@ package com.threegap.bitnagil.domain.report.model enum class ReportStatus { - Pending, - InProgress, - Completed, + PENDING, + IN_PROGRESS, + COMPLETED, ; - - companion object { - fun fromString(value: String): ReportStatus { - return when (value) { - "PENDING" -> Pending - "IN_PROGRESS" -> InProgress - "COMPLETED" -> Completed - else -> throw IllegalArgumentException("Invalid ReportStatus value: $value") - } - } - - fun toString(value: ReportStatus): String { - return when (value) { - Pending -> "PENDING" - InProgress -> "IN_PROGRESS" - Completed -> "COMPLETED" - } - } - } } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt index 1fe8cecc..96f889c0 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reportdetail/model/ReportProcess.kt @@ -13,9 +13,9 @@ enum class ReportProcess( companion object { fun fromDomain(status: ReportStatus): ReportProcess { return when (status) { - ReportStatus.Pending -> Reported - ReportStatus.InProgress -> Progress - ReportStatus.Completed -> Complete + ReportStatus.PENDING -> Reported + ReportStatus.IN_PROGRESS -> Progress + ReportStatus.COMPLETED -> Complete } } } diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt index f4456f59..5ab5729f 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/reporthistory/model/ReportProcess.kt @@ -14,9 +14,9 @@ enum class ReportProcess( companion object { fun fromDomain(status: ReportStatus): ReportProcess { return when (status) { - ReportStatus.Pending -> Reported - ReportStatus.InProgress -> Progress - ReportStatus.Completed -> Complete + ReportStatus.PENDING -> Reported + ReportStatus.IN_PROGRESS -> Progress + ReportStatus.COMPLETED -> Complete } } } From 07b3fb9ccc191c3cf45fdb9289aca83ce9e6d9d4 Mon Sep 17 00:00:00 2001 From: wjdrjs00 Date: Thu, 11 Dec 2025 16:17:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Feat:=20Report=20=EA=B4=80=EB=A0=A8=20enum?= =?UTF-8?q?=20=ED=81=B4=EB=9E=98=EC=8A=A4=EC=97=90=20=EC=A7=81=EB=A0=AC?= =?UTF-8?q?=ED=99=94=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/build.gradle.kts | 2 ++ .../threegap/bitnagil/domain/report/model/ReportCategory.kt | 3 +++ .../com/threegap/bitnagil/domain/report/model/ReportStatus.kt | 3 +++ 3 files changed, 8 insertions(+) diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index eb710e93..a6a6313b 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -1,8 +1,10 @@ plugins { alias(libs.plugins.bitnagil.kotlin) + alias(libs.plugins.kotlin.serialization) } dependencies { + implementation(libs.kotlinx.serialization.json) implementation(libs.kotlinx.coroutines.core) implementation(libs.javax.inject) testImplementation(libs.junit) diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt index ec701bd7..3147cbf4 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportCategory.kt @@ -1,5 +1,8 @@ package com.threegap.bitnagil.domain.report.model +import kotlinx.serialization.Serializable + +@Serializable enum class ReportCategory { TRANSPORTATION, LIGHTING, diff --git a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt index 00436e75..b23b3f30 100644 --- a/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt +++ b/domain/src/main/java/com/threegap/bitnagil/domain/report/model/ReportStatus.kt @@ -1,5 +1,8 @@ package com.threegap.bitnagil.domain.report.model +import kotlinx.serialization.Serializable + +@Serializable enum class ReportStatus { PENDING, IN_PROGRESS,