refactor: localize protobuf definitions

This commit is contained in:
2026-08-09 20:14:57 +08:00
parent 9f6f318bbb
commit 5ea45a76fe
429 changed files with 54058 additions and 61623 deletions

View File

@@ -2,9 +2,9 @@
package server
import (
"context"
"bsm/full/module/finance/wallet/internal/logic/alipay"
pb "bsm/full/module/finance/wallet/pb"
"context"
)
type AlipayServer struct {

View File

@@ -2,9 +2,9 @@
package server
import (
"context"
"bsm/full/module/finance/wallet/internal/logic/basic"
pb "bsm/full/module/finance/wallet/pb"
"context"
)
type BasicServer struct {

View File

@@ -2,18 +2,12 @@
package server
import (
"context"
pb "bsm/full/module/finance/wallet/pb"
"git.apinb.com/bsm-sdk/core/vars"
"context"
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/reflection"
"google.golang.org/protobuf/proto"
"net/http"
"os"
"strings"
"time"
)
type Server struct {
@@ -27,7 +21,6 @@ func New(addr string) *Server {
srv := &Server{
Ctx: context.Background(),
Grpc: grpc.NewServer(),
Mux: gwRuntime.NewServeMux(gwRuntime.WithForwardResponseRewriter(responseEnvelope)),
grpcConns: make(map[string]*grpc.ClientConn),
}
@@ -39,68 +32,5 @@ func New(addr string) *Server {
reflection.Register(srv.Grpc)
// 连接池: 只创建一次连接并复用
conn, ok := srv.grpcConns[addr]
if !ok {
var err error
conn, err = grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
panic("failed to dial grpc server: " + err.Error())
}
srv.grpcConns[addr] = conn
}
// 将服务注册到Gateway
if err := pb.RegisterAlipayHandler(srv.Ctx, srv.Mux, conn); err != nil {
panic("Failed to register Alipay handler: " + err.Error())
}
if err := pb.RegisterPaymentHandler(srv.Ctx, srv.Mux, conn); err != nil {
panic("Failed to register Payment handler: " + err.Error())
}
if err := pb.RegisterBasicHandler(srv.Ctx, srv.Mux, conn); err != nil {
panic("Failed to register Basic handler: " + err.Error())
}
if err := pb.RegisterWechatHandler(srv.Ctx, srv.Mux, conn); err != nil {
panic("Failed to register Wechat handler: " + err.Error())
}
// Register services swagger
srv.RegisterSwagger()
return srv
}
// RegisterSwagger 注册swagger
func (s *Server) RegisterSwagger() {
srvKey := strings.ToLower(vars.ServiceKey)
s.Mux.HandlePath("GET", "/"+srvKey+".swagger.json", func(w http.ResponseWriter, r *http.Request, pathParams map[string]string) {
w.Header().Set("Content-Type", "application/json")
bytes, err := os.ReadFile("./swagger/" + srvKey + ".swagger.json")
if err != nil {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(err.Error()))
return
}
w.Write(bytes)
return
})
}
// response envelope
func responseEnvelope(_ context.Context, response proto.Message) (interface{}, error) {
name := string(response.ProtoReflect().Descriptor().Name())
if name == "Status" || name == "Error" || name == "StatusReply" {
return response, nil
}
return map[string]any{
"code": 0,
"message": vars.OK,
"details": response,
"timeseq": time.Now().Unix(),
}, nil
}

View File

@@ -2,9 +2,9 @@
package server
import (
"context"
"bsm/full/module/finance/wallet/internal/logic/payment"
pb "bsm/full/module/finance/wallet/pb"
"context"
)
type PaymentServer struct {

View File

@@ -2,9 +2,9 @@
package server
import (
"context"
"bsm/full/module/finance/wallet/internal/logic/wechat"
pb "bsm/full/module/finance/wallet/pb"
"context"
)
type WechatServer struct {

View File

@@ -1,10 +0,0 @@
package wallet
import blocks "bsm/full/protobuf"
type Empty = blocks.Empty
type FetchRequest = blocks.FetchRequest
type IdentRequest = blocks.IdentRequest
type VersionRequest = blocks.VersionRequest
type SearchRequest = blocks.SearchRequest
type StatusReply = blocks.StatusReply

File diff suppressed because it is too large Load Diff

View File

@@ -7,7 +7,6 @@
package wallet
import (
protobuf "bsm/full/protobuf"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@@ -578,7 +577,7 @@ var File_module_finance_wallet_proto_payment_proto protoreflect.FileDescriptor
const file_module_finance_wallet_proto_payment_proto_rawDesc = "" +
"\n" +
")module/finance/wallet/proto/payment.proto\x12\x06wallet\x1a\x15protobuf/blocks.proto\"(\n" +
")module/finance/wallet/proto/payment.proto\x12\x06wallet\x1a'module/finance/wallet/proto/const.proto\"(\n" +
"\n" +
"WayRequest\x12\x1a\n" +
"\bplatform\x18\x01 \x01(\tR\bplatform\"-\n" +
@@ -649,18 +648,18 @@ func file_module_finance_wallet_proto_payment_proto_rawDescGZIP() []byte {
var file_module_finance_wallet_proto_payment_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_module_finance_wallet_proto_payment_proto_goTypes = []any{
(*WayRequest)(nil), // 0: wallet.WayRequest
(*WayReply)(nil), // 1: wallet.WayReply
(*WayItem)(nil), // 2: wallet.WayItem
(*PaymentItem)(nil), // 3: wallet.PaymentItem
(*ChargeRequest)(nil), // 4: wallet.ChargeRequest
(*OrderRequest)(nil), // 5: wallet.OrderRequest
(*CallbackRequest)(nil), // 6: wallet.CallbackRequest
(*PaymentReply)(nil), // 7: wallet.PaymentReply
nil, // 8: wallet.PaymentReply.ResultEntry
(*protobuf.Empty)(nil), // 9: blocks.Empty
(*protobuf.IdentRequest)(nil), // 10: blocks.IdentRequest
(*protobuf.StatusReply)(nil), // 11: blocks.StatusReply
(*WayRequest)(nil), // 0: wallet.WayRequest
(*WayReply)(nil), // 1: wallet.WayReply
(*WayItem)(nil), // 2: wallet.WayItem
(*PaymentItem)(nil), // 3: wallet.PaymentItem
(*ChargeRequest)(nil), // 4: wallet.ChargeRequest
(*OrderRequest)(nil), // 5: wallet.OrderRequest
(*CallbackRequest)(nil), // 6: wallet.CallbackRequest
(*PaymentReply)(nil), // 7: wallet.PaymentReply
nil, // 8: wallet.PaymentReply.ResultEntry
(*Empty)(nil), // 9: blocks.Empty
(*IdentRequest)(nil), // 10: blocks.IdentRequest
(*StatusReply)(nil), // 11: blocks.StatusReply
}
var file_module_finance_wallet_proto_payment_proto_depIdxs = []int32{
2, // 0: wallet.WayReply.way:type_name -> wallet.WayItem
@@ -689,6 +688,7 @@ func file_module_finance_wallet_proto_payment_proto_init() {
if File_module_finance_wallet_proto_payment_proto != nil {
return
}
file_module_finance_wallet_proto_const_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@@ -9,7 +9,6 @@ It translates gRPC into RESTful JSON APIs.
package wallet
import (
"bsm/full/protobuf"
"context"
"errors"
"io"
@@ -38,7 +37,7 @@ var (
func request_Payment_Hello_0(ctx context.Context, marshaler runtime.Marshaler, client PaymentClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq blocks.Empty
protoReq Empty
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
@@ -53,7 +52,7 @@ func request_Payment_Hello_0(ctx context.Context, marshaler runtime.Marshaler, c
func local_request_Payment_Hello_0(ctx context.Context, marshaler runtime.Marshaler, server PaymentServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq blocks.Empty
protoReq Empty
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
@@ -92,7 +91,7 @@ func local_request_Payment_Way_0(ctx context.Context, marshaler runtime.Marshale
func request_Payment_Get_0(ctx context.Context, marshaler runtime.Marshaler, client PaymentClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq blocks.IdentRequest
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
@@ -107,7 +106,7 @@ func request_Payment_Get_0(ctx context.Context, marshaler runtime.Marshaler, cli
func local_request_Payment_Get_0(ctx context.Context, marshaler runtime.Marshaler, server PaymentServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq blocks.IdentRequest
protoReq IdentRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {

View File

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

View File

@@ -7,7 +7,6 @@
package wallet
import (
protobuf "bsm/full/protobuf"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@@ -1086,7 +1085,7 @@ var File_module_finance_wallet_proto_wallet_proto protoreflect.FileDescriptor
const file_module_finance_wallet_proto_wallet_proto_rawDesc = "" +
"\n" +
"(module/finance/wallet/proto/wallet.proto\x12\x06wallet\x1a\x15protobuf/blocks.proto\"\x92\x02\n" +
"(module/finance/wallet/proto/wallet.proto\x12\x06wallet\x1a'module/finance/wallet/proto/const.proto\"\x92\x02\n" +
"\x10GetWalletRequest\x12)\n" +
"\x11is_total_today_in\x18\x01 \x01(\bR\x0eisTotalTodayIn\x12+\n" +
"\x12is_total_today_out\x18\x02 \x01(\bR\x0fisTotalTodayOut\x12)\n" +
@@ -1226,7 +1225,7 @@ var file_module_finance_wallet_proto_wallet_proto_goTypes = []any{
(*BankCardInfo)(nil), // 13: wallet.BankCardInfo
(*ApplyCashRequest)(nil), // 14: wallet.ApplyCashRequest
nil, // 15: wallet.GetWalletReply.TotalEntry
(*protobuf.StatusReply)(nil), // 16: blocks.StatusReply
(*StatusReply)(nil), // 16: blocks.StatusReply
}
var file_module_finance_wallet_proto_wallet_proto_depIdxs = []int32{
15, // 0: wallet.GetWalletReply.total:type_name -> wallet.GetWalletReply.TotalEntry
@@ -1261,6 +1260,7 @@ func file_module_finance_wallet_proto_wallet_proto_init() {
if File_module_finance_wallet_proto_wallet_proto != nil {
return
}
file_module_finance_wallet_proto_const_proto_init()
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@@ -7,7 +7,6 @@
package wallet
import (
protobuf "bsm/full/protobuf"
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
@@ -37,19 +36,19 @@ type BasicClient interface {
// 获取钱包信息
GetWallet(ctx context.Context, in *GetWalletRequest, opts ...grpc.CallOption) (*GetWalletReply, error)
// 设置支付密码
SetPayPassword(ctx context.Context, in *SetPayPasswordRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
SetPayPassword(ctx context.Context, in *SetPayPasswordRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 绑定微信或支付宝账户
BindPaymentId(ctx context.Context, in *BindPaymentIDRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
BindPaymentId(ctx context.Context, in *BindPaymentIDRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 查询交易记录
Transactions(ctx context.Context, in *TransactionsRequest, opts ...grpc.CallOption) (*TransactionsReply, error)
// 添加银行卡
AddBankCard(ctx context.Context, in *AddBankCardRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
AddBankCard(ctx context.Context, in *AddBankCardRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 获取用户银行卡列表
GetBankCard(ctx context.Context, in *FinanceEmpty, opts ...grpc.CallOption) (*GetBankCardReply, error)
// 删除银行卡
RmBankCard(ctx context.Context, in *RmBankCardRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
RmBankCard(ctx context.Context, in *RmBankCardRequest, opts ...grpc.CallOption) (*StatusReply, error)
// 申请提现
ApplyCash(ctx context.Context, in *ApplyCashRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error)
ApplyCash(ctx context.Context, in *ApplyCashRequest, opts ...grpc.CallOption) (*StatusReply, error)
}
type basicClient struct {
@@ -70,9 +69,9 @@ func (c *basicClient) GetWallet(ctx context.Context, in *GetWalletRequest, opts
return out, nil
}
func (c *basicClient) SetPayPassword(ctx context.Context, in *SetPayPasswordRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
func (c *basicClient) SetPayPassword(ctx context.Context, in *SetPayPasswordRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(protobuf.StatusReply)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Basic_SetPayPassword_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
@@ -80,9 +79,9 @@ func (c *basicClient) SetPayPassword(ctx context.Context, in *SetPayPasswordRequ
return out, nil
}
func (c *basicClient) BindPaymentId(ctx context.Context, in *BindPaymentIDRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
func (c *basicClient) BindPaymentId(ctx context.Context, in *BindPaymentIDRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(protobuf.StatusReply)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Basic_BindPaymentId_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
@@ -100,9 +99,9 @@ func (c *basicClient) Transactions(ctx context.Context, in *TransactionsRequest,
return out, nil
}
func (c *basicClient) AddBankCard(ctx context.Context, in *AddBankCardRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
func (c *basicClient) AddBankCard(ctx context.Context, in *AddBankCardRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(protobuf.StatusReply)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Basic_AddBankCard_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
@@ -120,9 +119,9 @@ func (c *basicClient) GetBankCard(ctx context.Context, in *FinanceEmpty, opts ..
return out, nil
}
func (c *basicClient) RmBankCard(ctx context.Context, in *RmBankCardRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
func (c *basicClient) RmBankCard(ctx context.Context, in *RmBankCardRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(protobuf.StatusReply)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Basic_RmBankCard_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
@@ -130,9 +129,9 @@ func (c *basicClient) RmBankCard(ctx context.Context, in *RmBankCardRequest, opt
return out, nil
}
func (c *basicClient) ApplyCash(ctx context.Context, in *ApplyCashRequest, opts ...grpc.CallOption) (*protobuf.StatusReply, error) {
func (c *basicClient) ApplyCash(ctx context.Context, in *ApplyCashRequest, opts ...grpc.CallOption) (*StatusReply, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(protobuf.StatusReply)
out := new(StatusReply)
err := c.cc.Invoke(ctx, Basic_ApplyCash_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
@@ -147,19 +146,19 @@ type BasicServer interface {
// 获取钱包信息
GetWallet(context.Context, *GetWalletRequest) (*GetWalletReply, error)
// 设置支付密码
SetPayPassword(context.Context, *SetPayPasswordRequest) (*protobuf.StatusReply, error)
SetPayPassword(context.Context, *SetPayPasswordRequest) (*StatusReply, error)
// 绑定微信或支付宝账户
BindPaymentId(context.Context, *BindPaymentIDRequest) (*protobuf.StatusReply, error)
BindPaymentId(context.Context, *BindPaymentIDRequest) (*StatusReply, error)
// 查询交易记录
Transactions(context.Context, *TransactionsRequest) (*TransactionsReply, error)
// 添加银行卡
AddBankCard(context.Context, *AddBankCardRequest) (*protobuf.StatusReply, error)
AddBankCard(context.Context, *AddBankCardRequest) (*StatusReply, error)
// 获取用户银行卡列表
GetBankCard(context.Context, *FinanceEmpty) (*GetBankCardReply, error)
// 删除银行卡
RmBankCard(context.Context, *RmBankCardRequest) (*protobuf.StatusReply, error)
RmBankCard(context.Context, *RmBankCardRequest) (*StatusReply, error)
// 申请提现
ApplyCash(context.Context, *ApplyCashRequest) (*protobuf.StatusReply, error)
ApplyCash(context.Context, *ApplyCashRequest) (*StatusReply, error)
}
// UnimplementedBasicServer should be embedded to have
@@ -172,25 +171,25 @@ type UnimplementedBasicServer struct{}
func (UnimplementedBasicServer) GetWallet(context.Context, *GetWalletRequest) (*GetWalletReply, error) {
return nil, status.Error(codes.Unimplemented, "method GetWallet not implemented")
}
func (UnimplementedBasicServer) SetPayPassword(context.Context, *SetPayPasswordRequest) (*protobuf.StatusReply, error) {
func (UnimplementedBasicServer) SetPayPassword(context.Context, *SetPayPasswordRequest) (*StatusReply, error) {
return nil, status.Error(codes.Unimplemented, "method SetPayPassword not implemented")
}
func (UnimplementedBasicServer) BindPaymentId(context.Context, *BindPaymentIDRequest) (*protobuf.StatusReply, error) {
func (UnimplementedBasicServer) BindPaymentId(context.Context, *BindPaymentIDRequest) (*StatusReply, error) {
return nil, status.Error(codes.Unimplemented, "method BindPaymentId not implemented")
}
func (UnimplementedBasicServer) Transactions(context.Context, *TransactionsRequest) (*TransactionsReply, error) {
return nil, status.Error(codes.Unimplemented, "method Transactions not implemented")
}
func (UnimplementedBasicServer) AddBankCard(context.Context, *AddBankCardRequest) (*protobuf.StatusReply, error) {
func (UnimplementedBasicServer) AddBankCard(context.Context, *AddBankCardRequest) (*StatusReply, error) {
return nil, status.Error(codes.Unimplemented, "method AddBankCard not implemented")
}
func (UnimplementedBasicServer) GetBankCard(context.Context, *FinanceEmpty) (*GetBankCardReply, error) {
return nil, status.Error(codes.Unimplemented, "method GetBankCard not implemented")
}
func (UnimplementedBasicServer) RmBankCard(context.Context, *RmBankCardRequest) (*protobuf.StatusReply, error) {
func (UnimplementedBasicServer) RmBankCard(context.Context, *RmBankCardRequest) (*StatusReply, error) {
return nil, status.Error(codes.Unimplemented, "method RmBankCard not implemented")
}
func (UnimplementedBasicServer) ApplyCash(context.Context, *ApplyCashRequest) (*protobuf.StatusReply, error) {
func (UnimplementedBasicServer) ApplyCash(context.Context, *ApplyCashRequest) (*StatusReply, error) {
return nil, status.Error(codes.Unimplemented, "method ApplyCash not implemented")
}
func (UnimplementedBasicServer) testEmbeddedByValue() {}

View File

@@ -0,0 +1,326 @@
syntax = "proto3";
package blocks;
option go_package = "bsm/full/module/finance/wallet/pb;wallet";
// Shared request and response messages.
message Empty {}
message FetchRequest {
int64 page_no = 1 [json_name = "page_no"];
int64 page_size = 2 [json_name = "page_size"];
map<string, string> params = 3;
}
message IdentRequest {
int64 id = 1;
string identity = 2;
}
message VersionRequest {
int64 version = 1;
}
message SearchRequest {
string keyword = 1;
}
message StatusReply {
int32 code = 1;
string message = 2;
string details = 3;
int64 timeseq = 4;
}
// Service-specific variants whose wire formats differ from the shared types.
message CmsSearchRequest {
string keyword = 1;
int64 page_no = 2 [json_name = "page_no"];
int64 page_size = 3 [json_name = "page_size"];
}
message MallFetchRequest {
int64 page_no = 1 [json_name = "page_no"];
int64 page_size = 2 [json_name = "page_size"];
map<string, string> params = 3;
string store_identity = 4 [json_name = "store_identity"];
string keyword = 5;
repeated int64 category_id = 6;
string sort = 7;
int64 min_price = 8 [json_name = "min_price"];
int64 max_price = 9 [json_name = "max_price"];
}
message MarketFetchRequest {
int64 page_no = 1 [json_name = "page_no"];
int64 page_size = 2 [json_name = "page_size"];
map<string, string> params = 3;
string identity = 4;
string keyword = 5;
int32 status = 6;
int32 approve = 7;
}
message OrderIdentRequest {
int64 id = 1;
string identity = 2;
string reason = 3;
int32 approve = 4;
string agency = 5;
string store_identity = 6;
}
message DeliveryStatusReply {
int64 status = 1;
string identity = 2;
string message = 3;
int64 timeseq = 4;
}
message IdentityStatusReply {
int32 code = 1;
string identity = 2;
string message = 3;
int64 timeseq = 4;
}
message OrderStatusReply {
int32 code = 1;
string identity = 2;
string message = 3;
int64 timeseq = 4;
string reason = 5;
}
message DataStatusReply {
string data = 1;
int64 timeseq = 2;
}
message StoreSerialRequest {
string store_identity = 1 [json_name = "store_identity"];
repeated string serial_id = 2 [json_name = "serial_id"];
}
// Cloud messages.
message IDRequest {
uint64 id = 1;
}
message IDListRequest {
repeated uint64 ids = 1;
}
message StdIicuds {
uint64 id = 1;
string created_at = 2;
string updated_at = 3;
string deleted_at = 4;
}
message StdPassport {
uint64 passport_id = 1;
string passport_identity = 2;
}
message CloudBase {
uint64 cloud_id = 1;
string cloud_identity = 2;
}
// CMS messages.
message CmsCategoryItem {
string site_identity = 1 [json_name = "site_identity"];
int64 id = 2;
string identity = 3;
int64 parent_id = 4 [json_name = "parent_id"];
string title = 5;
string cover_path = 6 [json_name = "cover_path"];
string intro = 7;
string created_at = 8 [json_name = "created_at"];
string updated_at = 9 [json_name = "updated_at"];
repeated CmsCategoryItem child = 10;
string category_key = 11 [json_name = "category_key"];
}
message CmsTagsItem {
int64 id = 1;
string identity = 2;
string title = 3;
string cover_path = 4 [json_name = "cover_path"];
string intro = 5;
string created_at = 6 [json_name = "created_at"];
}
message CmsAccessoryItem {
string identity = 1;
string title = 2;
string file_path = 3 [json_name = "file_path"];
string created_at = 4 [json_name = "created_at"];
}
// Passport messages.
message VerifyStatus {
int32 email_verify = 1;
int32 phone_verify = 2;
int32 face_verify = 3;
int32 document_verify = 4;
int32 kyc_verify = 5;
}
// Market messages.
message MarketLoginReply {
string token = 1;
string identity = 2;
string market_identity = 3 [json_name = "market_identity"];
string name = 4;
string account = 5;
string role = 6;
int32 status = 7;
string created_at = 8 [json_name = "created_at"];
string market_name = 9 [json_name = "market_name"];
}
// Order messages.
message OrderSummaryItem {
int64 id = 1;
string order_no = 2 [json_name = "order_no"];
int64 partner_id = 3 [json_name = "partner_id"];
string identity = 4;
int64 total_price = 7 [json_name = "total_price"];
int64 trans_price = 8 [json_name = "trans_price"];
int64 refund_price = 9 [json_name = "refund_price"];
int64 logistics_fee = 11 [json_name = "logistics_fee"];
int64 coupon_amount = 12 [json_name = "coupon_amount"];
string remark = 13;
int32 status = 14;
string logistics_number = 15 [json_name = "logistics_number"];
string address_identity = 16 [json_name = "address_identity"];
string county = 17;
string province = 18;
string city = 19;
string area = 20;
string address = 21;
string contact = 22;
string phone = 23;
string delivery_time = 24 [json_name = "delivery_time"];
string delivery_identity = 25 [json_name = "delivery_identity"];
int32 pay_type = 26 [json_name = "pay_type"];
int64 pay_amount = 27 [json_name = "pay_amount"];
string pay_trade_no = 28 [json_name = "pay_trade_no"];
string pay_time = 29 [json_name = "pay_time"];
string pay_remark = 30 [json_name = "pay_remark"];
string created = 31;
string updated = 32;
repeated OrderDetails details = 33;
string addr = 34;
string car_identity = 35 [json_name = "car_identity"];
string delivery_address = 36 [json_name = "delivery_address"];
string brand = 37;
string version = 38;
string license_number = 39 [json_name = "license_number"];
string member_name = 40 [json_name = "member_name"];
string member_phone = 41 [json_name = "member_phone"];
int32 approve = 42;
}
message OrderDetails {
int64 id = 1;
int64 product_id = 2 [json_name = "product_id"];
string spec_no = 3 [json_name = "spec_no"];
string spec = 4;
int64 type = 5;
string title = 6;
string cover_image = 7 [json_name = "cover_image"];
int64 sales_price = 8 [json_name = "sales_price"];
string product_args = 9 [json_name = "product_args"];
int64 number = 10;
int64 unit_price = 11 [json_name = "unit_price"];
int64 spec_id = 12 [json_name = "spec_id"];
string product_identity = 13 [json_name = "product_identity"];
int64 gas_types = 14 [json_name = "gas_types"];
int64 total_price = 15 [json_name = "total_price"];
}
// Social feed messages.
message FeedPostListReply {
repeated FeedPostItem list = 1;
int64 cnt = 2;
}
message FeedPostItem {
string identity = 1;
string content = 2;
int64 feed_id = 3;
string feed_identity = 4;
bool is_open = 5;
int64 cnt_unlike = 6;
int64 cnt_comment = 7;
int64 cnt_like = 8;
repeated FeedAttachItem attachs = 9;
repeated FeedTagItem tags = 10;
}
message FeedAttachItem {
string identity = 1;
string attach_type = 2;
string url = 3;
}
message FeedTagItem {
string key = 1;
string content = 2;
}
// Social group messages.
message GroupPostListReply {
repeated GroupPostItem list = 1;
int64 cnt = 2;
}
message GroupPostItem {
string identity = 1;
string content = 2;
int64 passport_id = 3;
string passport_identity = 4;
bool is_open = 5;
int64 cnt_unlike = 6;
int64 cnt_comment = 7;
int64 cnt_like = 8;
repeated GroupAttachItem attachs = 9;
repeated GroupTagItem tags = 10;
}
message GroupAttachItem {
string identity = 1;
string attach_type = 2;
string url = 3;
}
message GroupTagItem {
string key = 1;
string content = 2;
}
// Social relation messages.
message RelationItem {
string identity = 1;
string nickname = 2;
string remark_name = 3;
int32 popular = 4;
string avatar = 5;
string birthday = 6;
int32 sex = 7;
int32 province = 8;
int32 city = 9;
int32 area = 10;
string sign = 11;
repeated string tags = 12;
int32 foreign_status = 13;
}
message FetchRelationItemReply {
int64 total = 1;
repeated RelationItem data = 2;
}

View File

@@ -1,7 +1,7 @@
syntax = "proto3";
package wallet;
option go_package = "bsm/full/module/finance/wallet/pb;wallet";
import "protobuf/blocks.proto";
import "module/finance/wallet/proto/const.proto";
service Payment {
rpc Hello(blocks.Empty) returns (PaymentReply) {}

View File

@@ -1,7 +1,7 @@
syntax = "proto3";
package wallet;
option go_package = "bsm/full/module/finance/wallet/pb;wallet";
import "protobuf/blocks.proto";
import "module/finance/wallet/proto/const.proto";
service Basic {
//获取钱包信息

View File

@@ -1,32 +0,0 @@
filebeat.inputs:
- type: log
enabled: true
# 开启json解析
json.keys_under_root: true
json.add_error_key: true
# 日志文件路径
paths:
- ./logs/wallet/error.log
- ./logs/wallet/slow.log
setup.template.settings:
index.number_of_shards: 1
# 定义kafka topic field
fields:
log_topic: scf.wallet.dev
# 输出到kafka
output.kafka:
hosts: ["127.0.0.1:9092"]
topic: '%{[fields.log_topic]}'
partition.round_robin:
reachable_only: false
required_acks: 1
keep_alive: 10s
# ================================= Processors =================================
processors:
- decode_json_fields:
fields: ['@timestamp','level','content','trace','span','duration']
target: ""

View File

@@ -1,5 +0,0 @@
#install
go install github.com/securego/gosec/v2/cmd/gosec@latest
#run
gosec -fmt=json -out=./test/lint/gosec.json ./...

File diff suppressed because it is too large Load Diff

View File

@@ -1,501 +0,0 @@
{
"swagger": "2.0",
"info": {
"title": "alipay.proto",
"version": "version not set"
},
"tags": [
{
"name": "Alipay"
},
{
"name": "Payment"
},
{
"name": "Basic"
},
{
"name": "Wechat"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
},
"walletAlipayTradeAppPayReply": {
"type": "object",
"properties": {
"payParam": {
"type": "string",
"title": "调起支付的参数"
}
}
},
"walletAlipayTradePagePayReply": {
"type": "object",
"properties": {
"payUrl": {
"type": "string",
"title": "支付链接"
}
}
},
"walletAlipayTradeWapPayReply": {
"type": "object",
"properties": {
"payUrl": {
"type": "string",
"title": "支付链接"
}
}
},
"walletAlipayUniTransferReply": {
"type": "object"
},
"walletBankCardInfo": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "int64"
},
"bankNumber": {
"type": "string",
"title": "银行卡号"
},
"bankName": {
"type": "string",
"title": "银行名"
},
"cardOwner": {
"type": "string",
"title": "持卡人姓名"
},
"idCard": {
"type": "string",
"title": "持卡人身份证号"
},
"phone": {
"type": "string",
"title": "银行预留的手机号"
},
"bindId": {
"type": "string",
"title": "绑定银行卡返回的绑定id"
},
"bankType": {
"type": "string",
"title": "银行卡类型 DC为储蓄卡CC为信用卡"
},
"bank": {
"type": "string",
"title": "银行卡所属行"
},
"created": {
"type": "string",
"title": "添加日期"
}
}
},
"walletCallBackReply": {
"type": "object",
"properties": {
"code": {
"type": "string",
"title": "错误码SUCCESS为清算机构接收成功FAIL错误码为失败。"
},
"message": {
"type": "string",
"title": "返回信息"
}
}
},
"walletGetBankCardReply": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/walletBankCardInfo"
}
}
}
},
"walletGetWalletReply": {
"type": "object",
"properties": {
"passportIdentity": {
"type": "string",
"title": "用户唯一标识"
},
"walletIdentity": {
"type": "string",
"title": "钱包唯一标识"
},
"balance": {
"type": "string",
"format": "int64",
"title": "余额"
},
"withdrawalBalance": {
"type": "string",
"format": "int64",
"title": "可提现余额"
},
"status": {
"type": "integer",
"format": "int32",
"title": "状态 -1禁用1正常"
},
"alipayId": {
"type": "string",
"title": "支付宝ID"
},
"alipayName": {
"type": "string",
"title": "支付宝账户名"
},
"wxpayId": {
"type": "string",
"title": "微信ID"
},
"wxpayName": {
"type": "string",
"title": "微信支付账户名"
},
"total": {
"type": "object",
"additionalProperties": {
"type": "string",
"format": "int64"
},
"title": "统计数据输出"
},
"created": {
"type": "string",
"title": "创建时间"
}
}
},
"walletPaymentItem": {
"type": "object",
"properties": {
"orderNo": {
"type": "string",
"title": "订单号"
},
"tradeNo": {
"type": "string",
"title": "第三方交易流水号"
},
"type": {
"type": "integer",
"format": "int32",
"title": "类型:1充值;2支付电商订单"
},
"payChannel": {
"type": "integer",
"format": "int32",
"title": "支付模型WECHATALIPAY,BALANCE"
},
"payType": {
"type": "string",
"title": "支付类型 JSAPI:微信浏览器内支付 APP:app支付 MINI:小程序 NATIVE:Native支付,pc端生成二维码供用户扫码支付,QUICK_MSECURITY_PAY:app支付 QUICK_WAP_WAY:手机网站支付 FAST_INSTANT_TRADE_PAY:pc网站支付"
},
"amount": {
"type": "string",
"format": "int64",
"title": "充值金额 单位为分"
},
"args": {
"type": "string",
"title": "相关参数"
},
"status": {
"type": "integer",
"format": "int32",
"title": "支付状态"
}
}
},
"walletPaymentReply": {
"type": "object",
"properties": {
"code": {
"type": "string",
"format": "int64"
},
"result": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"title": "预支付返回"
}
}
},
"walletStatusReply": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32",
"title": "状态码"
},
"message": {
"type": "string",
"title": "状态说明"
},
"details": {
"type": "string",
"title": "数据"
},
"timeseq": {
"type": "string",
"format": "int64",
"title": "响应时间序列"
}
}
},
"walletTransaction": {
"type": "object",
"properties": {
"transType": {
"type": "integer",
"format": "int32",
"title": "收支类型:-1支出1收入"
},
"tradeType": {
"type": "integer",
"format": "int32",
"title": "交易类型1充值2提现3消费4退款5收益"
},
"inTradeNo": {
"type": "string",
"title": "内部流水号"
},
"outTradeNo": {
"type": "string",
"title": "外部流水号eg微信、支付宝、银行等"
},
"money": {
"type": "string",
"format": "int64",
"title": "交易金额,单位:分"
},
"fee": {
"type": "string",
"format": "int64",
"title": "手续费,单位:分"
},
"payChannel": {
"type": "integer",
"format": "int32",
"title": "支付模型WECHATALIPAY,BALANCE"
},
"payType": {
"type": "string",
"title": "支付类型 JSAPI:微信浏览器内支付 APP:app支付 MINI:小程序 NATIVE:Native支付,pc端生成二维码供用户扫码支付,QUICK_MSECURITY_PAY:app支付 QUICK_WAP_WAY:手机网站支付 FAST_INSTANT_TRADE_PAY:pc网站支付"
},
"created": {
"type": "string",
"title": "创建时间"
},
"remark": {
"type": "string",
"title": "备注信息"
}
}
},
"walletTransactionsReply": {
"type": "object",
"properties": {
"total": {
"type": "string",
"format": "int64",
"title": "总记录数"
},
"records": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/walletTransaction"
},
"title": "数据"
}
}
},
"walletWayItem": {
"type": "object",
"properties": {
"ident": {
"type": "string",
"title": "支付通道标识"
},
"title": {
"type": "string",
"title": "支付通道标题"
},
"intro": {
"type": "string",
"title": "支付通道说明"
},
"args": {
"type": "string",
"title": "支付通道相关参数"
}
}
},
"walletWayReply": {
"type": "object",
"properties": {
"way": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/walletWayItem"
},
"title": "支付通道列表"
}
}
},
"walletWxCallBackResource": {
"type": "object",
"properties": {
"originalType": {
"type": "string"
},
"algorithm": {
"type": "string"
},
"ciphertext": {
"type": "string"
},
"associatedData": {
"type": "string"
},
"nonce": {
"type": "string"
}
}
},
"walletWxCallBackSignInfo": {
"type": "object",
"properties": {
"transactionId": {
"type": "string"
},
"actCode": {
"type": "string"
},
"hallCode": {
"type": "string"
},
"hallBelongMchId": {
"type": "string",
"format": "int64"
},
"cardId": {
"type": "string"
},
"code": {
"type": "string"
},
"activityId": {
"type": "string"
}
}
},
"walletWxpayAppPreOrderReply": {
"type": "object",
"properties": {
"prepayId": {
"type": "string",
"title": "预支付ID两小时有效"
},
"appId": {
"type": "string",
"title": "微信app_id"
},
"mchId": {
"type": "string",
"title": "商户号,用以调起支付"
}
}
},
"walletWxpayJSAPIPreOrderReply": {
"type": "object",
"properties": {
"prepayId": {
"type": "string",
"title": "预支付ID两小时有效"
},
"appId": {
"type": "string",
"title": "微信app_id"
},
"timestamp": {
"type": "string",
"title": "时间戳"
},
"nonceStr": {
"type": "string",
"title": "随机字符串"
},
"signType": {
"type": "string",
"title": "签名方式"
},
"sign": {
"type": "string",
"title": "签名串"
}
}
},
"walletWxpayNativePreOrderReply": {
"type": "object",
"properties": {
"codeUrl": {
"type": "string",
"title": "二维码URL"
}
}
},
"walletWxpayTransferReply": {
"type": "object"
}
}
}