From 836490cd40ae52cbf27c120a33cefbbf11139ecf Mon Sep 17 00:00:00 2001 From: qianmoQ Date: Fri, 14 Jun 2024 20:43:22 +0800 Subject: [PATCH] [Core] [File] Add csv file convert --- file/datacap-file-csv/pom.xml | 48 +++++++++++++++++++ .../io/edurt/datacap/file/csv/CsvFile.kt | 28 +++++++++++ .../io/edurt/datacap/file/csv/CsvModule.kt | 15 ++++++ .../services/io.edurt.datacap.file.FileModule | 1 + .../edurt/datacap/file/csv/CsvModuleTest.kt | 27 +++++++++++ pom.xml | 1 + 6 files changed, 120 insertions(+) create mode 100644 file/datacap-file-csv/pom.xml create mode 100644 file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvFile.kt create mode 100644 file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvModule.kt create mode 100644 file/datacap-file-csv/src/main/resources/META-INF/services/io.edurt.datacap.file.FileModule create mode 100644 file/datacap-file-csv/src/test/kotlin/io/edurt/datacap/file/csv/CsvModuleTest.kt diff --git a/file/datacap-file-csv/pom.xml b/file/datacap-file-csv/pom.xml new file mode 100644 index 00000000..a15f6a02 --- /dev/null +++ b/file/datacap-file-csv/pom.xml @@ -0,0 +1,48 @@ + + + + io.edurt.datacap + datacap + 2024.03.6-SNAPSHOT + ../../pom.xml + + 4.0.0 + + datacap-file-csv + DataCap - File for csv + + + + org.jetbrains.kotlin + kotlin-reflect + + + com.google.inject + guice + + + ch.qos.logback + logback-classic + + + io.edurt.datacap + datacap-file-spi + + + commons-io + commons-io + + + + + + + org.jetbrains.dokka + dokka-maven-plugin + + + + + diff --git a/file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvFile.kt b/file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvFile.kt new file mode 100644 index 00000000..5e443494 --- /dev/null +++ b/file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvFile.kt @@ -0,0 +1,28 @@ +package io.edurt.datacap.file.csv + +import io.edurt.datacap.file.File +import io.edurt.datacap.file.model.FileRequest +import io.edurt.datacap.file.model.FileResponse + +class CsvFile : File +{ + override fun format(request: FileRequest): FileResponse + { + TODO("Not yet implemented") + } + + override fun formatStream(request: FileRequest): FileResponse + { + TODO("Not yet implemented") + } + + override fun writer(request: FileRequest): FileResponse + { + TODO("Not yet implemented") + } + + override fun reader(request: FileRequest): FileResponse + { + TODO("Not yet implemented") + } +} diff --git a/file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvModule.kt b/file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvModule.kt new file mode 100644 index 00000000..8212789d --- /dev/null +++ b/file/datacap-file-csv/src/main/kotlin/io/edurt/datacap/file/csv/CsvModule.kt @@ -0,0 +1,15 @@ +package io.edurt.datacap.file.csv + +import com.google.inject.multibindings.Multibinder +import io.edurt.datacap.file.File +import io.edurt.datacap.file.FileModule + +class CsvModule : FileModule() +{ + override fun configure() + { + Multibinder.newSetBinder(this.binder(), File::class.java) + .addBinding() + .to(CsvFile::class.java) + } +} diff --git a/file/datacap-file-csv/src/main/resources/META-INF/services/io.edurt.datacap.file.FileModule b/file/datacap-file-csv/src/main/resources/META-INF/services/io.edurt.datacap.file.FileModule new file mode 100644 index 00000000..5ba21cbd --- /dev/null +++ b/file/datacap-file-csv/src/main/resources/META-INF/services/io.edurt.datacap.file.FileModule @@ -0,0 +1 @@ +io.edurt.datacap.file.csv.CsvModule diff --git a/file/datacap-file-csv/src/test/kotlin/io/edurt/datacap/file/csv/CsvModuleTest.kt b/file/datacap-file-csv/src/test/kotlin/io/edurt/datacap/file/csv/CsvModuleTest.kt new file mode 100644 index 00000000..1b4c9c7b --- /dev/null +++ b/file/datacap-file-csv/src/test/kotlin/io/edurt/datacap/file/csv/CsvModuleTest.kt @@ -0,0 +1,27 @@ +package io.edurt.datacap.file.csv + +import com.google.inject.Guice +import com.google.inject.Injector +import com.google.inject.Key +import com.google.inject.TypeLiteral +import io.edurt.datacap.file.File +import io.edurt.datacap.file.FileManager +import org.junit.Assert.assertEquals +import org.junit.Test + +class CsvModuleTest +{ + private val injector: Injector = Guice.createInjector(FileManager()) + + @Test + fun test() + { + injector.getInstance(Key.get(object : TypeLiteral>() + {})) + .stream() + .findFirst() + .ifPresent { + assertEquals("Csv", it.name()) + } + } +} diff --git a/pom.xml b/pom.xml index f1bd6ee7..564ea0de 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,7 @@ file/datacap-file-txt file/datacap-file-json file/datacap-file-none + file/datacap-file-csv datacap