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)) } }() }