From 50b192850284c42b01c7e721040ed5884b74134d Mon Sep 17 00:00:00 2001 From: mlr3000 Date: Tue, 15 Feb 2022 11:34:48 +0800 Subject: [PATCH] chore:use struct pointer (#1538) --- tools/goctl/api/gogen/genhandlers.go | 2 +- tools/goctl/api/gogen/genlogic.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/goctl/api/gogen/genhandlers.go b/tools/goctl/api/gogen/genhandlers.go index c82532e7..45b61081 100644 --- a/tools/goctl/api/gogen/genhandlers.go +++ b/tools/goctl/api/gogen/genhandlers.go @@ -34,7 +34,7 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { } {{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx) - {{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}req{{end}}) + {{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}}) if err != nil { httpx.Error(w, err) } else { diff --git a/tools/goctl/api/gogen/genlogic.go b/tools/goctl/api/gogen/genlogic.go index 6b0d342c..475b941d 100644 --- a/tools/goctl/api/gogen/genlogic.go +++ b/tools/goctl/api/gogen/genlogic.go @@ -26,8 +26,8 @@ type {{.logic}} struct { svcCtx *svc.ServiceContext } -func New{{.logic}}(ctx context.Context, svcCtx *svc.ServiceContext) {{.logic}} { - return {{.logic}}{ +func New{{.logic}}(ctx context.Context, svcCtx *svc.ServiceContext) *{{.logic}} { + return &{{.logic}}{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, @@ -73,7 +73,7 @@ func genLogicByRoute(dir, rootPkg string, cfg *config.Config, group spec.Group, returnString = "return nil" } if len(route.RequestTypeName()) > 0 { - requestString = "req " + requestGoTypeName(route, typesPacket) + requestString = "req *" + requestGoTypeName(route, typesPacket) } subDir := getLogicFolderPath(group, route)