2026-08-09 10:43:45 +08:00
|
|
|
// Code generated by protoc-gen-slc. DO NOT EDIT.
|
|
|
|
|
package server
|
|
|
|
|
|
|
|
|
|
import (
|
2026-08-09 12:41:08 +08:00
|
|
|
pb "bsm/full/module/ec/mall/pb"
|
2026-08-09 20:14:57 +08:00
|
|
|
"context"
|
|
|
|
|
|
2026-08-09 10:43:45 +08:00
|
|
|
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
"google.golang.org/grpc/reflection"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Server struct {
|
2026-08-09 20:14:57 +08:00
|
|
|
Grpc *grpc.Server
|
|
|
|
|
Ctx context.Context
|
|
|
|
|
Mux *gwRuntime.ServeMux
|
|
|
|
|
grpcConns map[string]*grpc.ClientConn // 连接池
|
2026-08-09 10:43:45 +08:00
|
|
|
}
|
|
|
|
|
|
2026-08-10 10:03:46 +08:00
|
|
|
func New(grpcServ *grpc.Server) *Server {
|
|
|
|
|
standalone := grpcServ == nil
|
|
|
|
|
if standalone {
|
|
|
|
|
grpcServ = grpc.NewServer()
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-09 20:14:57 +08:00
|
|
|
srv := &Server{
|
|
|
|
|
Ctx: context.Background(),
|
2026-08-10 10:03:46 +08:00
|
|
|
Grpc: grpcServ,
|
2026-08-09 20:14:57 +08:00
|
|
|
grpcConns: make(map[string]*grpc.ClientConn),
|
|
|
|
|
}
|
2026-08-09 10:43:45 +08:00
|
|
|
|
|
|
|
|
// register service to grpc.Server
|
|
|
|
|
pb.RegisterAdsServer(srv.Grpc, NewAdsServer())
|
|
|
|
|
pb.RegisterCategoryServer(srv.Grpc, NewCategoryServer())
|
|
|
|
|
pb.RegisterFreightServer(srv.Grpc, NewFreightServer())
|
|
|
|
|
pb.RegisterNoticeServer(srv.Grpc, NewNoticeServer())
|
|
|
|
|
pb.RegisterProductServer(srv.Grpc, NewProductServer())
|
|
|
|
|
pb.RegisterStaffServer(srv.Grpc, NewStaffServer())
|
|
|
|
|
pb.RegisterStoreServer(srv.Grpc, NewStoreServer())
|
|
|
|
|
|
2026-08-10 10:03:46 +08:00
|
|
|
if standalone {
|
|
|
|
|
reflection.Register(srv.Grpc)
|
|
|
|
|
}
|
2026-08-09 10:43:45 +08:00
|
|
|
|
|
|
|
|
return srv
|
|
|
|
|
}
|