refactor: entferne toJavaInstant und passe DeviceRepository sowie verwandte Modelle an
Signed-off-by: StefanMoCoAt <stefan.mo.co@gmail.com>
This commit is contained in:
+3
-2
@@ -1,7 +1,7 @@
|
||||
package at.mocode.identity.domain.model
|
||||
|
||||
import kotlinx.datetime.Instant
|
||||
import java.util.*
|
||||
import kotlin.time.Instant
|
||||
|
||||
/**
|
||||
* Repräsentiert eine registrierte Desktop-Instanz ("Gerät").
|
||||
@@ -13,7 +13,8 @@ data class Device(
|
||||
val securityKeyHash: String, // Gehasht für Sicherheit
|
||||
val role: DeviceRole = DeviceRole.CLIENT,
|
||||
val lastSyncAt: Instant? = null,
|
||||
val createdAt: Instant
|
||||
val createdAt: Instant,
|
||||
val updatedAt: Instant = createdAt
|
||||
)
|
||||
|
||||
enum class DeviceRole {
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package at.mocode.identity.domain.repository
|
||||
|
||||
import at.mocode.identity.domain.model.Device
|
||||
import kotlinx.datetime.Instant
|
||||
import java.util.*
|
||||
import kotlin.time.Instant
|
||||
|
||||
interface DeviceRepository {
|
||||
suspend fun findById(id: UUID): Device?
|
||||
|
||||
+11
-12
@@ -11,7 +11,6 @@ import org.jetbrains.exposed.v1.jdbc.update
|
||||
import java.util.*
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
import kotlin.time.toJavaInstant
|
||||
|
||||
class ExposedDeviceRepository : DeviceRepository {
|
||||
|
||||
@@ -36,8 +35,8 @@ class ExposedDeviceRepository : DeviceRepository {
|
||||
it[name] = device.name
|
||||
it[securityKeyHash] = device.securityKeyHash
|
||||
it[role] = device.role
|
||||
it[lastSyncAt] = device.lastSyncAt?.toJavaInstant()
|
||||
it[updatedAt] = now.toJavaInstant()
|
||||
it[lastSyncAt] = device.lastSyncAt
|
||||
it[updatedAt] = now
|
||||
}
|
||||
} else {
|
||||
DeviceTable.insert {
|
||||
@@ -45,19 +44,18 @@ class ExposedDeviceRepository : DeviceRepository {
|
||||
it[name] = device.name
|
||||
it[securityKeyHash] = device.securityKeyHash
|
||||
it[role] = device.role
|
||||
it[lastSyncAt] = device.lastSyncAt?.toJavaInstant()
|
||||
it[createdAt] = now.toJavaInstant()
|
||||
it[updatedAt] = now.toJavaInstant()
|
||||
it[lastSyncAt] = device.lastSyncAt
|
||||
it[createdAt] = device.createdAt
|
||||
it[updatedAt] = now
|
||||
}
|
||||
}
|
||||
device
|
||||
device.copy(updatedAt = now)
|
||||
}
|
||||
|
||||
override suspend fun updateLastSyncAt(id: UUID, at: Instant): Boolean = transaction {
|
||||
val javaInstant = at.toJavaInstant()
|
||||
DeviceTable.update({ DeviceTable.id eq id }) {
|
||||
it[lastSyncAt] = javaInstant
|
||||
it[updatedAt] = javaInstant
|
||||
it[lastSyncAt] = at
|
||||
it[updatedAt] = at
|
||||
} > 0
|
||||
}
|
||||
|
||||
@@ -66,7 +64,8 @@ class ExposedDeviceRepository : DeviceRepository {
|
||||
name = row[DeviceTable.name],
|
||||
securityKeyHash = row[DeviceTable.securityKeyHash],
|
||||
role = row[DeviceTable.role],
|
||||
lastSyncAt = row[DeviceTable.lastSyncAt]?.let { Instant.fromEpochMilliseconds(it.toEpochMilli()) },
|
||||
createdAt = Instant.fromEpochMilliseconds(row[DeviceTable.createdAt].toEpochMilli())
|
||||
lastSyncAt = row[DeviceTable.lastSyncAt],
|
||||
createdAt = row[DeviceTable.createdAt],
|
||||
updatedAt = row[DeviceTable.updatedAt]
|
||||
)
|
||||
}
|
||||
|
||||
+4
-1
@@ -100,7 +100,10 @@ fun StammdatenTabContent(
|
||||
val katField = tClass.getDeclaredField("kategorie")
|
||||
katField.isAccessible = true
|
||||
val kats = katField.get(turnier) as? List<String>
|
||||
kats?.let { kat.addAll(it) }
|
||||
kats?.let {
|
||||
kat.clear()
|
||||
kat.addAll(it)
|
||||
}
|
||||
|
||||
val typField = tClass.getDeclaredField("typ")
|
||||
typField.isAccessible = true
|
||||
|
||||
Reference in New Issue
Block a user