Skip to content

Commit

Permalink
[CHORE]#75 : NotificationTypeDto 소거
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Aug 7, 2024
1 parent 838c498 commit ef95e4d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.bff.wespot.model.notification

enum class NotificationType {
IDLE,
MESSAGE,
MESSAGE_SENT,
MESSAGE_RECEIVED,
Expand All @@ -12,5 +13,6 @@ enum class NotificationType {
fun toDescription(): String = when (this) {
MESSAGE, MESSAGE_SENT, MESSAGE_RECEIVED -> "쪽지 알림"
VOTE, VOTE_RESULT, VOTE_RECEIVED -> "투표 알림"
IDLE -> ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.bff.wespot.data.remote.model.notification
import com.bff.wespot.data.remote.extensions.toISOLocalDateTime
import com.bff.wespot.data.remote.extensions.toLocalDateFromDashPattern
import com.bff.wespot.model.notification.Notification
import com.bff.wespot.model.notification.NotificationType
import kotlinx.serialization.Serializable
import java.time.LocalDateTime

Expand All @@ -14,7 +15,7 @@ data class NotificationListDto(
@Serializable
data class NotificationDto (
val id: Int,
val type: NotificationTypeDto,
val type: String,
val date: String,
val targetId: Int,
val content: String,
Expand All @@ -24,12 +25,24 @@ data class NotificationDto (
) {
fun toNotification(): Notification = Notification(
id = id,
type = type.toNotificationType(),
type = type.convertToNotificationType(),
date = date.toLocalDateFromDashPattern(),
targetId = targetId,
content = content,
isNew = isNew,
isEnable = isEnable,
createdAt = createdAt.toISOLocalDateTime() ?: LocalDateTime.MIN,
)

private fun String.convertToNotificationType(): NotificationType {
return when (this) {
MESSAGE.name -> NotificationType.MESSAGE
MESSAGE_SENT.name -> NotificationType.MESSAGE_SENT
MESSAGE_RECEIVED.name -> NotificationType.MESSAGE_RECEIVED
VOTE.name -> NotificationType.VOTE
VOTE_RESULT.name -> NotificationType.VOTE_RESULT
VOTE_RECEIVED.name -> NotificationType.VOTE_RECEIVED
else -> NotificationType.IDLE
}
}
}

This file was deleted.

0 comments on commit ef95e4d

Please sign in to comment.