fix 代码生成logic列表导包修复
This commit is contained in:
parent
e3ead51caa
commit
ac095cb4e5
@ -425,7 +425,7 @@ func (s *sToolsGenTable) SaveEdit(ctx context.Context, req *system.ToolsGenTable
|
|||||||
if tc, e := options["treeParentCode"]; options != nil && e && tc != "" && tc == dbColumn.HtmlField {
|
if tc, e := options["treeParentCode"]; options != nil && e && tc != "" && tc == dbColumn.HtmlField {
|
||||||
dbColumn.IsQuery = false
|
dbColumn.IsQuery = false
|
||||||
dbColumn.IsList = false
|
dbColumn.IsList = false
|
||||||
dbColumn.HtmlType = "select"
|
dbColumn.HtmlType = "treeSelect"
|
||||||
}
|
}
|
||||||
//获取字段关联表信息
|
//获取字段关联表信息
|
||||||
if column.LinkLabelName != "" {
|
if column.LinkLabelName != "" {
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
package logic
|
package logic
|
||||||
////
|
////
|
||||||
{{$gjson:=false}}
|
{{$gjson:=false}}
|
||||||
|
{{$libUtils:=false}}
|
||||||
{{$usedSystemModule:=false}}
|
{{$usedSystemModule:=false}}
|
||||||
{{$gstr:=false}}
|
{{$gstr:=false}}
|
||||||
{{range $index, $column := .table.Columns}}
|
{{range $index, $column := .table.Columns}}
|
||||||
{{if and $column.IsList (eq $column.HtmlType "images" "file" "files")}}
|
{{if eq $column.HtmlType "images" "file" "files"}}
|
||||||
{{$gjson = true}}
|
{{$libUtils = true}}
|
||||||
{{$gstr = true}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if and (eq $column.HtmlField "createdBy" "updatedBy" "deletedBy") (ne $.table.ModuleName "system")}}
|
{{if and (eq $column.HtmlField "createdBy" "updatedBy" "deletedBy") (ne $.table.ModuleName "system")}}
|
||||||
{{$usedSystemModule = true}}
|
{{$usedSystemModule = true}}
|
||||||
@ -35,9 +35,6 @@ package logic
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
{{if $gjson}}
|
|
||||||
"github.com/gogf/gf/v2/encoding/gjson"
|
|
||||||
{{end}}
|
|
||||||
{{if $gstr}}
|
{{if $gstr}}
|
||||||
"github.com/gogf/gf/v2/text/gstr"
|
"github.com/gogf/gf/v2/text/gstr"
|
||||||
{{end}}
|
{{end}}
|
||||||
@ -54,7 +51,7 @@ import (
|
|||||||
{{if $usedSystemModule}}
|
{{if $usedSystemModule}}
|
||||||
systemService "{{.goModName}}/internal/app/system/service"
|
systemService "{{.goModName}}/internal/app/system/service"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if or (eq .table.TplCategory "tree") $gjson}}
|
{{if or (eq .table.TplCategory "tree") $libUtils}}
|
||||||
"{{.goModName}}/library/libUtils"
|
"{{.goModName}}/library/libUtils"
|
||||||
{{end}}
|
{{end}}
|
||||||
"{{.goModName}}/library/liberr"
|
"{{.goModName}}/library/liberr"
|
||||||
@ -171,11 +168,7 @@ func (s *s{{.table.ClassName}})List(ctx context.Context, req *model.{{.table.Cla
|
|||||||
listRes.List = make([]*model.{{.table.ClassName}}ListRes,len(res))
|
listRes.List = make([]*model.{{.table.ClassName}}ListRes,len(res))
|
||||||
for k,v:=range res{
|
for k,v:=range res{
|
||||||
{{range $index, $column := .table.Columns}}
|
{{range $index, $column := .table.Columns}}
|
||||||
{{if and $column.IsList (eq $column.HtmlType "images" "file" "files")}}
|
{{if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}
|
||||||
{{$column.HtmlField}}:= ([]*comModel.UpFile)(nil)
|
|
||||||
err = gjson.DecodeTo(v.{{$column.GoField}},&{{$column.HtmlField}})
|
|
||||||
liberr.ErrIsNil(ctx,err)
|
|
||||||
{{else if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}
|
|
||||||
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
||||||
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
||||||
err = g.Model("{{$linkedTable.TableName}}").
|
err = g.Model("{{$linkedTable.TableName}}").
|
||||||
@ -203,7 +196,7 @@ func (s *s{{.table.ClassName}})List(ctx context.Context, req *model.{{.table.Cla
|
|||||||
{{range $index, $column := .table.Columns}}
|
{{range $index, $column := .table.Columns}}
|
||||||
{{if and $column.IsList (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }}
|
{{if and $column.IsList (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }}
|
||||||
{{if eq $column.HtmlType "images" "file" "files"}}
|
{{if eq $column.HtmlType "images" "file" "files"}}
|
||||||
{{$column.GoField}} : {{$column.HtmlField}},
|
{{$column.GoField}} : v.{{$column.GoField}},
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$column.GoField}} : v.{{$column.GoField}},
|
{{$column.GoField}} : v.{{$column.GoField}},
|
||||||
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
||||||
@ -226,7 +219,7 @@ func (s *s{{.table.ClassName}})List(ctx context.Context, req *model.{{.table.Cla
|
|||||||
UpdatedUser:v.UpdatedUser,
|
UpdatedUser:v.UpdatedUser,
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if eq $column.HtmlType "images" "file" "files"}}
|
{{if eq $column.HtmlType "images" "file" "files"}}
|
||||||
{{$column.GoField}} : {{$column.HtmlField}},
|
{{$column.GoField}} : v.{{$column.GoField}},
|
||||||
{{else}}
|
{{else}}
|
||||||
{{$column.GoField}} : v.{{$column.GoField}},
|
{{$column.GoField}} : v.{{$column.GoField}},
|
||||||
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
||||||
|
@ -88,12 +88,12 @@ type {{.table.ClassName}}ListRes struct{
|
|||||||
{{if eq .table.TplCategory "tree"}}
|
{{if eq .table.TplCategory "tree"}}
|
||||||
{{range $index, $column := .table.Columns}}
|
{{range $index, $column := .table.Columns}}
|
||||||
{{if or (eq $column.HtmlField $.table.TreeCode) (eq $column.HtmlField $.table.TreeParentCode) (eq $column.HtmlField $.table.TreeName) }}
|
{{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}}" dc:"{{$column.ColumnComment}}"`
|
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}" dc:"{{$column.ColumnComment}}"`
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{range $index, $column := .table.Columns}}
|
{{range $index, $column := .table.Columns}}
|
||||||
{{if and $column.IsList (ne $column.HtmlField $.table.TreeCode) (ne $column.HtmlField $.table.TreeParentCode) (ne $column.HtmlField $.table.TreeName) }}
|
{{if and $column.IsList (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}}" dc:"{{$column.ColumnComment}}"`
|
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}" dc:"{{$column.ColumnComment}}"`
|
||||||
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
||||||
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
||||||
Linked{{$column.GoField}} {{if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}[]{{end}}*Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `{{if not (eq $column.HtmlType "selects" "checkbox" "treeSelects")}}orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" {{end}}json:"linked{{$column.GoField}}" dc:"{{$column.ColumnComment}}"`
|
Linked{{$column.GoField}} {{if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}[]{{end}}*Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `{{if not (eq $column.HtmlType "selects" "checkbox" "treeSelects")}}orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" {{end}}json:"linked{{$column.GoField}}" dc:"{{$column.ColumnComment}}"`
|
||||||
@ -118,7 +118,7 @@ type {{.table.ClassName}}ListRes struct{
|
|||||||
{{if eq $column.HtmlField "updatedBy"}}
|
{{if eq $column.HtmlField "updatedBy"}}
|
||||||
UpdatedUser *{{if $hasUser}}systemModel.{{end}}LinkUserRes `orm:"with:id=updated_by" json:"updatedBy"`
|
UpdatedUser *{{if $hasUser}}systemModel.{{end}}LinkUserRes `orm:"with:id=updated_by" json:"updatedBy"`
|
||||||
{{end}}
|
{{end}}
|
||||||
{{$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}}" dc:"{{$column.ColumnComment}}"`
|
{{$column.GoField}} {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `json:"{{$column.HtmlField}}" dc:"{{$column.ColumnComment}}"`
|
||||||
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
||||||
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
||||||
Linked{{$column.GoField}} {{if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}[]{{end}}*Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `{{if not (eq $column.HtmlType "selects" "checkbox" "treeSelects")}}orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" {{end}}json:"linked{{$column.GoField}}" dc:"{{$column.ColumnComment}}"`
|
Linked{{$column.GoField}} {{if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}[]{{end}}*Linked{{$.table.ClassName}}{{$linkedTable.ClassName}} `{{if not (eq $column.HtmlType "selects" "checkbox" "treeSelects")}}orm:"with:{{$column.LinkLabelId}}={{$column.ColumnName}}" {{end}}json:"linked{{$column.GoField}}" dc:"{{$column.ColumnComment}}"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user