-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add liquibase * add model with some hacks test * wip * update Backend * update backend * update timeformat in db * update build gradle * update file urls * Added basic database model * fix frontend + migrations * update readme * remove andrena plans Co-authored-by: Daniel Thoma <[email protected]>
- Loading branch information
1 parent
c1987c0
commit d6e7a74
Showing
135 changed files
with
1,983 additions
and
1,109 deletions.
There are no files selected for viewing
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
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
61 changes: 42 additions & 19 deletions
61
application/src/jvmMain/kotlin/replace/dto/BookableEntityDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,53 @@ | ||
package replace.dto | ||
|
||
import kotlinx.serialization.Serializable | ||
import org.bson.types.ObjectId | ||
import replace.model.BookableEntity | ||
import kotlin.reflect.KProperty1 | ||
|
||
@Serializable | ||
data class BookableEntityDto( | ||
override val id: String? = null, | ||
override val id: String, | ||
|
||
val name: String, | ||
|
||
val floorId: String, | ||
|
||
val parentId: String? = null, | ||
val type: BookableEntityTypeDto? = null | ||
) : Dto | ||
|
||
fun BookableEntity.toDto() = BookableEntityDto( | ||
id = id?.toHexString(), | ||
name = name, | ||
floorId = floorId.toHexString(), | ||
parentId = parentId?.toHexString(), | ||
type = type?.toDto() | ||
) | ||
|
||
fun BookableEntityDto.toModel() = | ||
BookableEntity( | ||
name, | ||
type?.toModel(), | ||
ObjectId(floorId), | ||
if (parentId != null) ObjectId(parentId) else null | ||
|
||
val typeId: String? = null, | ||
|
||
val floor: FloorDto? = null, | ||
val parent: BookableEntityDto? = null, | ||
val type: BookableEntityTypeDto? = null, | ||
) : ModelDto | ||
|
||
fun BookableEntity.toDto(with: List<KProperty1<BookableEntity, *>> = emptyList()): BookableEntityDto { | ||
val floor = if (with.contains(BookableEntity::floor)) { | ||
floor.toDto() | ||
} else { | ||
null | ||
} | ||
|
||
val parent = if (with.contains(BookableEntity::parent)) { | ||
parent?.toDto() | ||
} else { | ||
null | ||
} | ||
|
||
val type = if (with.contains(BookableEntity::type)) { | ||
type?.toDto() | ||
} else { | ||
null | ||
} | ||
|
||
return BookableEntityDto( | ||
id = id.value, | ||
name = name, | ||
floorId = floorId.value, | ||
parentId = parentId?.value, | ||
typeId = typeId?.value, | ||
floor = floor, | ||
parent = parent, | ||
type = type, | ||
) | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
package replace.dto | ||
|
||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.Serializable | ||
import org.bson.types.ObjectId | ||
import replace.model.Booking | ||
import kotlin.reflect.KProperty1 | ||
|
||
@Serializable | ||
data class BookingDto( | ||
override val id: String? = null, | ||
val bookedEntities: List<String>, | ||
val startDateTime: String, | ||
val endDateTime: String, | ||
) : Dto | ||
override val id: String, | ||
val userId: String, | ||
val user: UserDto? = null, | ||
val bookedEntities: List<BookableEntityDto>? = null, | ||
val start: String, | ||
val end: String | ||
) : ModelDto | ||
|
||
fun Booking.toDto() = BookingDto( | ||
id = id?.toHexString(), | ||
bookedEntities = bookedEntities.map { it.toHexString() }, | ||
startDateTime = startDateTime.toString(), | ||
endDateTime = endDateTime.toString(), | ||
) | ||
fun Booking.toDto(with: List<KProperty1<Booking, *>> = emptyList()): BookingDto { | ||
|
||
fun BookingDto.toModel() = Booking(bookedEntities.map { ObjectId(it) }, Instant.parse(startDateTime), Instant.parse(endDateTime)) | ||
val bookedEntities = if (with.contains(Booking::bookedEntities)) { | ||
bookedEntities.map { it.toDto() } | ||
} else { | ||
null | ||
} | ||
|
||
val user = if (with.contains(Booking::user)) { | ||
user.toDto() | ||
} else { | ||
null | ||
} | ||
|
||
return BookingDto( | ||
id = id.value, | ||
userId = userId.value, | ||
start = start.toString(), | ||
end = end.toString(), | ||
bookedEntities = bookedEntities, | ||
user = user, | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
application/src/jvmMain/kotlin/replace/dto/CreateBookableEntityDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package replace.dto | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class CreateBookableEntityDto( | ||
val name: String, | ||
|
||
val floorId: String, | ||
|
||
val parentId: String? = null, | ||
|
||
val typeId: String? = null, | ||
) |
6 changes: 3 additions & 3 deletions
6
...otlin/replace/model/BookableEntityType.kt → ...eplace/dto/CreateBookableEntityTypeDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package replace.model | ||
package replace.dto | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BookableEntityType( | ||
data class CreateBookableEntityTypeDto( | ||
val name: String, | ||
) : ObjectWithId() | ||
) |
10 changes: 10 additions & 0 deletions
10
application/src/jvmMain/kotlin/replace/dto/CreateBookingDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package replace.dto | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class CreateBookingDto( | ||
val bookedEntityIds: List<String>, | ||
val start: String, | ||
val end: String | ||
) |
10 changes: 10 additions & 0 deletions
10
application/src/jvmMain/kotlin/replace/dto/CreateFloorDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package replace.dto | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class CreateFloorDto( | ||
val name: String, | ||
val siteId: String, | ||
val planFile: FileUploadDto? = null, | ||
) |
6 changes: 3 additions & 3 deletions
6
.../src/jvmMain/kotlin/replace/model/Site.kt → ...mMain/kotlin/replace/dto/CreateSiteDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package replace.model | ||
package replace.dto | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Site( | ||
class CreateSiteDto( | ||
val name: String, | ||
) : ObjectWithId() | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package replace.dto | ||
|
||
interface Dto { | ||
val id: String? | ||
abstract class Dto { | ||
fun validate() {} | ||
} |
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
16 changes: 5 additions & 11 deletions
16
application/src/jvmMain/kotlin/replace/dto/FileUploadDto.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,31 @@ | ||
package replace.dto | ||
|
||
import kotlinx.serialization.Serializable | ||
import replace.datastore.FileRepository | ||
import replace.datastore.FileStorage | ||
import replace.datastore.TemporaryFileRepository | ||
import replace.usecase.temporaryfileupload.SaveTemporaryFileUploadPersistentUseCase | ||
|
||
@Serializable | ||
class FileUploadDto( | ||
override val id: String, | ||
data class FileUploadDto( | ||
val fileId: String, | ||
val temporary: Boolean, | ||
) : Dto | ||
) | ||
|
||
suspend fun FileUploadDto.save( | ||
temporaryFileRepository: TemporaryFileRepository, | ||
fileRepository: FileRepository, | ||
fileStorage: FileStorage, | ||
): FileUploadDto { | ||
if (!temporary) { | ||
return this | ||
} | ||
|
||
val file = SaveTemporaryFileUploadPersistentUseCase.execute( | ||
id, | ||
temporaryFileRepository, | ||
fileRepository, | ||
fileId, | ||
fileStorage, | ||
) | ||
|
||
checkNotNull(file.id) { "Could not save file" } | ||
|
||
return FileUploadDto( | ||
id = file.id, | ||
fileId = file.id, | ||
temporary = false, | ||
) | ||
} |
Oops, something went wrong.