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