Created
March 12, 2020 03:54
-
-
Save mike-neck/135fbd2188c39e4470b614082fb85376 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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