From 36174ba5cc45992d4e9698f79180225b1b93e983 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 31 Aug 2020 12:32:13 +0800 Subject: [PATCH] make svcCtx as a member for better code generation --- tools/goctl/api/gogen/genlogic.go | 4 +++- tools/goctl/rpc/gen/genlogic.go | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/goctl/api/gogen/genlogic.go b/tools/goctl/api/gogen/genlogic.go index 49da400f..55332b02 100644 --- a/tools/goctl/api/gogen/genlogic.go +++ b/tools/goctl/api/gogen/genlogic.go @@ -20,13 +20,15 @@ import ( ) type {{.logic}} struct { - ctx context.Context + ctx context.Context + svcCtx *svc.ServiceContext logx.Logger } func New{{.logic}}(ctx context.Context, svcCtx *svc.ServiceContext) {{.logic}} { return {{.logic}}{ ctx: ctx, + svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } diff --git a/tools/goctl/rpc/gen/genlogic.go b/tools/goctl/rpc/gen/genlogic.go index 4c2de0ed..ca4468ca 100644 --- a/tools/goctl/rpc/gen/genlogic.go +++ b/tools/goctl/rpc/gen/genlogic.go @@ -22,13 +22,15 @@ import ( ) type {{.logicName}} struct { - ctx context.Context + ctx context.Context + svcCtx *svc.ServiceContext logx.Logger } func New{{.logicName}}(ctx context.Context,svcCtx *svc.ServiceContext) *{{.logicName}} { return &{{.logicName}}{ ctx: ctx, + svcCtx: svcCtx, Logger: logx.WithContext(ctx), } }