package com.example.data.database import com.example.data.database.tables.* import com.example.dto.response.* import org.jetbrains.exposed.v1.core.ResultRow fun ResultRow.toFurniture(): FurnitureResponse { return FurnitureResponse( id = this[FurnitureTable.id], name = this[FurnitureTable.name], description = this[FurnitureTable.description], category = toFurnitureCategory(), price = this[FurnitureTable.price], sale = this[FurnitureTable.sale], shopCategories = emptyList(), url = this[FurnitureTable.url], ) } fun ResultRow.toFurnitureCategory(): FurnitureCategoryResponse { return FurnitureCategoryResponse( this[FurnitureCategory.id], this[FurnitureCategory.name], ) } fun ResultRow.toShopCategory(): ShopCategoryResponse { return ShopCategoryResponse( this[ShopCategoryTable.id], this[ShopCategoryTable.name], ) } fun ResultRow.toAllShopCategoryResponse(): AllShopCategoryResponse { return AllShopCategoryResponse( this[ShopCategoryTable.id], this[ShopCategoryTable.name], furnitureList = emptyList() ) } fun ResultRow.toCartResponse(): CartResponse { return CartResponse( count = this[CartTable.count], furnitureResponse = toFurniture(), ) } fun ResultRow.toOrderResponse(): OrderResponse { return OrderResponse( id = this[OrderTable.orderId], userUuid = this[OrderTable.userUuid], addressId = this[OrderTable.userAddress], dateTime = this[OrderTable.orderDateTime], orderStatus = toOrderStatusResponse(), orderTotalSum = this[OrderTable.orderTotalSum], orderSet = emptyList() ) } fun ResultRow.toOrderStatusResponse(): OrderStatusResponse { return OrderStatusResponse( this[OrderStatusTable.id], this[OrderStatusTable.name], ) } fun ResultRow.toSaleResponse(): SaleResponse { return SaleResponse( this[SaleTable.id], this[SaleTable.name], this[SaleTable.url] ) } fun ResultRow.toOrderItemResponse(): OrderItemResponse { return OrderItemResponse( furnitureId = this[OrderSetTable.furnitureId], orderId = this[OrderSetTable.orderId], furniturePrice = this[OrderSetTable.furniturePrice], count = this[OrderSetTable.count], furnitureResponse = toFurniture(), ) }