Skip to content

Instantly share code, notes, and snippets.

@mike-neck
Created March 12, 2020 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-neck/135fbd2188c39e4470b614082fb85376 to your computer and use it in GitHub Desktop.
Save mike-neck/135fbd2188c39e4470b614082fb85376 to your computer and use it in GitHub Desktop.
package com.example.diagram
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConstructorBinding
import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.runApplication
@EnableConfigurationProperties(Erd::class)
@SpringBootApplication
class DiagramApplication
fun main(args: Array<String>) {
runApplication<DiagramApplication>(*args)
}
@ConfigurationProperties("er")
@ConstructorBinding
data class Erd(
val diagram: Map<String, TableDef>,
val relations: Set<Relation>
)
@ConstructorBinding
data class TableDef(
val columns: List<Column>
)
@ConstructorBinding
data class Column(
val name: String,
val type: ColumnType,
val size: Int? = null,
val num: Int? = null,
val dec: Int? = null,
val primaryKey: Boolean,
val unique: Boolean,
val notNull: Boolean
)
enum class ColumnType {
INT,
DECIMAL,
VARCHAR,
DATE,
TIME,
TIMESTAMP
}
@ConstructorBinding
data class Relation(
val from: String,
val references: List<Reference>
)
@ConstructorBinding
data class Reference(
val from: String,
val to: String
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment