From b4994d228efeb530176ad717e5c495fdd5144459 Mon Sep 17 00:00:00 2001 From: yxh Date: Sat, 18 Sep 2021 14:46:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AF=86=E5=88=AB=E4=B8=BB=E9=94=AE=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/vm/go/controller.template | 4 ++-- template/vm/go/service.template | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/template/vm/go/controller.template b/template/vm/go/controller.template index 1bed68d..ddc04c1 100644 --- a/template/vm/go/controller.template +++ b/template/vm/go/controller.template @@ -105,7 +105,7 @@ func (c *{{$structName}}) Add(r *ghttp.Request) { // Get 获取 func (c *{{$structName}}) Get(r *ghttp.Request) { - id := r.GetInt64("id") + id := r.Get{{$.table.PkColumn.GoType | CaseCamel}}("id") info, err := service.{{.table.ClassName}}.GetInfoById(r.GetCtx(),id) if err != nil { c.FailJsonExit(r, err.Error()) @@ -151,7 +151,7 @@ func (c *{{$structName}}) Edit(r *ghttp.Request) { // Delete 删除 func (c *{{$structName}}) Delete(r *ghttp.Request) { - ids := r.GetInts("ids") + ids := r.Get{{$.table.PkColumn.GoType | CaseCamel}}s("ids") err := service.{{.table.ClassName}}.DeleteByIds(r.GetCtx(),ids) if err != nil { c.FailJsonExit(r, err.Error()) diff --git a/template/vm/go/service.template b/template/vm/go/service.template index 3ce83b3..3430f3d 100644 --- a/template/vm/go/service.template +++ b/template/vm/go/service.template @@ -165,7 +165,7 @@ func (s *{{$structName}}) GetList(req *dao.{{.table.ClassName}}SearchReq) (total // GetInfoById 通过id获取 -func (s *{{$structName}}) GetInfoById(ctx context.Context,id int64) (info *dao.{{.table.ClassName}}InfoRes, err error) { +func (s *{{$structName}}) GetInfoById(ctx context.Context,id {{$.table.PkColumn.GoType}}) (info *dao.{{.table.ClassName}}InfoRes, err error) { if id == 0 { err = gerror.New("参数错误") return @@ -218,7 +218,7 @@ func (s *{{$structName}}) Edit(ctx context.Context,req *dao.{{.table.ClassName}} // DeleteByIds 删除 -func (s *{{$structName}}) DeleteByIds(ctx context.Context,ids []int) (err error) { +func (s *{{$structName}}) DeleteByIds(ctx context.Context,ids []{{$.table.PkColumn.GoType}}) (err error) { if len(ids) == 0 { err = gerror.New("参数错误") return @@ -252,7 +252,7 @@ func (s *{{$structName}}) Change{{$column.GoField}}(ctx context.Context,req *dao {{if eq .table.TplCategory "tree"}} // GetChildrenIds 通过ID获取子级ID -func (s *{{$structName}})GetChildrenIds(ctx context.Context,ids []int) ([]int, error) { +func (s *{{$structName}})GetChildrenIds(ctx context.Context,ids []{{$.table.PkColumn.GoType}}) ([]{{$.table.PkColumn.GoType}}, error) { //获取所有 _,_,all, err := s.GetList(&dao.{{.table.ClassName}}SearchReq{PageReq:comModel.PageReq{Ctx: ctx}}) if err != nil {