diff --git a/.gitignore b/.gitignore index d9ed4f5..e50723a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +### 예제 샘프 ### +examples/ +examples/spring-boot-kotlin/.idea/ + + + ### intellij ### *.iml .idea/ diff --git a/HELP.md b/HELP.md deleted file mode 100644 index 623f426..0000000 --- a/HELP.md +++ /dev/null @@ -1,27 +0,0 @@ -# Read Me First -The following was discovered as part of building this project: - -* The JVM level was changed from '22' to '21' as the Kotlin version does not support Java 22 yet. - -# Getting Started - -### Reference Documentation -For further reference, please consider the following sections: - -* [Official Gradle documentation](https://docs.gradle.org) -* [Spring Boot Gradle Plugin Reference Guide](https://docs.spring.io/spring-boot/3.3.2/gradle-plugin) -* [Create an OCI image](https://docs.spring.io/spring-boot/3.3.2/gradle-plugin/packaging-oci-image.html) -* [Spring Web](https://docs.spring.io/spring-boot/docs/3.3.2/reference/htmlsingle/index.html#web) - -### Guides -The following guides illustrate how to use some features concretely: - -* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/) -* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/) -* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/) - -### Additional Links -These additional references should also help you: - -* [Gradle Build Scans – insights for your project's build](https://scans.gradle.com#gradle) - diff --git a/examples/spring-boot-kotlin/build.gradle.kts b/examples/spring-boot-kotlin/build.gradle.kts index 33ad649..4dff5fd 100644 --- a/examples/spring-boot-kotlin/build.gradle.kts +++ b/examples/spring-boot-kotlin/build.gradle.kts @@ -13,12 +13,16 @@ java { languageVersion = JavaLanguageVersion.of(21) } } - repositories { - mavenCentral() + mavenCentral() + maven { url = uri("https://jitpack.io") } } dependencies { + // 오픈소스 프로젝트 추가 + // Add open-source project + implementation("com.github.hyunolike:json-csv-bridge:v0.0.3") + implementation("org.springframework.boot:spring-boot-starter-web") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("org.jetbrains.kotlin:kotlin-reflect") diff --git a/examples/spring-boot-kotlin/src/main/kotlin/com/example/SpringBootKotlinApplication.kt b/examples/spring-boot-kotlin/src/main/kotlin/com/example/SpringBootKotlinApplication.kt index 478cf7e..012cbb7 100644 --- a/examples/spring-boot-kotlin/src/main/kotlin/com/example/SpringBootKotlinApplication.kt +++ b/examples/spring-boot-kotlin/src/main/kotlin/com/example/SpringBootKotlinApplication.kt @@ -1,11 +1,38 @@ package com.example +import com.jsoncsvbridge.factory.DefaultCsvCreatorFactory +import org.springframework.boot.CommandLineRunner import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +import org.springframework.stereotype.Component +import java.io.File @SpringBootApplication class SpringBootKotlinApplication fun main(args: Array) { - runApplication(*args) + runApplication(*args) } + +@Component +class CsvCreatorRunner() : CommandLineRunner { + override fun run(vararg args: String) { + val outputDir = File("csv_output").apply { mkdirs() } + + // JSON to CSV + val jsonCreator = DefaultCsvCreatorFactory().createCsvCreator("json"); + val jsonOutputPath = outputDir.resolve("output_json.csv").absolutePath + + // JSON to CSV + val jsonInput = """ + [ + {"name": "Alice", "age": 30, "city": "New York"}, + {"name": "Bob", "age": 25, "city": "Los Angeles"}, + {"name": "Charlie", "age": 35, "city": "Chicago"} + ] + """ + + jsonCreator.createCsv(jsonInput, jsonOutputPath) + println("JSON to CSV conversion completed. File saved at: $jsonOutputPath") + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/jsoncsvbridge/factory/DefaultCsvCreatorFactory.kt b/src/main/kotlin/com/jsoncsvbridge/factory/DefaultCsvCreatorFactory.kt index 0fb0bc2..fc82202 100644 --- a/src/main/kotlin/com/jsoncsvbridge/factory/DefaultCsvCreatorFactory.kt +++ b/src/main/kotlin/com/jsoncsvbridge/factory/DefaultCsvCreatorFactory.kt @@ -20,4 +20,11 @@ class DefaultCsvCreatorFactory : CsvCreatorFactory { else -> throw IllegalArgumentException("Unknown type") } } + + companion object { + @JvmStatic + fun createCsvCreator(type: String): CsvCreator { + return DefaultCsvCreatorFactory().createCsvCreator(type) + } + } } \ No newline at end of file