添加购物车查询商品主图片

master
shenzhuan 2 years ago
parent 094936ba93
commit 781eec64cd

@ -19,6 +19,7 @@ type IProductRepository interface {
Page(int32, int32) (int64, *[]model.Product, error) Page(int32, int32) (int64, *[]model.Product, error)
ShowProductDetail(int32) (*model.ProductDetail, error) ShowProductDetail(int32) (*model.ProductDetail, error)
ShowProductSku(int32) (*[]model.ProductSku, error) ShowProductSku(int32) (*[]model.ProductSku, error)
ShowDetailSku(int32) (*model.ProductSku, error)
CountNum() int64 CountNum() int64
} }
@ -84,3 +85,10 @@ func (u *ProductRepository) ShowProductSku(id int32) (product *[]model.ProductSk
fmt.Println("repository ShowProductSku >>>> ", productSku) fmt.Println("repository ShowProductSku >>>> ", productSku)
return &productSku, nil return &productSku, nil
} }
func (u *ProductRepository) ShowDetailSku(id int32) (obj *model.ProductSku, err error) {
var productSku = &model.ProductSku{}
u.mysqlDB.Where("id = ?", id).Find(&productSku)
fmt.Println("repository ShowDetailSku >>>> ", productSku)
return productSku, nil
}

