From d22b5e2fb7143e169c39ccfe0fb3f8349e5e5df7 Mon Sep 17 00:00:00 2001 From: yxh Date: Wed, 22 Jan 2025 11:06:30 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96=EF=BC=8C=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E9=AA=8C=E8=AF=81=E5=99=A8=E6=9C=AA=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 1 + resource/template/vm/go/controller.template | 2 +- resource/template/vm/go/logic.template | 12 +++++++----- resource/template/vm/vue/edit-vue.template | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index efca6d7..8b55f2c 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( _ "github.com/tiger1103/gfast/v3/internal/app/boot" _ "github.com/tiger1103/gfast/v3/internal/app/system/packed" "github.com/tiger1103/gfast/v3/internal/cmd" + _ "github.com/tiger1103/gfast/v3/library/libValidate" _ "github.com/tiger1103/gfast/v3/task" ) diff --git a/resource/template/vm/go/controller.template b/resource/template/vm/go/controller.template index 83b96df..a180842 100644 --- a/resource/template/vm/go/controller.template +++ b/resource/template/vm/go/controller.template @@ -262,7 +262,7 @@ func (c *{{$structName}}Controller) Export(ctx context.Context, req *{{.table.Mo {{else if eq $column.HtmlType "deptSelectorSingle"}} //{{$column.ColumnComment}} {{$column.HtmlField}}Str := "" - {{$column.HtmlField}}Obj := systemService.SysDept().GetByDept(ctx, v.DepartId) + {{$column.HtmlField}}Obj := systemService.SysDept().GetByDept(ctx, v.{{$column.GoField}}) if {{$column.HtmlField}}Obj != nil { {{$column.HtmlField}}Str = {{$column.HtmlField}}Obj.DeptName } diff --git a/resource/template/vm/go/logic.template b/resource/template/vm/go/logic.template index 4e0b0af..598d78c 100644 --- a/resource/template/vm/go/logic.template +++ b/resource/template/vm/go/logic.template @@ -19,6 +19,7 @@ package {{$structName}} {{$hasLinkTable:=false}} {{$useCommonService:=false}} {{$hasDeptSelector:=false}} +{{$hasUserMultipleSelector:=false}} {{$usedSystemModel := false}} {{range $index, $column := .table.Columns}} {{if eq $column.HtmlType "images" "file" "files" "imageSelector" "fileSelector"}} @@ -27,6 +28,9 @@ package {{$structName}} {{if eq $column.HtmlType "deptSelectorMultiple" "deptSelectorSingle"}} {{$hasDeptSelector = true}} {{end}} +{{if eq $column.HtmlType "userSelectorMultiple"}} + {{$hasUserMultipleSelector = true}} +{{end}} {{if and (or (eq $column.HtmlField "createdBy" "updatedBy" "deletedBy" "deptId") (eq $column.HtmlType "userSelectorSingle" "userSelectorMultiple" "deptSelectorMultiple" "deptSelectorSingle")) (ne $.table.ModuleName "system")}} {{$usedSystemModule = true}} {{end}} @@ -206,12 +210,12 @@ func (s *s{{.table.ClassName}})List(ctx context.Context, req *model.{{.table.Cla listRes.List = make([]*model.{{.table.ClassName}}ListRes,len(res)) for k,v:=range res{ {{range $index, $column := .table.Columns}} - {{if eq $column.HtmlType "userSelectorMultiple"}} + {{if and $column.IsList (eq $column.HtmlType "userSelectorMultiple")}} var linked{{$column.GoField}} []*{{if $usedSystemModel}}systemModel{{else}}model{{end}}.SysUserSimpleRes linked{{$column.GoField}}, err = {{if $usedSystemModule}}systemService{{else}}service{{end}}.SysUser().GetUsers(ctx, gconv.Interfaces(v.{{$column.GoField}})) liberr.ErrIsNil(ctx, err) {{end}} - {{if eq $column.HtmlType "deptSelectorMultiple"}} + {{if and $column.IsList (eq $column.HtmlType "deptSelectorMultiple")}} linked{{$column.GoField}} := make([]*{{if $usedSystemModel}}systemModel{{else}}model{{end}}.LinkDeptRes, len(v.{{$column.GoField}})) for lk, lv := range v.{{$column.GoField}} { linked{{$column.GoField}}[lk] = {{if $usedSystemModule}}systemService{{else}}service{{end}}.SysDept().GetByDept(ctx, lv) @@ -508,7 +512,7 @@ func (s *s{{.table.ClassName}})GetBy{{$pkGoField}}(ctx context.Context, {{$.tabl err =g.Try(ctx, func(ctx context.Context){ err = dao.{{.table.ClassName}}.Ctx(ctx).WithAll().Where(dao.{{.table.ClassName}}.Columns().{{$pkGoField}}, {{$.table.PkColumn.HtmlField}}).Scan(&res) liberr.ErrIsNil(ctx,err,"获取信息失败") - {{if or $.table.HasDeptId $hasDeptSelector}} + {{if or $.table.HasDeptId $hasDeptSelector $hasUserMultipleSelector}} if res!=nil{ {{if $.table.HasDeptId}} {{if $usedSystemModule}} @@ -517,7 +521,6 @@ func (s *s{{.table.ClassName}})GetBy{{$pkGoField}}(ctx context.Context, {{$.tabl res.DeptInfo = service.SysDept().GetByDept(ctx, res.DeptId) {{end}} {{end}} - {{if $hasDeptSelector}} {{range $index, $column := .table.Columns}} {{if eq $column.HtmlType "userSelectorMultiple"}} res.Linked{{$column.GoField}}, err = {{if $usedSystemModule}}systemService{{else}}service{{end}}.SysUser().GetUsers(ctx, gconv.Interfaces(res.{{$column.GoField}})) @@ -531,7 +534,6 @@ func (s *s{{.table.ClassName}})GetBy{{$pkGoField}}(ctx context.Context, {{$.tabl } {{end}} {{end}} - {{end}} } {{end}} {{range $index, $column := .table.Columns}} diff --git a/resource/template/vm/vue/edit-vue.template b/resource/template/vm/vue/edit-vue.template index 037e64b..2aa2dfc 100644 --- a/resource/template/vm/vue/edit-vue.template +++ b/resource/template/vm/vue/edit-vue.template @@ -132,6 +132,7 @@ @@ -140,6 +141,7 @@