This commit is contained in:
parent
e4bcfab2af
commit
2ae6742cd5
@ -1,11 +1,11 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import kotlinx.datetime.LocalDate
|
import kotlinx.datetime.LocalDateTime
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ApiObject(
|
data class ApiObject(
|
||||||
val tag: String,
|
val tag: String,
|
||||||
val device_id: Int,
|
val device_id: Int,
|
||||||
val device_date: LocalDate
|
val device_date: LocalDateTime
|
||||||
)
|
)
|
@ -2,13 +2,13 @@ package database.dao
|
|||||||
|
|
||||||
import org.jetbrains.exposed.dao.id.IntIdTable
|
import org.jetbrains.exposed.dao.id.IntIdTable
|
||||||
import org.jetbrains.exposed.sql.*
|
import org.jetbrains.exposed.sql.*
|
||||||
import org.jetbrains.exposed.sql.`java-time`.date
|
import org.jetbrains.exposed.sql.`java-time`.datetime
|
||||||
import java.time.LocalDate
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
object SampleObjects : IntIdTable() {
|
object SampleObjects : IntIdTable() {
|
||||||
val tag: Column<String> = varchar("tag", 32)
|
val tag: Column<String> = varchar("tag", 32)
|
||||||
val timestamp: Column<LocalDate> = date("timestamp").default(LocalDate.now())
|
val timestamp: Column<LocalDateTime> = datetime("timestamp").default(LocalDateTime.now())
|
||||||
val device_id: Column<Int> = integer("device_id")
|
val device_id: Column<Int> = integer("device_id")
|
||||||
val device_date: Column<LocalDate> = date("device_date")
|
val device_date: Column<LocalDateTime> = datetime("device_date")
|
||||||
override val primaryKey = PrimaryKey(id, name = "PK_SampleObject_Id")
|
override val primaryKey = PrimaryKey(id, name = "PK_SampleObject_Id")
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ package database.service
|
|||||||
|
|
||||||
import database.model.SampleObject
|
import database.model.SampleObject
|
||||||
import api.ApiObject
|
import api.ApiObject
|
||||||
import kotlinx.datetime.toJavaLocalDate
|
import kotlinx.datetime.toJavaLocalDateTime
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
class SampleObjectService : ISampleObjectService {
|
class SampleObjectService : ISampleObjectService {
|
||||||
@ -11,7 +11,7 @@ class SampleObjectService : ISampleObjectService {
|
|||||||
transaction {
|
transaction {
|
||||||
SampleObject.new {
|
SampleObject.new {
|
||||||
tag = apiObject.tag
|
tag = apiObject.tag
|
||||||
device_date = apiObject.device_date.toJavaLocalDate()
|
device_date = apiObject.device_date.toJavaLocalDateTime()
|
||||||
device_id = apiObject.device_id
|
device_id = apiObject.device_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user