This commit is contained in:
movavi 2023-12-26 01:02:49 +04:00
parent 57821e0ec3
commit aea5353e4a
5 changed files with 18 additions and 28 deletions

View File

@ -6,7 +6,7 @@ import java.util.Base64
@Serializable
data class BouquetRemote(
val id: Int? = 0,
val id: Int? = null,
val name: String = "",
val quantityOfFlowers: Int = 0,
val price: Int = 0,
@ -22,7 +22,7 @@ fun BouquetRemote.toBouquet(): Bouquet = Bouquet(
)
fun Bouquet.toBouquetRemote(): BouquetRemote = BouquetRemote(
bouquetId,
null,
name,
quantityOfFlowers,
price,

View File

@ -1,22 +0,0 @@
package com.example.flowershopapp.API.Model
import com.example.flowershopapp.Entities.Model.OrdersWithBouquets
import kotlinx.serialization.Serializable
@Serializable
data class OrderBouquetRemote(
val order: OrderRemote = OrderRemote(),
val bouquet: List<BouquetRemote> = listOf()
)
fun OrderBouquetRemote.toOrdersWithBouquets(): OrdersWithBouquets {
val convertedOrder = this.order.toOrder()
val convertedBouquets = this.bouquet.map { it.toBouquet() }
return OrdersWithBouquets(convertedOrder, convertedBouquets)
}
fun OrdersWithBouquets.toOrderBouquetRemote(): OrderBouquetRemote {
val convertedOrder = this.order.toOrderRemote()
val convertedBouquets = this.bouquets.map { it.toBouquetRemote() }
return OrderBouquetRemote(convertedOrder, convertedBouquets)
}

View File

@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class OrderRemote(
val id: Int? = 0,
val id: Int? = null,
val date: String = "",
val sum: Int = 0,
val userId: Int = 0,
@ -19,7 +19,7 @@ fun OrderRemote.toOrder(): Order = Order(
)
fun Order.toOrderRemote(): OrderRemote = OrderRemote(
orderId,
null,
date,
sum,
userId

View File

@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
@Serializable
data class UserRemote(
val id: Int = 0,
val id: Int? = null,
val userName: String = "",
val dateOfBirth: String = "",
val phoneNumber: String = "",
@ -21,7 +21,7 @@ fun UserRemote.toUser(): User = User(
)
fun User.toUserRemote(): UserRemote = UserRemote(
userId ?: 0,
null,
userName,
dateOfBirth,
phoneNumber,

View File

@ -137,6 +137,12 @@
"date": "2023-12-25",
"sum": 1200,
"userId": 2
},
{
"date": "2023-12-25",
"sum": 2424,
"userId": 2,
"id": 5
}
],
"users": [
@ -212,6 +218,12 @@
"bouquetId": 1,
"count": 1,
"id": 6
},
{
"orderId": 5,
"bouquetId": 2,
"count": 1,
"id": 7
}
]
}