tag insert
列注释添加tag
This commit is contained in:
@@ -53,22 +53,13 @@ func GetModel() model.IModel {
|
||||
return &MySQLModel
|
||||
}
|
||||
|
||||
// FixElementNote 分析元素表注释
|
||||
func FixElementNote(em *model.ColumnsInfo, note string) {
|
||||
// FixElementTag 分析元素表注释
|
||||
func FixElementTag(em *model.ColumnsInfo, note string) {
|
||||
matches := noteRegex.FindStringSubmatch(note)
|
||||
if len(matches) < 2 {
|
||||
em.Notes = note
|
||||
return
|
||||
}
|
||||
em.Notes = note[len(matches[0]):]
|
||||
|
||||
list := strings.Split(matches[1], ";")
|
||||
for _, v := range list {
|
||||
tmp := strings.Split(v, ":")
|
||||
if len(tmp) == 2 {
|
||||
if strings.EqualFold(tmp[0], "default") { // 默认值
|
||||
em.Default = tmp[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
em.Gormt = matches[1]
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func (m *mysqlModel) getTableElement(orm *mysqldb.MySqlDB, tab string) (el []mod
|
||||
var tmp model.ColumnsInfo
|
||||
tmp.Name = v.Field
|
||||
tmp.Type = v.Type
|
||||
FixElementNote(&tmp, v.Desc)
|
||||
FixElementTag(&tmp, v.Desc) // 分析表注释
|
||||
|
||||
// keys
|
||||
if keylist, ok := KeyColumnMp[v.Field]; ok { // maybe have index or key
|
||||
|
||||
Reference in New Issue
Block a user