-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#187 의약품 상세 정보 응답 시 재심사 날짜로 인해 발생하는 데이터 오류 수정, UI에 표시할 데이터 구조 수정하였고 M…
…apper클래스를 만들어서 적절한 값으로 변경하여 주는 기능 추가 및 지속 작업 중
- Loading branch information
Showing
21 changed files
with
190 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
core/model/src/main/java/com/android/mediproject/core/model/DateTime.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
package com.android.mediproject.core.model | ||
|
||
import com.android.mediproject.core.model.common.UiValue | ||
import java.time.LocalDate | ||
import java.time.LocalDateTime | ||
import java.time.format.DateTimeFormatter | ||
|
||
fun String.toLocalDate(format: String): LocalDate? = if (isEmpty()) null else LocalDate.parse(this, DateTimeFormatter.ofPattern(format)) | ||
fun String?.toLocalDate(format: String): DateTimeValue = DateTimeValue(this, format) | ||
|
||
fun String.toLocalDateTime(format: String): LocalDateTime = LocalDateTime.parse(this, DateTimeFormatter.ofPattern(format)) | ||
|
||
class DateTimeValue(dateTime: String?, format: String) : UiValue<LocalDate> { | ||
override val value: LocalDate = dateTime?.run { LocalDate.parse(this, DateTimeFormatter.ofPattern(format)) } ?: LocalDate.MIN | ||
override val isEmpty: Boolean = value.isEqual(LocalDate.MIN) | ||
} |
15 changes: 15 additions & 0 deletions
15
core/model/src/main/java/com/android/mediproject/core/model/common/UiValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.android.mediproject.core.model.common | ||
|
||
/** | ||
* UI에서 사용하는 값을 나타내기 위한 자료형 | ||
* | ||
* @param T UI에서 사용하는 값의 자료형 | ||
* @property value UI에서 사용하는 값 | ||
* @property isEmpty UI에서 사용하는 값이 비어있는지 여부 | ||
* | ||
* LocalDate와 같이 Date값의 존재 여부를 Null대신 구분짓기 위해 사용한다. | ||
*/ | ||
interface UiValue<T> { | ||
val value: T | ||
val isEmpty: Boolean | ||
} |
14 changes: 0 additions & 14 deletions
14
core/model/src/main/java/com/android/mediproject/core/model/constants/MedicationType.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...a/com/android/mediproject/core/model/medicine/common/cancel/MedicineCancelStatusMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.android.mediproject.core.model.medicine.common.cancel | ||
|
||
import com.android.mediproject.core.model.toLocalDate | ||
|
||
class MedicineCancelStatusMapper { | ||
companion object { | ||
private const val cancelDateFormat = "yyyyMMdd" | ||
fun map(cancelName: String, cancelDate: String? = null): MedicineCancelStatus { | ||
return when (MedicineCancelStatusType.statusOf(cancelName)) { | ||
MedicineCancelStatusType.CANCELED -> Canceled(cancelDate.toLocalDate(cancelDateFormat)) | ||
MedicineCancelStatusType.EXPIRED -> Expired(cancelDate.toLocalDate(cancelDateFormat)) | ||
MedicineCancelStatusType.NORMAL -> Normal() | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ava/com/android/mediproject/core/model/medicine/common/cancel/MedicineCancelStatusType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.android.mediproject.core.model.medicine.common.cancel | ||
|
||
import androidx.annotation.StringRes | ||
import com.android.mediproject.core.model.DateTimeValue | ||
import com.android.mediproject.core.model.R | ||
|
||
enum class MedicineCancelStatusType(val status: String, @StringRes val statusStringResId: Int) { | ||
CANCELED("취하", R.string.medicineCancelStatus_canceled), EXPIRED( | ||
"유효기간만료", | ||
R.string.medicineCancelStatus_expired, | ||
), | ||
NORMAL("정상", R.string.medicineCancelStatus_normal); | ||
|
||
companion object { | ||
fun statusOf(status: String) = values().find { it.status == status } ?: throw IllegalArgumentException() | ||
} | ||
} | ||
|
||
interface MedicineCancelStatus { | ||
@get:StringRes val statusStringId: Int | ||
} | ||
|
||
data class Canceled(val cancelDate: DateTimeValue) : MedicineCancelStatus { | ||
override val statusStringId: Int = MedicineCancelStatusType.CANCELED.statusStringResId | ||
} | ||
|
||
class Expired(val cancelDate: DateTimeValue) : MedicineCancelStatus { | ||
override val statusStringId: Int = MedicineCancelStatusType.EXPIRED.statusStringResId | ||
} | ||
|
||
class Normal : MedicineCancelStatus { | ||
override val statusStringId: Int = MedicineCancelStatusType.NORMAL.statusStringResId | ||
} |
27 changes: 27 additions & 0 deletions
27
...android/mediproject/core/model/medicine/common/producttype/FilterMedicationProductType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.android.mediproject.core.model.medicine.common.producttype | ||
|
||
import androidx.annotation.StringRes | ||
import com.android.mediproject.core.model.R | ||
import com.android.mediproject.core.model.medicine.common.producttype.FilterMedicationProductType.ALL | ||
import com.android.mediproject.core.model.medicine.common.producttype.FilterMedicationProductType.GENERAL | ||
import com.android.mediproject.core.model.medicine.common.producttype.FilterMedicationProductType.SPECIALTY | ||
|
||
/** | ||
* 표시할 의약품 타입 | ||
* | ||
* @property SPECIALTY 전문의약품 | ||
* @property GENERAL 일반의약품 | ||
* @property ALL 전체 | ||
*/ | ||
enum class FilterMedicationProductType(val text: String, @StringRes val stringResId: Int) { | ||
ALL("", R.string.medicineProductType_all), SPECIALTY("전문", R.string.medicineProductType_specialty), GENERAL( | ||
"일반", | ||
R.string.medicineProductType_general, | ||
); | ||
|
||
companion object { | ||
|
||
fun FilterMedicationProductType.text() = text | ||
fun FilterMedicationProductType.stringResId() = stringResId | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...a/com/android/mediproject/core/model/medicine/common/producttype/MedicationProductType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.android.mediproject.core.model.medicine.common.producttype | ||
|
||
import androidx.annotation.StringRes | ||
import com.android.mediproject.core.model.R | ||
import com.android.mediproject.core.model.medicine.common.producttype.MedicationProductType.GENERAL | ||
import com.android.mediproject.core.model.medicine.common.producttype.MedicationProductType.SPECIALTY | ||
|
||
/** | ||
* 의약품 타입 | ||
* | ||
* @property SPECIALTY 전문의약품 | ||
* @property GENERAL 일반의약품 | ||
*/ | ||
enum class MedicationProductType(val description: String, @StringRes val stringResId: Int) { | ||
SPECIALTY("전문", R.string.medicineProductType_specialty), | ||
GENERAL("일반", R.string.medicineProductType_general); | ||
|
||
companion object { | ||
fun valueOf(description: String) = values().find { description.contains(it.name) } ?: throw IllegalArgumentException() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.