From 57fd3eb516f07c270f9f829703c34a815b053999 Mon Sep 17 00:00:00 2001 From: "huangsimin@fusen.cn" Date: Wed, 29 Nov 2023 17:41:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../proto_build/tpls/logic_grpc_struct.tpl | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/goutils/proto_build/tpls/logic_grpc_struct.tpl b/goutils/proto_build/tpls/logic_grpc_struct.tpl index 76dc810..8f8f1c6 100644 --- a/goutils/proto_build/tpls/logic_grpc_struct.tpl +++ b/goutils/proto_build/tpls/logic_grpc_struct.tpl @@ -61,7 +61,6 @@ func (lgrpc *{{.StructName}}Grpc) {{.MethodName}}(ctx {{.ParamCtx}}, req {{.Para } {{end}} - func DefaultValidToken(ctx context.Context) *basic.UserInfo { var ( err error @@ -82,9 +81,11 @@ func DefaultValidToken(ctx context.Context) *basic.UserInfo { defer func() { if vresult != nil { userinfo := vresult.UserInfo.AsMap() - ui.UserId = int64(userinfo["user_id"].(float64)) - ui.GuestId = int64(userinfo["guest_id"].(float64)) - ui.Exp = int64(userinfo["exp"].(float64)) + if len(userinfo) != 0 { + ui.UserId = int64(userinfo["user_id"].(float64)) + ui.GuestId = int64(userinfo["guest_id"].(float64)) + ui.Exp = int64(userinfo["exp"].(float64)) + } } }() } @@ -102,13 +103,15 @@ func DefaultValidToken(ctx context.Context) *basic.UserInfo { defer func() { if vresult != nil { debug := vresult.DebugInfo.AsMap() - ui.Debug = &basic.Debug{} - if dexp, ok := debug["exp"]; ok { - dexpint64 := int64(dexp.(float64)) - ui.Debug.Exp = &dexpint64 + if len(debug) != 0 { + ui.Debug = &basic.Debug{} + if dexp, ok := debug["exp"]; ok { + dexpint64 := int64(dexp.(float64)) + ui.Debug.Exp = &dexpint64 + } + ui.Debug.IsAllTemplateTag = int64(debug["is_all_template_tag"].(float64)) + ui.Debug.IsCache = int64(debug["is_cache"].(float64)) } - ui.Debug.IsAllTemplateTag = int64(debug["is_all_template_tag"].(float64)) - ui.Debug.IsCache = int64(debug["is_cache"].(float64)) } }() }