Skip to content

Commit b11ead1

Browse files
committed
fix: Fix tree template
1 parent 3b1e2ae commit b11ead1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

tpls/default/biz.go.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func (a *{{$name}}) Query(ctx context.Context, params schema.{{$name}}QueryParam
4343
}
4444
{{- if $treeTpl}}
4545
result.Data = result.Data.ToTree()
46+
sort.Sort(result.Data)
4647
{{- end}}
4748
return result, nil
4849
}

tpls/default/schema.go.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ func (a {{plural .Name}}) ToTree() {{plural .Name}} {
103103
var list {{plural .Name}}
104104
m := a.ToMap()
105105
for _, item := range a {
106-
if item.ParentPath == "" {
106+
if item.ParentID == "" {
107107
list = append(list, item)
108108
continue
109109
}
110-
if parent, ok := m[item.ParentPath]; ok {
110+
if parent, ok := m[item.ParentID]; ok {
111111
if parent.Children == nil {
112112
children := {{plural .Name}}{item}
113113
parent.Children = &children

0 commit comments

Comments
 (0)