Browse Source

代码生成树形菜单bug修复

yxh 4 years ago
parent
commit
28935880f9
2 changed files with 30 additions and 0 deletions
  1. 13 0
      template/vm/go/dao.template
  2. 17 0
      template/vm/go/service.template

+ 13 - 0
template/vm/go/dao.template

@@ -87,11 +87,24 @@ type {{$.table.ClassName}}{{$column.GoField}}Req struct {
 
 
 // {{.table.ClassName}}ListRes 列表返回结果
 // {{.table.ClassName}}ListRes 列表返回结果
 type {{.table.ClassName}}ListRes struct {
 type {{.table.ClassName}}ListRes struct {
+    {{if eq .table.TplCategory "tree"}}
+    {{range $index, $column := .table.Columns}}
+    {{if or (eq $column.HtmlField $.table.TreeCode) (eq $column.HtmlField $.table.TreeParentCode) (eq $column.HtmlField $.table.TreeName) }}
+    {{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}}   `json:"{{$column.HtmlField}}"`
+    {{end}}
+    {{end}}
+    {{range $index, $column := .table.Columns}}
+    {{if and (eq $column.IsList "1") (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }}
+    {{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}}   `json:"{{$column.HtmlField}}"`
+    {{end}}
+    {{end}}
+    {{else}}
     {{range $index, $column := .table.Columns}}
     {{range $index, $column := .table.Columns}}
     {{if eq $column.IsList "1" }}
     {{if eq $column.IsList "1" }}
     {{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}}   `json:"{{$column.HtmlField}}"`
     {{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else if eq $column.HtmlType "images" "file" "files"}}[]*comModel.UpFile{{else}}{{$column.GoType}}{{end}}   `json:"{{$column.HtmlField}}"`
     {{end}}
     {{end}}
     {{end}}
     {{end}}
+    {{end}}
 }
 }
 
 
 // {{.table.ClassName}}InfoRes 数据返回结果
 // {{.table.ClassName}}InfoRes 数据返回结果

+ 17 - 0
template/vm/go/service.template

@@ -132,6 +132,22 @@ func (s *{{$structName}}) GetList(req *dao.{{.table.ClassName}}SearchReq) (total
         {{end}}
         {{end}}
         {{end}}
         {{end}}
         list[k] = &dao.{{.table.ClassName}}ListRes{
         list[k] = &dao.{{.table.ClassName}}ListRes{
+            {{if eq .table.TplCategory "tree"}}
+            {{range $index, $column := .table.Columns}}
+            {{if or (eq $column.HtmlField $.table.TreeCode) (eq $column.HtmlField $.table.TreeParentCode) (eq $column.HtmlField $.table.TreeName) }}
+            {{$column.GoField}} : v.{{$column.GoField}},
+            {{end}}
+            {{end}}
+            {{range $index, $column := .table.Columns}}
+            {{if and (eq $column.IsList "1") (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }}
+            {{if eq $column.HtmlType "images" "file" "files"}}
+            {{$column.GoField}} : {{$column.HtmlField}},
+            {{else}}
+            {{$column.GoField}} : v.{{$column.GoField}},
+            {{end}}
+            {{end}}
+            {{end}}
+            {{else}}
             {{range $index, $column := .table.Columns}}
             {{range $index, $column := .table.Columns}}
             {{if eq $column.IsList "1"}}
             {{if eq $column.IsList "1"}}
             {{if eq $column.HtmlType "images" "file" "files"}}
             {{if eq $column.HtmlType "images" "file" "files"}}
@@ -141,6 +157,7 @@ func (s *{{$structName}}) GetList(req *dao.{{.table.ClassName}}SearchReq) (total
             {{end}}
             {{end}}
             {{end}}
             {{end}}
             {{end}}
             {{end}}
+            {{end}}
         }
         }
     }
     }
     return
     return