From e39f15f1cfbc743e4a6a586300147a81b2192f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=B5=E9=AB=98=E5=93=A6?= <1151499519@qq.com> Date: Thu, 18 Apr 2024 10:25:08 +0800 Subject: [PATCH] fix: add condition --- tools/rpccall/proto.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/rpccall/proto.go b/tools/rpccall/proto.go index bb98620..f38b7d5 100644 --- a/tools/rpccall/proto.go +++ b/tools/rpccall/proto.go @@ -71,7 +71,10 @@ func SProtoCall(ctx *routing.Context, param interface{}, handler interface{}) er } rv := rt2.FieldByName("CommonResp").Elem() - if rv.FieldByName("Code").Int() != int64(0) { + if !rv.IsValid() { + return hc.Success(ctx, rets[0].Interface(), "") + } + if rv.FieldByName("Code").IsValid() && rv.FieldByName("Code").Int() != int64(0) { return hc.Fail(ctx, &error_support.Error{Code: int(rv.FieldByName("Code").Int()), Msg: rv.FieldByName("Msg").String()}) } return hc.Success(ctx, rets[0].Interface(), rv.FieldByName("Msg").String())