refactor: localize protobuf definitions
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
package wallet
|
||||
|
||||
import (
|
||||
protobuf "bsm/full/protobuf"
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
@@ -32,17 +31,17 @@ const (
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type PaymentClient interface {
|
||||
Hello(ctx context.Context, in *protobuf.Empty, opts ...grpc.CallOption) (*PaymentReply, error)
|
||||
Hello(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*PaymentReply, error)
|
||||
// 获取平台支持的支付网关
|
||||
Way(ctx context.Context, in *WayRequest, opts ...grpc.CallOption) (*WayReply, error)
|
||||
// 获取支付的详情
|
||||
Get(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*PaymentItem, error)
|
||||
Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*PaymentItem, error)
|
||||
// 支付-电商订单
|
||||
ByOrder(ctx context.Context, in *OrderRequest, opts ...grpc.CallOption) (*PaymentReply, error)
|
||||
// 支付-充值
|
||||
ByCharge(ctx context.Context, in *ChargeRequest, opts ...grpc.CallOption) (*PaymentReply, error)
|
||||
// 回调更新支付的结果和状态
|
||||
Callback(ctx context.Context, in *CallbackRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
|
||||
Callback(ctx context.Context, in *CallbackRequest, opts ...grpc.CallOption) (*StatusReply, error)
|
||||
}
|
||||
|
||||
type paymentClient struct {
|
||||
@@ -53,7 +52,7 @@ func NewPaymentClient(cc grpc.ClientConnInterface) PaymentClient {
|
||||
return &paymentClient{cc}
|
||||
}
|
||||
|
||||
func (c *paymentClient) Hello(ctx context.Context, in *protobuf.Empty, opts ...grpc.CallOption) (*PaymentReply, error) {
|
||||
func (c *paymentClient) Hello(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*PaymentReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PaymentReply)
|
||||
err := c.cc.Invoke(ctx, Payment_Hello_FullMethodName, in, out, cOpts...)
|
||||
@@ -73,7 +72,7 @@ func (c *paymentClient) Way(ctx context.Context, in *WayRequest, opts ...grpc.Ca
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *paymentClient) Get(ctx context.Context, in *protobuf.IdentRequest, opts ...grpc.CallOption) (*PaymentItem, error) {
|
||||
func (c *paymentClient) Get(ctx context.Context, in *IdentRequest, opts ...grpc.CallOption) (*PaymentItem, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PaymentItem)
|
||||
err := c.cc.Invoke(ctx, Payment_Get_FullMethodName, in, out, cOpts...)
|
||||
@@ -103,9 +102,9 @@ func (c *paymentClient) ByCharge(ctx context.Context, in *ChargeRequest, opts ..
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *paymentClient) Callback(ctx context.Context, in *CallbackRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
|
||||
func (c *paymentClient) Callback(ctx context.Context, in *CallbackRequest, opts ...grpc.CallOption) (*StatusReply, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(protobuf.StatusReply)
|
||||
out := new(StatusReply)
|
||||
err := c.cc.Invoke(ctx, Payment_Callback_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -117,17 +116,17 @@ func (c *paymentClient) Callback(ctx context.Context, in *CallbackRequest, opts
|
||||
// All implementations should embed UnimplementedPaymentServer
|
||||
// for forward compatibility.
|
||||
type PaymentServer interface {
|
||||
Hello(context.Context, *protobuf.Empty) (*PaymentReply, error)
|
||||
Hello(context.Context, *Empty) (*PaymentReply, error)
|
||||
// 获取平台支持的支付网关
|
||||
Way(context.Context, *WayRequest) (*WayReply, error)
|
||||
// 获取支付的详情
|
||||
Get(context.Context, *protobuf.IdentRequest) (*PaymentItem, error)
|
||||
Get(context.Context, *IdentRequest) (*PaymentItem, error)
|
||||
// 支付-电商订单
|
||||
ByOrder(context.Context, *OrderRequest) (*PaymentReply, error)
|
||||
// 支付-充值
|
||||
ByCharge(context.Context, *ChargeRequest) (*PaymentReply, error)
|
||||
// 回调更新支付的结果和状态
|
||||
Callback(context.Context, *CallbackRequest) (*protobuf.StatusReply, error)
|
||||
Callback(context.Context, *CallbackRequest) (*StatusReply, error)
|
||||
}
|
||||
|
||||
// UnimplementedPaymentServer should be embedded to have
|
||||
@@ -137,13 +136,13 @@ type PaymentServer interface {
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedPaymentServer struct{}
|
||||
|
||||
func (UnimplementedPaymentServer) Hello(context.Context, *protobuf.Empty) (*PaymentReply, error) {
|
||||
func (UnimplementedPaymentServer) Hello(context.Context, *Empty) (*PaymentReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Hello not implemented")
|
||||
}
|
||||
func (UnimplementedPaymentServer) Way(context.Context, *WayRequest) (*WayReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Way not implemented")
|
||||
}
|
||||
func (UnimplementedPaymentServer) Get(context.Context, *protobuf.IdentRequest) (*PaymentItem, error) {
|
||||
func (UnimplementedPaymentServer) Get(context.Context, *IdentRequest) (*PaymentItem, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Get not implemented")
|
||||
}
|
||||
func (UnimplementedPaymentServer) ByOrder(context.Context, *OrderRequest) (*PaymentReply, error) {
|
||||
@@ -152,7 +151,7 @@ func (UnimplementedPaymentServer) ByOrder(context.Context, *OrderRequest) (*Paym
|
||||
func (UnimplementedPaymentServer) ByCharge(context.Context, *ChargeRequest) (*PaymentReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ByCharge not implemented")
|
||||
}
|
||||
func (UnimplementedPaymentServer) Callback(context.Context, *CallbackRequest) (*protobuf.StatusReply, error) {
|
||||
func (UnimplementedPaymentServer) Callback(context.Context, *CallbackRequest) (*StatusReply, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method Callback not implemented")
|
||||
}
|
||||
func (UnimplementedPaymentServer) testEmbeddedByValue() {}
|
||||
@@ -176,7 +175,7 @@ func RegisterPaymentServer(s grpc.ServiceRegistrar, srv PaymentServer) {
|
||||
}
|
||||
|
||||
func _Payment_Hello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(protobuf.Empty)
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -188,7 +187,7 @@ func _Payment_Hello_Handler(srv interface{}, ctx context.Context, dec func(inter
|
||||
FullMethod: Payment_Hello_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PaymentServer).Hello(ctx, req.(*protobuf.Empty))
|
||||
return srv.(PaymentServer).Hello(ctx, req.(*Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -212,7 +211,7 @@ func _Payment_Way_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
}
|
||||
|
||||
func _Payment_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(protobuf.IdentRequest)
|
||||
in := new(IdentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -224,7 +223,7 @@ func _Payment_Get_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
FullMethod: Payment_Get_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PaymentServer).Get(ctx, req.(*protobuf.IdentRequest))
|
||||
return srv.(PaymentServer).Get(ctx, req.(*IdentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user