Skip to content

Commit

Permalink
toDto methods should not be suspended
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstaeding committed Mar 17, 2023
1 parent d291c51 commit 54538b0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ data class BookableEntityDto(
val type: BookableEntityTypeDto? = null,
) : ModelDto

suspend fun BookableEntity.toDto(with: List<KProperty1<BookableEntity, *>> = emptyList()): BookableEntityDto {
fun BookableEntity.toDto(with: List<KProperty1<BookableEntity, *>> = emptyList()): BookableEntityDto {
val floor = if (with.contains(BookableEntity::floor)) {
floor.toDto()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class BookableEntityTypeDto(
val bookableEntities: List<BookableEntityDto>? = null,
) : ModelDto

suspend fun BookableEntityType.toDto(with: List<KProperty1<BookableEntityType, *>> = emptyList()): BookableEntityTypeDto {
fun BookableEntityType.toDto(with: List<KProperty1<BookableEntityType, *>> = emptyList()): BookableEntityTypeDto {
val bookableEntities = if (with.contains(BookableEntityType::bookableEntities)) {
bookableEntities.map { it.toDto() }
} else {
Expand Down
6 changes: 3 additions & 3 deletions application/src/jvmMain/kotlin/replace/dto/FloorDto.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package replace.dto

import kotlinx.serialization.Serializable
import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransaction
import org.jetbrains.exposed.sql.transactions.transaction
import replace.model.Floor
import kotlin.reflect.KProperty1

Expand All @@ -16,7 +16,7 @@ class FloorDto(
val bookableEntities: List<BookableEntityDto>? = null,
) : ModelDto

suspend fun Floor.toDto(with: List<KProperty1<Floor, *>> = emptyList()): FloorDto {
fun Floor.toDto(with: List<KProperty1<Floor, *>> = emptyList()): FloorDto {
val siteDto = if (with.contains(Floor::site)) {
site.toDto()
} else {
Expand All @@ -33,7 +33,7 @@ suspend fun Floor.toDto(with: List<KProperty1<Floor, *>> = emptyList()): FloorDt
id = id.value,
name = name,
siteId = siteId.value,
planFile = newSuspendedTransaction { planFile?.toDto() },
planFile = transaction { planFile?.toDto() },
site = siteDto,
bookableEntities = bookableEntities,
)
Expand Down
2 changes: 1 addition & 1 deletion application/src/jvmMain/kotlin/replace/dto/SiteDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SiteDto(
val floors: List<FloorDto>? = null,
) : ModelDto

suspend fun Site.toDto(with: List<KProperty1<Site, *>> = emptyList()): SiteDto {
fun Site.toDto(with: List<KProperty1<Site, *>> = emptyList()): SiteDto {
val floors = if (with.contains(Site::floors)) {
floors.map { it.toDto() }
} else {
Expand Down

0 comments on commit 54538b0

Please sign in to comment.