修复模版生成bug
关联表 新增字段选择
This commit is contained in:
1 parent
50464dc6e6
commit
21d217c42a
3 files changed
+32
-1
No files matched your search
@@ -141,6 +141,13 @@ func GenCodeV2(c *gin.Context) {
|
||||
tools2.HasError(err, "", -1)
|
||||
table.TableId = id
|
||||
tab, _ := table.Get()
|
||||
//for i := range tab.Columns {
|
||||
// if tab.Columns[i].IsInsert == "1" {
|
||||
// tab.Columns[i].IsInsert = "true"
|
||||
// continue
|
||||
// }
|
||||
// tab.Columns[i].IsInsert = "false"
|
||||
//}
|
||||
|
||||
if tab.IsActions == 1 {
|
||||
ActionsGen(tab)
|
||||
|
||||
@@ -160,8 +160,31 @@ func (e *SysTables) Update() (update SysTables, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
tableNames := make([]string, 0)
|
||||
for i := range e.Columns {
|
||||
if e.Columns[i].FkTableName != "" {
|
||||
tableNames = append(tableNames, e.Columns[i].FkTableName)
|
||||
}
|
||||
}
|
||||
|
||||
tables := make([]SysTables, 0)
|
||||
tableMap := make(map[string]*SysTables)
|
||||
if len(tableNames) > 0 {
|
||||
if err = orm.Eloquent.Table("sys_tables").Where("table_name in (?)", tableNames).Find(&tables).Error; err != nil {
|
||||
return
|
||||
}
|
||||
for i := range tables {
|
||||
tableMap[tables[i].TBName] = &tables[i]
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < len(e.Columns); i++ {
|
||||
if e.Columns[i].FkTableName != "" {
|
||||
t, ok := tableMap[e.Columns[i].FkTableName]
|
||||
if ok {
|
||||
e.Columns[i].FkTableNameClass = t.ClassName
|
||||
e.Columns[i].FkTableNamePackage = t.ModuleName
|
||||
} else {
|
||||
tableNameList := strings.Split(e.Columns[i].FkTableName, "_")
|
||||
e.Columns[i].FkTableNameClass = ""
|
||||
e.Columns[i].FkTableNamePackage = ""
|
||||
@@ -172,6 +195,7 @@ func (e *SysTables) Update() (update SysTables, err error) {
|
||||
e.Columns[i].FkTableNamePackage += strings.ToLower(strStart) + strings.ToLower(strEnd)
|
||||
}
|
||||
}
|
||||
}
|
||||
_, _ = e.Columns[i].Update()
|
||||
}
|
||||
return
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
{{ range .Columns }}
|
||||
{{- $x := .IsInsert -}}
|
||||
{{- if ($x) -}}
|
||||
{{- if (eq $x "1") -}}
|
||||
{{- if (.Pk) }}
|
||||
{{- else if eq .GoField "CreatedAt" -}}
|
||||
{{- else if eq .GoField "UpdatedAt" -}}
|
||||
|
||||
Reference in new issue
Block a user