aboutsummaryrefslogtreecommitdiff
path: root/kvision-server
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-server')
-rw-r--r--kvision-server/build.gradle1
-rw-r--r--kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt15
2 files changed, 16 insertions, 0 deletions
diff --git a/kvision-server/build.gradle b/kvision-server/build.gradle
index 8be34ecf..6d623b3d 100644
--- a/kvision-server/build.gradle
+++ b/kvision-server/build.gradle
@@ -15,6 +15,7 @@ dependencies {
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
compile "org.jooby:jooby-lang-kotlin"
compile "org.jooby:jooby-jackson"
+ compile "com.github.andrewoma.kwery:mapper:${kweryVersion}"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:${jacksonModuleKotlinVersion}"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
testCompile project(":kvision-common")
diff --git a/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt b/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt
index 1d174f88..ad4185d6 100644
--- a/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt
+++ b/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt
@@ -21,6 +21,11 @@
*/
package pl.treksoft.kvision.types
+import com.github.andrewoma.kwery.mapper.SimpleConverter
+import com.github.andrewoma.kwery.mapper.TableConfiguration
+import com.github.andrewoma.kwery.mapper.reifiedConverter
+import com.github.andrewoma.kwery.mapper.standardConverters
+import com.github.andrewoma.kwery.mapper.util.camelToLowerUnderscore
import java.text.SimpleDateFormat
import java.util.*
@@ -40,3 +45,13 @@ internal actual fun KDate.toStringF(format: String) =
SimpleDateFormat(format).format(this.toJava())
fun KDate.toJava(): java.util.Date = java.util.Date(this.time)
+
+object KDateConverter : SimpleConverter<KDate>(
+ { row, c -> KDate(row.date(c).time) },
+ { it.toJava() }
+)
+
+val kvTableConfig = TableConfiguration(
+ converters = standardConverters + reifiedConverter(KDateConverter),
+ namingConvention = camelToLowerUnderscore
+)