diff --git a/src/main/kotlin/data/database/mapper.kt b/src/main/kotlin/data/database/mapper.kt index 7d3373c..be3d905 100644 --- a/src/main/kotlin/data/database/mapper.kt +++ b/src/main/kotlin/data/database/mapper.kt @@ -51,7 +51,15 @@ fun ResultRow.toOrderResponse(): OrderResponse { dateTime = this[OrderTable.orderDateTime], orderStatus = toOrderStatusResponse(), orderTotalSum = this[OrderTable.orderTotalSum], - orderSet = emptyList() + orderSet = emptyList(), + addressResponse = AddressResponse( + addressId = this[AddressTable.id], + entrance = this[AddressTable.entrance], + apartment = this[AddressTable.apartment], + floor = this[AddressTable.floor], + comment = this[AddressTable.comment], + address = this[AddressTable.address], + ) ) } fun ResultRow.toOrderStatusResponse(): OrderStatusResponse { diff --git a/src/main/kotlin/data/repository/OrderRepository.kt b/src/main/kotlin/data/repository/OrderRepository.kt index a4c2c37..9612ce2 100644 --- a/src/main/kotlin/data/repository/OrderRepository.kt +++ b/src/main/kotlin/data/repository/OrderRepository.kt @@ -34,7 +34,7 @@ class OrderRepository { return@dbQuery false } suspend fun getOrdersByUuid(userUUID: UUID): List = DatabaseSettings.dbQuery { - return@dbQuery (OrderTable innerJoin OrderStatusTable) + return@dbQuery (OrderTable innerJoin OrderStatusTable innerJoin AddressTable) .selectAll() .where { OrderTable.userUuid eq userUUID diff --git a/src/main/kotlin/data/repository/UserRepository.kt b/src/main/kotlin/data/repository/UserRepository.kt index 1e10b6e..30c887d 100644 --- a/src/main/kotlin/data/repository/UserRepository.kt +++ b/src/main/kotlin/data/repository/UserRepository.kt @@ -93,8 +93,5 @@ class UserRepository { ProfileTable.update({ ProfileTable.uuid eq uuid }) { it[ProfileTable.address] = address[AddressTable.id] } - if(user.hasValue(AddressTable.id)){ - AddressTable.deleteWhere { id eq user[id] } - } } } \ No newline at end of file diff --git a/src/main/kotlin/dto/response/OrderResponse.kt b/src/main/kotlin/dto/response/OrderResponse.kt index c6c4853..381f783 100644 --- a/src/main/kotlin/dto/response/OrderResponse.kt +++ b/src/main/kotlin/dto/response/OrderResponse.kt @@ -12,6 +12,7 @@ data class OrderResponse( @Serializable(with = UuidSerializer::class) val userUuid : UUID, val addressId: Long, + val addressResponse: AddressResponse, val dateTime: LocalDateTime, val orderStatus : OrderStatusResponse, @Serializable(with = BigDecimalSerializer::class)