@ -9,6 +9,8 @@ type IProductDataService interface {
Page(int32, int32) (count int64, products *[]model.Product, err error) Page(int32, int32) (count int64, products *[]model.Product, err error)
ShowProductDetail(int32) (obj *model.ProductDetail, err error) ShowProductDetail(int32) (obj *model.ProductDetail, err error)
ShowProductSku(int32) (obj *[]model.ProductSku, err error) ShowProductSku(int32) (obj *[]model.ProductSku, err error)
ShowDetailSku(int32) (obj *model.ProductSku, err error)
CountNum() int64 CountNum() int64
} }
type ProductDataService struct { type ProductDataService struct {
@ -38,3 +40,7 @@ func (u *ProductDataService) ShowProductSku(id int32) (product *[]model.ProductS
return u.productRepository.ShowProductSku(id) return u.productRepository.ShowProductSku(id)
} }
func (u *ProductDataService) ShowDetailSku(id int32) (product *model.ProductSku, err error) {
return u.productRepository.ShowDetailSku(id)
}

@ -71,7 +71,7 @@ func (u *ProductHandler) ShowProductDetail(ctx context.Context, req *proto.Produ
return nil return nil
} }
// 商品SKU // 商品SKU列表
func (u *ProductHandler) ShowProductSku(ctx context.Context, req *proto.ProductSkuReq, resp *proto.ProductSkuResp) error { func (u *ProductHandler) ShowProductSku(ctx context.Context, req *proto.ProductSkuReq, resp *proto.ProductSkuResp) error {
//count := u.ProductDataService.CountNum() //count := u.ProductDataService.CountNum()
obj, err := u.ProductDataService.ShowProductSku(req.GetProductId()) obj, err := u.ProductDataService.ShowProductSku(req.GetProductId())
@ -87,12 +87,28 @@ func (u *ProductHandler) ShowProductSku(ctx context.Context, req *proto.ProductS
func ObjSkuForResp(obj *[]model.ProductSku, resp *proto.ProductSkuResp) (err error) { func ObjSkuForResp(obj *[]model.ProductSku, resp *proto.ProductSkuResp) (err error) {
for _, v := range *obj { for _, v := range *obj {
product := &proto.ProductSku{} productSku := &proto.ProductSku{}
err := common.SwapToStruct(v, product) err := common.SwapToStruct(v, productSku)
if err != nil { if err != nil {
return err return err
} }
resp.ProductSku = append(resp.ProductSku, product) resp.ProductSku = append(resp.ProductSku, productSku)
}
return nil
}
// 商品SKU详情
func (u *ProductHandler) ShowDetailSku(ctx context.Context, req *proto.ProductDetailReq, resp *proto.ProductSkuResp) error {
//count := u.ProductDataService.CountNum()
obj, err := u.ProductDataService.ShowDetailSku(req.Id)
if err != nil {
println("ShowDetailSku err :", err)
}
productSku := &proto.ProductSku{}
err = common.SwapToStruct(obj, productSku)
if err != nil {
return err
} }
resp.ProductSku = append(resp.ProductSku, productSku)
return nil return nil
} }

@ -58,7 +58,7 @@ func main() {
proto.RegisterPageHandler(repcService.Server(), &handler.ProductHandler{productDataService}) proto.RegisterPageHandler(repcService.Server(), &handler.ProductHandler{productDataService})
proto.RegisterShowProductDetailHandler(repcService.Server(), &handler.ProductHandler{productDataService}) proto.RegisterShowProductDetailHandler(repcService.Server(), &handler.ProductHandler{productDataService})
proto.RegisterShowProductSkuHandler(repcService.Server(), &handler.ProductHandler{productDataService}) proto.RegisterShowProductSkuHandler(repcService.Server(), &handler.ProductHandler{productDataService})
proto.RegisterShowDetailSkuHandler(repcService.Server(), &handler.ProductHandler{productDataService})
//5.启动服务 //5.启动服务
if err := repcService.Run(); err != nil { if err := repcService.Run(); err != nil {
log.Println("start user service err :", err) log.Println("start user service err :", err)

@ -11,6 +11,10 @@
package proto package proto
import ( import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
@ -854,8 +858,13 @@ var file_product_proto_rawDesc = []byte{
0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50,
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52,
0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74,
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65,
0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71,
0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -891,11 +900,13 @@ var file_product_proto_depIdxs = []int32{
1, // 4: proto.Page.Page:input_type -> proto.PageReq 1, // 4: proto.Page.Page:input_type -> proto.PageReq
4, // 5: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq 4, // 5: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq
7, // 6: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq 7, // 6: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq
2, // 7: proto.Page.Page:output_type -> proto.PageResp 4, // 7: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq
5, // 8: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp 2, // 8: proto.Page.Page:output_type -> proto.PageResp
8, // 9: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp 5, // 9: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp
7, // [7:10] is the sub-list for method output_type 8, // 10: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp
4, // [4:7] is the sub-list for method input_type 8, // 11: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp
8, // [8:12] is the sub-list for method output_type
4, // [4:8] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee 4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name 0, // [0:4] is the sub-list for field type_name
@ -1024,7 +1035,7 @@ func file_product_proto_init() {
NumEnums: 0, NumEnums: 0,
NumMessages: 10, NumMessages: 10,
NumExtensions: 0, NumExtensions: 0,
NumServices: 3, NumServices: 4,
}, },
GoTypes: file_product_proto_goTypes, GoTypes: file_product_proto_goTypes,
DependencyIndexes: file_product_proto_depIdxs, DependencyIndexes: file_product_proto_depIdxs,
@ -1035,3 +1046,307 @@ func file_product_proto_init() {
file_product_proto_goTypes = nil file_product_proto_goTypes = nil
file_product_proto_depIdxs = nil file_product_proto_depIdxs = nil
} }
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// PageClient is the client API for Page service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type PageClient interface {
// rpc 服务
Page(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*PageResp, error)
}
type pageClient struct {
cc grpc.ClientConnInterface
}
func NewPageClient(cc grpc.ClientConnInterface) PageClient {
return &pageClient{cc}
}
func (c *pageClient) Page(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*PageResp, error) {
out := new(PageResp)
err := c.cc.Invoke(ctx, "/proto.Page/Page", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// PageServer is the server API for Page service.
type PageServer interface {
// rpc 服务
Page(context.Context, *PageReq) (*PageResp, error)
}
// UnimplementedPageServer can be embedded to have forward compatible implementations.
type UnimplementedPageServer struct {
}
func (*UnimplementedPageServer) Page(context.Context, *PageReq) (*PageResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Page not implemented")
}
func RegisterPageServer(s *grpc.Server, srv PageServer) {
s.RegisterService(&_Page_serviceDesc, srv)
}
func _Page_Page_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PageReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PageServer).Page(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.Page/Page",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PageServer).Page(ctx, req.(*PageReq))
}
return interceptor(ctx, in, info, handler)
}
var _Page_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.Page",
HandlerType: (*PageServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Page",
Handler: _Page_Page_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}
// ShowProductDetailClient is the client API for ShowProductDetail service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowProductDetailClient interface {
// rpc 服务
ShowProductDetail(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductDetailResp, error)
}
type showProductDetailClient struct {
cc grpc.ClientConnInterface
}
func NewShowProductDetailClient(cc grpc.ClientConnInterface) ShowProductDetailClient {
return &showProductDetailClient{cc}
}
func (c *showProductDetailClient) ShowProductDetail(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductDetailResp, error) {
out := new(ProductDetailResp)
err := c.cc.Invoke(ctx, "/proto.ShowProductDetail/ShowProductDetail", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowProductDetailServer is the server API for ShowProductDetail service.
type ShowProductDetailServer interface {
// rpc 服务
ShowProductDetail(context.Context, *ProductDetailReq) (*ProductDetailResp, error)
}
// UnimplementedShowProductDetailServer can be embedded to have forward compatible implementations.
type UnimplementedShowProductDetailServer struct {
}
func (*UnimplementedShowProductDetailServer) ShowProductDetail(context.Context, *ProductDetailReq) (*ProductDetailResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowProductDetail not implemented")
}
func RegisterShowProductDetailServer(s *grpc.Server, srv ShowProductDetailServer) {
s.RegisterService(&_ShowProductDetail_serviceDesc, srv)
}
func _ShowProductDetail_ShowProductDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductDetailReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowProductDetailServer).ShowProductDetail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowProductDetail/ShowProductDetail",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowProductDetailServer).ShowProductDetail(ctx, req.(*ProductDetailReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowProductDetail_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowProductDetail",
HandlerType: (*ShowProductDetailServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowProductDetail",
Handler: _ShowProductDetail_ShowProductDetail_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}
// ShowProductSkuClient is the client API for ShowProductSku service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowProductSkuClient interface {
// rpc 服务
ShowProductSku(ctx context.Context, in *ProductSkuReq, opts ...grpc.CallOption) (*ProductSkuResp, error)
}
type showProductSkuClient struct {
cc grpc.ClientConnInterface
}
func NewShowProductSkuClient(cc grpc.ClientConnInterface) ShowProductSkuClient {
return &showProductSkuClient{cc}
}
func (c *showProductSkuClient) ShowProductSku(ctx context.Context, in *ProductSkuReq, opts ...grpc.CallOption) (*ProductSkuResp, error) {
out := new(ProductSkuResp)
err := c.cc.Invoke(ctx, "/proto.ShowProductSku/ShowProductSku", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowProductSkuServer is the server API for ShowProductSku service.
type ShowProductSkuServer interface {
// rpc 服务
ShowProductSku(context.Context, *ProductSkuReq) (*ProductSkuResp, error)
}
// UnimplementedShowProductSkuServer can be embedded to have forward compatible implementations.
type UnimplementedShowProductSkuServer struct {
}
func (*UnimplementedShowProductSkuServer) ShowProductSku(context.Context, *ProductSkuReq) (*ProductSkuResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowProductSku not implemented")
}
func RegisterShowProductSkuServer(s *grpc.Server, srv ShowProductSkuServer) {
s.RegisterService(&_ShowProductSku_serviceDesc, srv)
}
func _ShowProductSku_ShowProductSku_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductSkuReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowProductSkuServer).ShowProductSku(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowProductSku/ShowProductSku",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowProductSkuServer).ShowProductSku(ctx, req.(*ProductSkuReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowProductSku_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowProductSku",
HandlerType: (*ShowProductSkuServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowProductSku",
Handler: _ShowProductSku_ShowProductSku_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}
// ShowDetailSkuClient is the client API for ShowDetailSku service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowDetailSkuClient interface {
// rpc 服务
ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductSkuResp, error)
}
type showDetailSkuClient struct {
cc grpc.ClientConnInterface
}
func NewShowDetailSkuClient(cc grpc.ClientConnInterface) ShowDetailSkuClient {
return &showDetailSkuClient{cc}
}
func (c *showDetailSkuClient) ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductSkuResp, error) {
out := new(ProductSkuResp)
err := c.cc.Invoke(ctx, "/proto.ShowDetailSku/ShowDetailSku", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowDetailSkuServer is the server API for ShowDetailSku service.
type ShowDetailSkuServer interface {
// rpc 服务
ShowDetailSku(context.Context, *ProductDetailReq) (*ProductSkuResp, error)
}
// UnimplementedShowDetailSkuServer can be embedded to have forward compatible implementations.
type UnimplementedShowDetailSkuServer struct {
}
func (*UnimplementedShowDetailSkuServer) ShowDetailSku(context.Context, *ProductDetailReq) (*ProductSkuResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowDetailSku not implemented")
}
func RegisterShowDetailSkuServer(s *grpc.Server, srv ShowDetailSkuServer) {
s.RegisterService(&_ShowDetailSku_serviceDesc, srv)
}
func _ShowDetailSku_ShowDetailSku_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductDetailReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowDetailSkuServer).ShowDetailSku(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowDetailSku/ShowDetailSku",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowDetailSkuServer).ShowDetailSku(ctx, req.(*ProductDetailReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowDetailSku_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowDetailSku",
HandlerType: (*ShowDetailSkuServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowDetailSku",
Handler: _ShowDetailSku_ShowDetailSku_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "product.proto",
}

@ -209,3 +209,64 @@ type showProductSkuHandler struct {
func (h *showProductSkuHandler) ShowProductSku(ctx context.Context, in *ProductSkuReq, out *ProductSkuResp) error { func (h *showProductSkuHandler) ShowProductSku(ctx context.Context, in *ProductSkuReq, out *ProductSkuResp) error {
return h.ShowProductSkuHandler.ShowProductSku(ctx, in, out) return h.ShowProductSkuHandler.ShowProductSku(ctx, in, out)
} }
// Api Endpoints for ShowDetailSku service
func NewShowDetailSkuEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for ShowDetailSku service
type ShowDetailSkuService interface {
// rpc 服务
ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...client.CallOption) (*ProductSkuResp, error)
}
type showDetailSkuService struct {
c client.Client
name string
}
func NewShowDetailSkuService(name string, c client.Client) ShowDetailSkuService {
return &showDetailSkuService{
c: c,
name: name,
}
}
func (c *showDetailSkuService) ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...client.CallOption) (*ProductSkuResp, error) {
req := c.c.NewRequest(c.name, "ShowDetailSku.ShowDetailSku", in)
out := new(ProductSkuResp)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for ShowDetailSku service
type ShowDetailSkuHandler interface {
// rpc 服务
ShowDetailSku(context.Context, *ProductDetailReq, *ProductSkuResp) error
}
func RegisterShowDetailSkuHandler(s server.Server, hdlr ShowDetailSkuHandler, opts ...server.HandlerOption) error {
type showDetailSku interface {
ShowDetailSku(ctx context.Context, in *ProductDetailReq, out *ProductSkuResp) error
}
type ShowDetailSku struct {
showDetailSku
}
h := &showDetailSkuHandler{hdlr}
return s.Handle(s.NewHandler(&ShowDetailSku{h}, opts...))
}
type showDetailSkuHandler struct {
ShowDetailSkuHandler
}
func (h *showDetailSkuHandler) ShowDetailSku(ctx context.Context, in *ProductDetailReq, out *ProductSkuResp) error {
return h.ShowDetailSkuHandler.ShowDetailSku(ctx, in, out)
}

@ -144,3 +144,9 @@ service ShowProductSku {
//rpc //rpc
rpc ShowProductSku (ProductSkuReq) returns (ProductSkuResp){} rpc ShowProductSku (ProductSkuReq) returns (ProductSkuResp){}
} }
//
service ShowDetailSku {
//rpc
rpc ShowDetailSku (ProductDetailReq) returns (ProductSkuResp){}
}

@ -11,6 +11,10 @@
package proto package proto
import ( import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
@ -416,3 +420,85 @@ func file_user_proto_init() {
file_user_proto_goTypes = nil file_user_proto_goTypes = nil
file_user_proto_depIdxs = nil file_user_proto_depIdxs = nil
} }
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// LoginClient is the client API for Login service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type LoginClient interface {
// rpc 服务
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResp, error)
}
type loginClient struct {
cc grpc.ClientConnInterface
}
func NewLoginClient(cc grpc.ClientConnInterface) LoginClient {
return &loginClient{cc}
}
func (c *loginClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResp, error) {
out := new(LoginResp)
err := c.cc.Invoke(ctx, "/proto.Login/Login", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// LoginServer is the server API for Login service.
type LoginServer interface {
// rpc 服务
Login(context.Context, *LoginRequest) (*LoginResp, error)
}
// UnimplementedLoginServer can be embedded to have forward compatible implementations.
type UnimplementedLoginServer struct {
}
func (*UnimplementedLoginServer) Login(context.Context, *LoginRequest) (*LoginResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func RegisterLoginServer(s *grpc.Server, srv LoginServer) {
s.RegisterService(&_Login_serviceDesc, srv)
}
func _Login_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LoginServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.Login/Login",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LoginServer).Login(ctx, req.(*LoginRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Login_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.Login",
HandlerType: (*LoginServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Login",
Handler: _Login_Login_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "user.proto",
}

@ -59,6 +59,7 @@ func main() {
) )
client := proto.NewAddCartService("shop-cart", rpcServer.Client()) client := proto.NewAddCartService("shop-cart", rpcServer.Client())
clientA := proto.NewShowProductDetailService("shop-product", rpcServer.Client()) clientA := proto.NewShowProductDetailService("shop-product", rpcServer.Client())
clientB := proto.NewShowDetailSkuService("shop-product", rpcServer.Client())
//分页查询商品列表 //分页查询商品列表
router.GET("/increase", func(c *gin.Context) { router.GET("/increase", func(c *gin.Context) {
// "number": 0, // "number": 0,
@ -78,7 +79,6 @@ func main() {
reqDetail := &proto.ProductDetailReq{ reqDetail := &proto.ProductDetailReq{
Id: int32(productId), Id: int32(productId),
} }
//
respDetail, err := clientA.ShowProductDetail(context.TODO(), reqDetail) respDetail, err := clientA.ShowProductDetail(context.TODO(), reqDetail)
if respDetail != nil { if respDetail != nil {
req.ProductName = respDetail.ProductDetail[0].Name req.ProductName = respDetail.ProductDetail[0].Name
@ -86,11 +86,26 @@ func main() {
} }
log.Println(" /ShowProductDetail resp :", respDetail) log.Println(" /ShowProductDetail resp :", respDetail)
//SKU //SKU详情
reqDetail.Id = req.ProductSkuId
respSkuDetail, err := clientB.ShowDetailSku(context.TODO(), reqDetail)
log.Println(" /ShowDetailSku resp :", respSkuDetail)
//添加购物车 远程调用服务 //添加购物车 远程调用服务
log.Println(" /AddCart req :", req) log.Println(" /AddCart req :", req)
if respSkuDetail.ProductSku[0].Stock < req.Number {
common.RespFail(c.Writer, &proto.AddCartResp{}, "库存不足,添加失败")
return
}
resp, err := client.AddCart(context.TODO(), req) resp, err := client.AddCart(context.TODO(), req)
resp.ProductSkuSimple = respSkuDetail.ProductSku[0]
resp.ProductSimple = respDetail.ProductDetail[0]
log.Println(" /AddCart resp :", resp) log.Println(" /AddCart resp :", resp)
//根据响应做输出 //根据响应做输出
if err != nil { if err != nil {
log.Println(err.Error()) log.Println(err.Error())

@ -11,10 +11,6 @@
package proto package proto
import ( import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect" reflect "reflect"
@ -1193,8 +1189,14 @@ var file_cart_proto_rawDesc = []byte{
0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75,
0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64,
0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d,
0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a,
0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65,
0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00,
0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@ -1236,12 +1238,14 @@ var file_cart_proto_depIdxs = []int32{
4, // 7: proto.Page.Page:input_type -> proto.PageReq 4, // 7: proto.Page.Page:input_type -> proto.PageReq
7, // 8: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq 7, // 8: proto.ShowProductDetail.ShowProductDetail:input_type -> proto.ProductDetailReq
10, // 9: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq 10, // 9: proto.ShowProductSku.ShowProductSku:input_type -> proto.ProductSkuReq
2, // 10: proto.AddCart.AddCart:output_type -> proto.AddCartResp 7, // 10: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq
5, // 11: proto.Page.Page:output_type -> proto.PageResp 2, // 11: proto.AddCart.AddCart:output_type -> proto.AddCartResp
8, // 12: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp 5, // 12: proto.Page.Page:output_type -> proto.PageResp
11, // 13: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp 8, // 13: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp
10, // [10:14] is the sub-list for method output_type 11, // 14: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp
6, // [6:10] is the sub-list for method input_type 11, // 15: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp
11, // [11:16] is the sub-list for method output_type
6, // [6:11] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name 6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee 6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name 0, // [0:6] is the sub-list for field type_name
@ -1406,7 +1410,7 @@ func file_cart_proto_init() {
NumEnums: 0, NumEnums: 0,
NumMessages: 13, NumMessages: 13,
NumExtensions: 0, NumExtensions: 0,
NumServices: 4, NumServices: 5,
}, },
GoTypes: file_cart_proto_goTypes, GoTypes: file_cart_proto_goTypes,
DependencyIndexes: file_cart_proto_depIdxs, DependencyIndexes: file_cart_proto_depIdxs,
@ -1417,307 +1421,3 @@ func file_cart_proto_init() {
file_cart_proto_goTypes = nil file_cart_proto_goTypes = nil
file_cart_proto_depIdxs = nil file_cart_proto_depIdxs = nil
} }
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// AddCartClient is the client API for AddCart service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type AddCartClient interface {
//rpc 服务
AddCart(ctx context.Context, in *AddCartReq, opts ...grpc.CallOption) (*AddCartResp, error)
}
type addCartClient struct {
cc grpc.ClientConnInterface
}
func NewAddCartClient(cc grpc.ClientConnInterface) AddCartClient {
return &addCartClient{cc}
}
func (c *addCartClient) AddCart(ctx context.Context, in *AddCartReq, opts ...grpc.CallOption) (*AddCartResp, error) {
out := new(AddCartResp)
err := c.cc.Invoke(ctx, "/proto.AddCart/AddCart", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AddCartServer is the server API for AddCart service.
type AddCartServer interface {
//rpc 服务
AddCart(context.Context, *AddCartReq) (*AddCartResp, error)
}
// UnimplementedAddCartServer can be embedded to have forward compatible implementations.
type UnimplementedAddCartServer struct {
}
func (*UnimplementedAddCartServer) AddCart(context.Context, *AddCartReq) (*AddCartResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddCart not implemented")
}
func RegisterAddCartServer(s *grpc.Server, srv AddCartServer) {
s.RegisterService(&_AddCart_serviceDesc, srv)
}
func _AddCart_AddCart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddCartReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AddCartServer).AddCart(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.AddCart/AddCart",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AddCartServer).AddCart(ctx, req.(*AddCartReq))
}
return interceptor(ctx, in, info, handler)
}
var _AddCart_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.AddCart",
HandlerType: (*AddCartServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "AddCart",
Handler: _AddCart_AddCart_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cart.proto",
}
// PageClient is the client API for Page service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type PageClient interface {
//rpc 服务
Page(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*PageResp, error)
}
type pageClient struct {
cc grpc.ClientConnInterface
}
func NewPageClient(cc grpc.ClientConnInterface) PageClient {
return &pageClient{cc}
}
func (c *pageClient) Page(ctx context.Context, in *PageReq, opts ...grpc.CallOption) (*PageResp, error) {
out := new(PageResp)
err := c.cc.Invoke(ctx, "/proto.Page/Page", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// PageServer is the server API for Page service.
type PageServer interface {
//rpc 服务
Page(context.Context, *PageReq) (*PageResp, error)
}
// UnimplementedPageServer can be embedded to have forward compatible implementations.
type UnimplementedPageServer struct {
}
func (*UnimplementedPageServer) Page(context.Context, *PageReq) (*PageResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method Page not implemented")
}
func RegisterPageServer(s *grpc.Server, srv PageServer) {
s.RegisterService(&_Page_serviceDesc, srv)
}
func _Page_Page_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PageReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(PageServer).Page(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.Page/Page",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(PageServer).Page(ctx, req.(*PageReq))
}
return interceptor(ctx, in, info, handler)
}
var _Page_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.Page",
HandlerType: (*PageServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Page",
Handler: _Page_Page_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cart.proto",
}
// ShowProductDetailClient is the client API for ShowProductDetail service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowProductDetailClient interface {
//rpc 服务
ShowProductDetail(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductDetailResp, error)
}
type showProductDetailClient struct {
cc grpc.ClientConnInterface
}
func NewShowProductDetailClient(cc grpc.ClientConnInterface) ShowProductDetailClient {
return &showProductDetailClient{cc}
}
func (c *showProductDetailClient) ShowProductDetail(ctx context.Context, in *ProductDetailReq, opts ...grpc.CallOption) (*ProductDetailResp, error) {
out := new(ProductDetailResp)
err := c.cc.Invoke(ctx, "/proto.ShowProductDetail/ShowProductDetail", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowProductDetailServer is the server API for ShowProductDetail service.
type ShowProductDetailServer interface {
//rpc 服务
ShowProductDetail(context.Context, *ProductDetailReq) (*ProductDetailResp, error)
}
// UnimplementedShowProductDetailServer can be embedded to have forward compatible implementations.
type UnimplementedShowProductDetailServer struct {
}
func (*UnimplementedShowProductDetailServer) ShowProductDetail(context.Context, *ProductDetailReq) (*ProductDetailResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowProductDetail not implemented")
}
func RegisterShowProductDetailServer(s *grpc.Server, srv ShowProductDetailServer) {
s.RegisterService(&_ShowProductDetail_serviceDesc, srv)
}
func _ShowProductDetail_ShowProductDetail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductDetailReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowProductDetailServer).ShowProductDetail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowProductDetail/ShowProductDetail",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowProductDetailServer).ShowProductDetail(ctx, req.(*ProductDetailReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowProductDetail_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowProductDetail",
HandlerType: (*ShowProductDetailServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowProductDetail",
Handler: _ShowProductDetail_ShowProductDetail_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cart.proto",
}
// ShowProductSkuClient is the client API for ShowProductSku service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ShowProductSkuClient interface {
//rpc 服务
ShowProductSku(ctx context.Context, in *ProductSkuReq, opts ...grpc.CallOption) (*ProductSkuResp, error)
}
type showProductSkuClient struct {
cc grpc.ClientConnInterface
}
func NewShowProductSkuClient(cc grpc.ClientConnInterface) ShowProductSkuClient {
return &showProductSkuClient{cc}
}
func (c *showProductSkuClient) ShowProductSku(ctx context.Context, in *ProductSkuReq, opts ...grpc.CallOption) (*ProductSkuResp, error) {
out := new(ProductSkuResp)
err := c.cc.Invoke(ctx, "/proto.ShowProductSku/ShowProductSku", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ShowProductSkuServer is the server API for ShowProductSku service.
type ShowProductSkuServer interface {
//rpc 服务
ShowProductSku(context.Context, *ProductSkuReq) (*ProductSkuResp, error)
}
// UnimplementedShowProductSkuServer can be embedded to have forward compatible implementations.
type UnimplementedShowProductSkuServer struct {
}
func (*UnimplementedShowProductSkuServer) ShowProductSku(context.Context, *ProductSkuReq) (*ProductSkuResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ShowProductSku not implemented")
}
func RegisterShowProductSkuServer(s *grpc.Server, srv ShowProductSkuServer) {
s.RegisterService(&_ShowProductSku_serviceDesc, srv)
}
func _ShowProductSku_ShowProductSku_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ProductSkuReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ShowProductSkuServer).ShowProductSku(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/proto.ShowProductSku/ShowProductSku",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ShowProductSkuServer).ShowProductSku(ctx, req.(*ProductSkuReq))
}
return interceptor(ctx, in, info, handler)
}
var _ShowProductSku_serviceDesc = grpc.ServiceDesc{
ServiceName: "proto.ShowProductSku",
HandlerType: (*ShowProductSkuServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ShowProductSku",
Handler: _ShowProductSku_ShowProductSku_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cart.proto",
}

@ -270,3 +270,64 @@ type showProductSkuHandler struct {
func (h *showProductSkuHandler) ShowProductSku(ctx context.Context, in *ProductSkuReq, out *ProductSkuResp) error { func (h *showProductSkuHandler) ShowProductSku(ctx context.Context, in *ProductSkuReq, out *ProductSkuResp) error {
return h.ShowProductSkuHandler.ShowProductSku(ctx, in, out) return h.ShowProductSkuHandler.ShowProductSku(ctx, in, out)
} }
// Api Endpoints for ShowDetailSku service
func NewShowDetailSkuEndpoints() []*api.Endpoint {
return []*api.Endpoint{}
}
// Client API for ShowDetailSku service
type ShowDetailSkuService interface {
// rpc 服务
ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...client.CallOption) (*ProductSkuResp, error)
}
type showDetailSkuService struct {
c client.Client
name string
}
func NewShowDetailSkuService(name string, c client.Client) ShowDetailSkuService {
return &showDetailSkuService{
c: c,
name: name,
}
}
func (c *showDetailSkuService) ShowDetailSku(ctx context.Context, in *ProductDetailReq, opts ...client.CallOption) (*ProductSkuResp, error) {
req := c.c.NewRequest(c.name, "ShowDetailSku.ShowDetailSku", in)
out := new(ProductSkuResp)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for ShowDetailSku service
type ShowDetailSkuHandler interface {
// rpc 服务
ShowDetailSku(context.Context, *ProductDetailReq, *ProductSkuResp) error
}
func RegisterShowDetailSkuHandler(s server.Server, hdlr ShowDetailSkuHandler, opts ...server.HandlerOption) error {
type showDetailSku interface {
ShowDetailSku(ctx context.Context, in *ProductDetailReq, out *ProductSkuResp) error
}
type ShowDetailSku struct {
showDetailSku
}
h := &showDetailSkuHandler{hdlr}
return s.Handle(s.NewHandler(&ShowDetailSku{h}, opts...))
}
type showDetailSkuHandler struct {
ShowDetailSkuHandler
}
func (h *showDetailSkuHandler) ShowDetailSku(ctx context.Context, in *ProductDetailReq, out *ProductSkuResp) error {
return h.ShowDetailSkuHandler.ShowDetailSku(ctx, in, out)
}

@ -209,3 +209,8 @@ service ShowProductSku {
//rpc //rpc
rpc ShowProductSku (ProductSkuReq) returns (ProductSkuResp){} rpc ShowProductSku (ProductSkuReq) returns (ProductSkuResp){}
} }
//
service ShowDetailSku {
//rpc
rpc ShowDetailSku (ProductDetailReq) returns (ProductSkuResp){}
}

Loading…
Cancel
Save