From b8cbd4fb30162823c57c7d54901f8286011b15a6 Mon Sep 17 00:00:00 2001 From: xxj <346944475@qq.com> Date: Wed, 9 Feb 2022 15:57:41 +0800 Subject: [PATCH] Update def.go --- data/view/genfunc/def.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/view/genfunc/def.go b/data/view/genfunc/def.go index cd29415..6b100b9 100755 --- a/data/view/genfunc/def.go +++ b/data/view/genfunc/def.go @@ -219,7 +219,7 @@ func (obj *_{{$obj.StructName}}Mgr) Reset() *_{{$obj.StructName}}Mgr { // Get 获取 func (obj *_{{$obj.StructName}}Mgr) Get() (result {{$obj.StructName}}, err error) { - err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).Find(&result).Error + err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).First(&result).Error {{GenPreloadList $obj.PreloadList false}} return } @@ -255,7 +255,7 @@ func (obj *_{{$obj.StructName}}Mgr) GetByOption(opts ...Option) (result {{$obj.S o.apply(&options) } - err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).Where(options.query).Find(&result).Error + err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).Where(options.query).First(&result).Error {{GenPreloadList $obj.PreloadList false}} return } @@ -326,7 +326,7 @@ func (obj *_{{$obj.StructName}}Mgr) GetBatchFrom{{$oem.ColStructName}}({{CapLowe {{range $ofm := $obj.Primary}} // {{GenFListIndex $ofm 1}} primary or index 获取唯一内容 func (obj *_{{$obj.StructName}}Mgr) {{GenFListIndex $ofm 1}}({{GenFListIndex $ofm 2}}) (result {{$obj.StructName}}, err error) { - err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).Where("{{GenFListIndex $ofm 3}}", {{GenFListIndex $ofm 4}}).Find(&result).Error + err = obj.DB.WithContext(obj.ctx).Model({{$obj.StructName}}{}).Where("{{GenFListIndex $ofm 3}}", {{GenFListIndex $ofm 4}}).First(&result).Error {{GenPreloadList $obj.PreloadList false}} return }