diff --git a/internal/api/a2r/api2rpc.go b/internal/api/a2r/api2rpc.go index 98d34e8ea..d370b23f6 100644 --- a/internal/api/a2r/api2rpc.go +++ b/internal/api/a2r/api2rpc.go @@ -39,38 +39,3 @@ func Call[A, B, C any]( } apiresp.GinSuccess(c, data) // 成功 } -func Call2[A, B, C any]( - _ func(client C, ctx context.Context, req *A, options ...grpc.CallOption) (*B, error), - client func() (C, error), - c *gin.Context, -) { - var req A - if err := c.BindJSON(&req); err != nil { - apiresp.GinError(c, errs.ErrArgs.Wrap(err.Error())) // 参数错误 - return - } - if check, ok := any(&req).(interface{ Check() error }); ok { - if err := check.Check(); err != nil { - apiresp.GinError(c, errs.ErrArgs.Wrap(err.Error())) // 参数校验失败 - return - } - } - cli, err := client() - if err != nil { - apiresp.GinError(c, errs.ErrInternalServer.Wrap(err.Error())) // 获取RPC连接失败 - log.Error("0", "get rpc client conn err:", err.Error()) - return - } - if a, ok := any(&cli).(interface { - rpc(ctx context.Context, req *A, options ...grpc.CallOption) (*B, error) - }); ok { - data, err := a.rpc(c, &req) - if err != nil { - log.Error("0", "rpc call err:", err.Error()) - apiresp.GinError(c, err) // RPC调用失败 - return - } - apiresp.GinSuccess(c, data) // 成功 - } - -} diff --git a/internal/api/auth.go b/internal/api/auth.go index 6f61a310b..e997ba6aa 100644 --- a/internal/api/auth.go +++ b/internal/api/auth.go @@ -32,8 +32,7 @@ func (o *Auth) UserRegister(c *gin.Context) { } func (o *Auth) UserToken(c *gin.Context) { - - a2r.Call2(auth.AuthClient.UserToken, o.client, c) + a2r.Call(auth.AuthClient.UserToken, o.client, c) } func (o *Auth) ParseToken(c *gin.Context) { diff --git a/pkg/common/mw/rpc.go b/pkg/common/mw/rpc.go index f9004b648..a1d75233a 100644 --- a/pkg/common/mw/rpc.go +++ b/pkg/common/mw/rpc.go @@ -64,10 +64,13 @@ func rpcClientInterceptor(ctx context.Context, method string, req, reply interfa if ok { md.Append(constant.OpUserID, opUserID) } + log.Info("", "rpc come here") err = invoker(metadata.NewOutgoingContext(ctx, md), method, req, reply, cc, opts...) if err == nil { return nil } + log.Info("", "rpc come here err") + rpcErr, ok := err.(interface{ GRPCStatus() *status.Status }) if !ok { return errs.NewCodeError(errs.DefaultOtherError, err.Error()).Wrap()