fix tag for v2
This commit is contained in:
@@ -214,9 +214,8 @@ func enterSet(g *gocui.Gui, v *gocui.View) error {
|
|||||||
AddValidate("required input", requireValidator)
|
AddValidate("required input", requireValidator)
|
||||||
form.AddInputField("db_name", SLocalize("db_name"), formPart[0], formPart[1]).SetText(config.GetDbInfo().Database).
|
form.AddInputField("db_name", SLocalize("db_name"), formPart[0], formPart[1]).SetText(config.GetDbInfo().Database).
|
||||||
AddValidate("required input", requireValidator)
|
AddValidate("required input", requireValidator)
|
||||||
form.AddInputField("db_type", SLocalize("db_type"), formPart[0], formPart[1]).SetText(tools.AsString(config.GetDbInfo().Type)).
|
form.AddSelect("db_type", SLocalize("db_type"), formPart[0], formPart[2]).AddOptions(getDBTypeList()...).
|
||||||
AddValidate("required input", requireValidator)
|
SetSelected(GetDBTypeStr(config.GetDbInfo().Type))
|
||||||
|
|
||||||
// add select
|
// add select
|
||||||
form.AddSelect("is_dev", SLocalize("is_dev"), formPart[0], formPart[2]).
|
form.AddSelect("is_dev", SLocalize("is_dev"), formPart[0], formPart[2]).
|
||||||
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsDev())))
|
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsDev())))
|
||||||
@@ -288,9 +287,11 @@ func buttonSave(g *gocui.Gui, v *gocui.View) error {
|
|||||||
dbInfo.Username = mp["db_usename"]
|
dbInfo.Username = mp["db_usename"]
|
||||||
dbInfo.Password = mp["db_pwd"]
|
dbInfo.Password = mp["db_pwd"]
|
||||||
dbInfo.Database = mp["db_name"]
|
dbInfo.Database = mp["db_name"]
|
||||||
|
|
||||||
config.SetMysqlDbInfo(&dbInfo)
|
|
||||||
mp = form.GetSelectedOpts()
|
mp = form.GetSelectedOpts()
|
||||||
|
|
||||||
|
dbInfo.Type = GetDBTypeID(mp["db_type"])
|
||||||
|
config.SetMysqlDbInfo(&dbInfo)
|
||||||
|
|
||||||
config.SetIsDev(getBool(mp["is_dev"]))
|
config.SetIsDev(getBool(mp["is_dev"]))
|
||||||
config.SetSimple(getBool(mp["is_simple"]))
|
config.SetSimple(getBool(mp["is_simple"]))
|
||||||
config.SetSingularTable(getBool(mp["is_singular"]))
|
config.SetSingularTable(getBool(mp["is_singular"]))
|
||||||
@@ -411,3 +412,35 @@ func OnInitDialog() {
|
|||||||
log.Panicln(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetDBTypeStr 0:mysql , 1:sqlite , 2:mssql
|
||||||
|
func GetDBTypeStr(tp int) string {
|
||||||
|
switch tp {
|
||||||
|
case 0:
|
||||||
|
return "mysql"
|
||||||
|
case 1:
|
||||||
|
return "sqlite"
|
||||||
|
case 2:
|
||||||
|
return "mssql"
|
||||||
|
}
|
||||||
|
// default
|
||||||
|
return "mysql"
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDBTypeID 0:mysql , 1:sqlite , 2:mssql
|
||||||
|
func GetDBTypeID(name string) int {
|
||||||
|
switch name {
|
||||||
|
case "mysql":
|
||||||
|
return 0
|
||||||
|
case "sqlite":
|
||||||
|
return 1
|
||||||
|
case "mssql":
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
// default
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDBTypeList() []string {
|
||||||
|
return []string{"mysql", "sqlite", "mssql"}
|
||||||
|
}
|
||||||
|
|||||||
@@ -86,14 +86,14 @@ func (m *_Model) genTableElement(cols []ColumnsInfo) (el []genstruct.GenElement)
|
|||||||
switch v1.Key {
|
switch v1.Key {
|
||||||
// case ColumnsKeyDefault:
|
// case ColumnsKeyDefault:
|
||||||
case ColumnsKeyPrimary: // primary key.主键
|
case ColumnsKeyPrimary: // primary key.主键
|
||||||
tmp.AddTag(_tagGorm, "primary_key")
|
tmp.AddTag(_tagGorm, "primaryKey")
|
||||||
isPK = true
|
isPK = true
|
||||||
case ColumnsKeyUnique: // unique key.唯一索引
|
case ColumnsKeyUnique: // unique key.唯一索引
|
||||||
tmp.AddTag(_tagGorm, "unique")
|
tmp.AddTag(_tagGorm, "unique")
|
||||||
case ColumnsKeyIndex: // index key.复合索引
|
case ColumnsKeyIndex: // index key.复合索引
|
||||||
tmp.AddTag(_tagGorm, getUninStr("index", ":", v1.KeyName))
|
tmp.AddTag(_tagGorm, getUninStr("index", ":", v1.KeyName))
|
||||||
case ColumnsKeyUniqueIndex: // unique index key.唯一复合索引
|
case ColumnsKeyUniqueIndex: // unique index key.唯一复合索引
|
||||||
tmp.AddTag(_tagGorm, getUninStr("unique_index", ":", v1.KeyName))
|
tmp.AddTag(_tagGorm, getUninStr("uniqueIndex", ":", v1.KeyName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,8 +154,8 @@ func (m *_Model) genForeignKey(col ColumnsInfo) (fklist []genstruct.GenElement)
|
|||||||
tmp.SetType(getCamelName(v.TableName))
|
tmp.SetType(getCamelName(v.TableName))
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp.AddTag(_tagGorm, "association_foreignkey:"+col.Name)
|
tmp.AddTag(_tagGorm, "joinForeignKey:"+col.Name) // association_foreignkey
|
||||||
tmp.AddTag(_tagGorm, "foreignkey:"+v.ColumnName)
|
tmp.AddTag(_tagGorm, "foreignKey:"+v.ColumnName)
|
||||||
|
|
||||||
// json tag
|
// json tag
|
||||||
if config.GetIsWEBTag() {
|
if config.GetIsWEBTag() {
|
||||||
|
|||||||
Reference in New Issue
Block a user