tag insert

列注释添加tag
This commit is contained in:
xxj
2020-12-07 19:06:12 +08:00
parent e9ecd38609
commit a97443b09f
10 changed files with 18 additions and 34 deletions

View File

@@ -53,22 +53,13 @@ func GetModel() model.IModel {
return &SQLiteModel
}
// 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]
}

View File

@@ -147,7 +147,7 @@ func (m *sqliteModel) getTableElement(orm *gorm.DB, tab string) (el []model.Colu
var tmp model.ColumnsInfo
tmp.Name = v.Name
tmp.Type = v.Type
FixElementNote(&tmp, "")
FixElementTag(&tmp, "")
if v.Pk == 1 { // 主键
tmp.Index = append(tmp.Index, model.KList{
Key: model.ColumnsKeyPrimary,