Skip to content

Commit

Permalink
[FEATURE]#218 : 서버드리븐 Ui Component DTO Model 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Jan 30, 2025
1 parent bf97353 commit 66141a3
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.bff.wespot.data.remote.model.dynamicui

import com.bff.wespot.data.remote.model.dynamicui.component.DynamicUiComponentDto
import com.bff.wespot.data.remote.model.dynamicui.component.toDynamicUiComponent
import com.bff.wespot.model.dynamicui.FeatureOverview
import com.bff.wespot.model.dynamicui.component.ButtonComponent
import com.bff.wespot.model.dynamicui.component.ImageComponent
import com.bff.wespot.model.dynamicui.component.TextComponent
import kotlinx.serialization.Serializable

@Serializable
data class FeatureOverviewDto(
val id: Int,
val name: String,
val data: List<DynamicUiComponentDto>,
) {
fun toFeatureOverview(): FeatureOverview = FeatureOverview(
headerText = data[0].toDynamicUiComponent() as? TextComponent ?: TextComponent(),
overview = data[1].toDynamicUiComponent() as? ImageComponent ?: ImageComponent(),
dismissButton = data[2].toDynamicUiComponent() as? ButtonComponent ?: ButtonComponent(),
navigateButton = data[3].toDynamicUiComponent() as? ButtonComponent ?: ButtonComponent(),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.bff.wespot.data.remote.model.dynamicui.component

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
@SerialName("buttonComponent")
data class ButtonComponentDto(
val text: String,
val link: String = "",
): DynamicUiComponentDto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.bff.wespot.data.remote.model.dynamicui.component

import com.bff.wespot.model.dynamicui.component.ButtonComponent
import com.bff.wespot.model.dynamicui.component.DynamicUiComponent
import com.bff.wespot.model.dynamicui.component.ImageComponent
import com.bff.wespot.model.dynamicui.component.TextComponent
import kotlinx.serialization.Serializable

@Serializable
sealed interface DynamicUiComponentDto

fun DynamicUiComponentDto.toDynamicUiComponent(): DynamicUiComponent {
return when (this) {
is TextComponentDto -> TextComponent(text)
is ImageComponentDto -> ImageComponent(url, width, height)
is ButtonComponentDto -> ButtonComponent(text, link)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.bff.wespot.data.remote.model.dynamicui.component

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
@SerialName("imageComponent")
data class ImageComponentDto(
val url: String,
val width: Int,
val height: Int
): DynamicUiComponentDto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.bff.wespot.data.remote.model.dynamicui.component

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
@SerialName("textComponent")
data class TextComponentDto(
val text: String,
): DynamicUiComponentDto

0 comments on commit 66141a3

Please sign in to comment.