add products

This commit is contained in:
2024-05-18 12:58:50 +07:00
parent afd5536246
commit 6b3306bb96
8 changed files with 389 additions and 31 deletions
+37
View File
@@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7
const (
CRM_GetCatalog_FullMethodName = "/crabs.crm.CRM/GetCatalog"
CRM_GetPositions_FullMethodName = "/crabs.crm.CRM/GetPositions"
CRM_GetProduct_FullMethodName = "/crabs.crm.CRM/GetProduct"
)
// CRMClient is the client API for CRM service.
@@ -29,6 +30,7 @@ const (
type CRMClient interface {
GetCatalog(ctx context.Context, in *GetCatalogReq, opts ...grpc.CallOption) (*CatalogRsp, error)
GetPositions(ctx context.Context, in *GetPositionsReq, opts ...grpc.CallOption) (*PositionsRsp, error)
GetProduct(ctx context.Context, in *GetProductReq, opts ...grpc.CallOption) (*ProductRsp, error)
}
type cRMClient struct {
@@ -57,12 +59,22 @@ func (c *cRMClient) GetPositions(ctx context.Context, in *GetPositionsReq, opts
return out, nil
}
func (c *cRMClient) GetProduct(ctx context.Context, in *GetProductReq, opts ...grpc.CallOption) (*ProductRsp, error) {
out := new(ProductRsp)
err := c.cc.Invoke(ctx, CRM_GetProduct_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// CRMServer is the server API for CRM service.
// All implementations must embed UnimplementedCRMServer
// for forward compatibility
type CRMServer interface {
GetCatalog(context.Context, *GetCatalogReq) (*CatalogRsp, error)
GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error)
GetProduct(context.Context, *GetProductReq) (*ProductRsp, error)
mustEmbedUnimplementedCRMServer()
}
@@ -76,6 +88,9 @@ func (UnimplementedCRMServer) GetCatalog(context.Context, *GetCatalogReq) (*Cata
func (UnimplementedCRMServer) GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetPositions not implemented")
}
func (UnimplementedCRMServer) GetProduct(context.Context, *GetProductReq) (*ProductRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetProduct not implemented")
}
func (UnimplementedCRMServer) mustEmbedUnimplementedCRMServer() {}
// UnsafeCRMServer may be embedded to opt out of forward compatibility for this service.
@@ -125,6 +140,24 @@ func _CRM_GetPositions_Handler(srv interface{}, ctx context.Context, dec func(in
return interceptor(ctx, in, info, handler)
}
func _CRM_GetProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetProductReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CRMServer).GetProduct(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: CRM_GetProduct_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CRMServer).GetProduct(ctx, req.(*GetProductReq))
}
return interceptor(ctx, in, info, handler)
}
// CRM_ServiceDesc is the grpc.ServiceDesc for CRM service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -140,6 +173,10 @@ var CRM_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetPositions",
Handler: _CRM_GetPositions_Handler,
},
{
MethodName: "GetProduct",
Handler: _CRM_GetProduct_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "main.proto",