增加数据库must设置
This commit is contained in:
parent
8cac1f5393
commit
2cf20e7206
@ -116,7 +116,7 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
|||||||
nowTables = db.Select("INFORMATION_SCHEMA.TABLES", "TABLE_NAME as name,TABLE_COMMENT as label", Map{"TABLE_SCHEMA": db.DBName})
|
nowTables = db.Select("INFORMATION_SCHEMA.TABLES", "TABLE_NAME as name,TABLE_COMMENT as label", Map{"TABLE_SCHEMA": db.DBName})
|
||||||
}
|
}
|
||||||
if db.Type == "sqlite" {
|
if db.Type == "sqlite" {
|
||||||
nowTables = db.Select("sqlite_sequence", "name")
|
nowTables = db.Select("sqlite_master", "name", Map{"type": "table"})
|
||||||
}
|
}
|
||||||
//idSlice=append(idSlice,nowTables)
|
//idSlice=append(idSlice,nowTables)
|
||||||
for _, v := range nowTables {
|
for _, v := range nowTables {
|
||||||
@ -158,7 +158,7 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
|||||||
|
|
||||||
tableInfo := make([]Map, 0)
|
tableInfo := make([]Map, 0)
|
||||||
if db.Type == "mysql" {
|
if db.Type == "mysql" {
|
||||||
tableInfo = db.Select("INFORMATION_SCHEMA.COLUMNS", "COLUMN_NAME AS name,COLUMN_TYPE AS type,COLUMN_COMMENT AS label", Map{"AND": Map{"TABLE_SCHEMA": db.DBName, "TABLE_NAME": v.GetString("name")}})
|
tableInfo = db.Select("INFORMATION_SCHEMA.COLUMNS", "COLUMN_NAME AS name,COLUMN_TYPE AS type,COLUMN_COMMENT AS label,IS_NULLABLE AS must,COLUMN_DEFAULT AS dflt_value", Map{"AND": Map{"TABLE_SCHEMA": db.DBName, "TABLE_NAME": v.GetString("name")}})
|
||||||
}
|
}
|
||||||
if db.Type == "sqlite" {
|
if db.Type == "sqlite" {
|
||||||
tableInfo = db.Query("pragma table_info([" + v.GetString("name") + "]);")
|
tableInfo = db.Query("pragma table_info([" + v.GetString("name") + "]);")
|
||||||
@ -189,6 +189,18 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
|||||||
//"must": false,
|
//"must": false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if info.GetString("must") == "NO" {
|
||||||
|
coloum["must"] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if info["dflt_value"] != nil {
|
||||||
|
coloum["default"] = info["dflt_value"]
|
||||||
|
}
|
||||||
|
|
||||||
|
if info["pk"] != nil && info.GetCeilInt64("pk") == 1 {
|
||||||
|
coloum["must"] = true
|
||||||
|
}
|
||||||
|
|
||||||
//备注以空格隔开,空格后的是其他备注
|
//备注以空格隔开,空格后的是其他备注
|
||||||
indexNum := strings.Index(info.GetString("label"), " ")
|
indexNum := strings.Index(info.GetString("label"), " ")
|
||||||
if indexNum > -1 {
|
if indexNum > -1 {
|
||||||
@ -219,7 +231,15 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
|||||||
coloum["edit"] = ColumnName.GetBool("edit")
|
coloum["edit"] = ColumnName.GetBool("edit")
|
||||||
coloum["add"] = ColumnName["add"]
|
coloum["add"] = ColumnName["add"]
|
||||||
coloum["list"] = ColumnName.GetBool("list")
|
coloum["list"] = ColumnName.GetBool("list")
|
||||||
|
//coloum["must"] = ColumnName.GetBool("must")
|
||||||
|
|
||||||
|
if coloum["must"] == nil {
|
||||||
coloum["must"] = ColumnName.GetBool("must")
|
coloum["must"] = ColumnName.GetBool("must")
|
||||||
|
} else {
|
||||||
|
if ColumnName["must"] != nil {
|
||||||
|
coloum["must"] = ColumnName.GetBool("must")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ColumnName.GetBool("info") {
|
if ColumnName.GetBool("info") {
|
||||||
delete(coloum, "info")
|
delete(coloum, "info")
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user