Created
April 18, 2024 13:20
-
-
Save MkhytarMkhoian/429582b825241ab3368d7a1137633f24 to your computer and use it in GitHub Desktop.
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
fun CategoryDTO.asDomain() = Category( | |
id = id, | |
image = image, | |
name = name, | |
children = children.asDomain(), | |
adsCount = adsCount, | |
feedType = feedType.asDomain(), | |
) | |
fun Category.asDTO() = CategoryDTO( | |
id = id, | |
image = image, | |
name = name, | |
children = children.asDTO(), | |
adsCount = adsCount, | |
feedType = feedType.asDTO(), | |
) | |
fun List<Category>.asDTO(): List<CategoryDTO> { | |
return map { it.asDTO() } | |
} | |
fun List<CategoryDTO>.asDomain(): List<Category> { | |
return map { it.asDomain() } | |
} | |
fun CategoryDTO.FeedType?.asDomain() = when (this) { | |
CategoryDTO.FeedType.MAP -> Category.FeedType.MAP | |
CategoryDTO.FeedType.DEFAULT -> Category.FeedType.DEFAULT | |
else -> Category.FeedType.DEFAULT | |
} | |
fun Category.FeedType.asDTO() = when (this) { | |
Category.FeedType.MAP -> CategoryDTO.FeedType.MAP | |
Category.FeedType.DEFAULT -> CategoryDTO.FeedType.DEFAULT | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment