Compare commits
2 Commits
afd5536246
...
db4419dc81
Author | SHA1 | Date |
---|---|---|
Владимир Фёдоров | db4419dc81 | |
Владимир Фёдоров | 6b3306bb96 |
3
Makefile
3
Makefile
|
@ -8,3 +8,6 @@ generate:
|
||||||
--grpc-gateway_out ./proto --grpc-gateway_opt paths=source_relative \
|
--grpc-gateway_out ./proto --grpc-gateway_opt paths=source_relative \
|
||||||
--swagger_out=allow_merge=true,merge_file_name=main:./proto \
|
--swagger_out=allow_merge=true,merge_file_name=main:./proto \
|
||||||
./api/main.proto
|
./api/main.proto
|
||||||
|
|
||||||
|
run:
|
||||||
|
go run ./cmd/cake_crm/main.go
|
||||||
|
|
|
@ -17,6 +17,16 @@ service CRM {
|
||||||
get: "/positions/{id}"
|
get: "/positions/{id}"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
rpc GetProduct(GetProductReq) returns (ProductRsp) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/products/{id}"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
rpc GetBreadcrumbs(GetBreadcrumbsReq) returns (BreadcrumbsRsp) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
get: "/breadcrumbs/{id}"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetCatalogReq {}
|
message GetCatalogReq {}
|
||||||
|
@ -75,3 +85,19 @@ message Characteristic {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
string value = 2;
|
string value = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetProductReq {
|
||||||
|
int64 id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ProductRsp {
|
||||||
|
Product product = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetBreadcrumbsReq {
|
||||||
|
int64 id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BreadcrumbsRsp {
|
||||||
|
repeated Category categories = 1;
|
||||||
|
}
|
||||||
|
|
|
@ -32,3 +32,19 @@ func (s *Server) GetPositions(ctx context.Context, req *crm.GetPositionsReq) (*c
|
||||||
}
|
}
|
||||||
return &crm.PositionsRsp{Products: products}, nil
|
return &crm.PositionsRsp{Products: products}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetProduct(ctx context.Context, req *crm.GetProductReq) (*crm.ProductRsp, error) {
|
||||||
|
product, err := s.storage.GetProduct(ctx, req.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &crm.ProductRsp{Product: product}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) GetBreadcrumbs(ctx context.Context, req *crm.GetBreadcrumbsReq) (*crm.BreadcrumbsRsp, error) {
|
||||||
|
breadcrumbs, err := s.storage.GetBreadcrumbs(ctx, req.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &crm.BreadcrumbsRsp{Categories: breadcrumbs}, nil
|
||||||
|
}
|
||||||
|
|
|
@ -5,18 +5,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Product struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
// todo
|
|
||||||
}
|
|
||||||
|
|
||||||
type Breadcrumb struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
URL string `json:"url"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type IStorage interface {
|
type IStorage interface {
|
||||||
GetCatalog(ctx context.Context) ([]*crm.Category, error)
|
GetCatalog(ctx context.Context) ([]*crm.Category, error)
|
||||||
GetPositions(ctx context.Context, id int64) ([]*crm.Product, error)
|
GetPositions(ctx context.Context, id int64) ([]*crm.Product, error)
|
||||||
|
GetProduct(ctx context.Context, id int64) (*crm.Product, error)
|
||||||
|
GetBreadcrumbs(ctx context.Context, id int64) ([]*crm.Category, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,14 @@ import (
|
||||||
crm "cake_crm/proto"
|
crm "cake_crm/proto"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrProductNotFound = errors.New("product not found")
|
||||||
|
)
|
||||||
|
|
||||||
type storageFile struct{}
|
type storageFile struct{}
|
||||||
|
|
||||||
func NewStorageFile() storage.IStorage {
|
func NewStorageFile() storage.IStorage {
|
||||||
|
@ -43,3 +48,50 @@ func (s *storageFile) GetPositions(_ context.Context, id int64) ([]*crm.Product,
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *storageFile) GetProduct(_ context.Context, id int64) (*crm.Product, error) {
|
||||||
|
data, err := os.ReadFile("resources/products.json")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var products []*crm.Product
|
||||||
|
if err := json.Unmarshal(data, &products); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, product := range products {
|
||||||
|
if product.Id == id {
|
||||||
|
return product, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, ErrProductNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *storageFile) GetBreadcrumbs(_ context.Context, id int64) ([]*crm.Category, error) {
|
||||||
|
data, err := os.ReadFile("resources/catalog.json")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var categories []*crm.Category
|
||||||
|
if err := json.Unmarshal(data, &categories); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return getBreadcrumbs(categories, id), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getBreadcrumbs(categories []*crm.Category, id int64) []*crm.Category {
|
||||||
|
for _, category := range categories {
|
||||||
|
if category.Id == id {
|
||||||
|
category.Children = nil
|
||||||
|
return []*crm.Category{category}
|
||||||
|
}
|
||||||
|
breadcrumbs := getBreadcrumbs(category.Children, id)
|
||||||
|
if len(breadcrumbs) != 0 {
|
||||||
|
res := make([]*crm.Category, 0, len(breadcrumbs)+1)
|
||||||
|
category.Children = nil
|
||||||
|
res = append(res, category)
|
||||||
|
res = append(res, breadcrumbs...)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
353
proto/main.pb.go
353
proto/main.pb.go
|
@ -634,6 +634,194 @@ func (x *Characteristic) GetValue() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetProductReq struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetProductReq) Reset() {
|
||||||
|
*x = GetProductReq{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_main_proto_msgTypes[10]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetProductReq) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GetProductReq) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GetProductReq) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_main_proto_msgTypes[10]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use GetProductReq.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GetProductReq) Descriptor() ([]byte, []int) {
|
||||||
|
return file_main_proto_rawDescGZIP(), []int{10}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetProductReq) GetId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProductRsp struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ProductRsp) Reset() {
|
||||||
|
*x = ProductRsp{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_main_proto_msgTypes[11]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ProductRsp) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*ProductRsp) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *ProductRsp) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_main_proto_msgTypes[11]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use ProductRsp.ProtoReflect.Descriptor instead.
|
||||||
|
func (*ProductRsp) Descriptor() ([]byte, []int) {
|
||||||
|
return file_main_proto_rawDescGZIP(), []int{11}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *ProductRsp) GetProduct() *Product {
|
||||||
|
if x != nil {
|
||||||
|
return x.Product
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetBreadcrumbsReq struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetBreadcrumbsReq) Reset() {
|
||||||
|
*x = GetBreadcrumbsReq{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_main_proto_msgTypes[12]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetBreadcrumbsReq) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*GetBreadcrumbsReq) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *GetBreadcrumbsReq) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_main_proto_msgTypes[12]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use GetBreadcrumbsReq.ProtoReflect.Descriptor instead.
|
||||||
|
func (*GetBreadcrumbsReq) Descriptor() ([]byte, []int) {
|
||||||
|
return file_main_proto_rawDescGZIP(), []int{12}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *GetBreadcrumbsReq) GetId() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Id
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type BreadcrumbsRsp struct {
|
||||||
|
state protoimpl.MessageState
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Categories []*Category `protobuf:"bytes,1,rep,name=categories,proto3" json:"categories,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *BreadcrumbsRsp) Reset() {
|
||||||
|
*x = BreadcrumbsRsp{}
|
||||||
|
if protoimpl.UnsafeEnabled {
|
||||||
|
mi := &file_main_proto_msgTypes[13]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *BreadcrumbsRsp) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*BreadcrumbsRsp) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *BreadcrumbsRsp) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_main_proto_msgTypes[13]
|
||||||
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use BreadcrumbsRsp.ProtoReflect.Descriptor instead.
|
||||||
|
func (*BreadcrumbsRsp) Descriptor() ([]byte, []int) {
|
||||||
|
return file_main_proto_rawDescGZIP(), []int{13}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *BreadcrumbsRsp) GetCategories() []*Category {
|
||||||
|
if x != nil {
|
||||||
|
return x.Categories
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var File_main_proto protoreflect.FileDescriptor
|
var File_main_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_main_proto_rawDesc = []byte{
|
var file_main_proto_rawDesc = []byte{
|
||||||
|
@ -702,19 +890,44 @@ var file_main_proto_rawDesc = []byte{
|
||||||
0x61, 0x63, 0x74, 0x65, 0x72, 0x69, 0x73, 0x74, 0x69, 0x63, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
|
0x61, 0x63, 0x74, 0x65, 0x72, 0x69, 0x73, 0x74, 0x69, 0x63, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
|
||||||
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14,
|
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14,
|
||||||
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,
|
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76,
|
||||||
0x61, 0x6c, 0x75, 0x65, 0x32, 0xb4, 0x01, 0x0a, 0x03, 0x43, 0x52, 0x4d, 0x12, 0x4f, 0x0a, 0x0a,
|
0x61, 0x6c, 0x75, 0x65, 0x22, 0x1f, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75,
|
||||||
0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x18, 0x2e, 0x63, 0x72, 0x61,
|
0x63, 0x74, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f,
|
0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x3a, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
|
||||||
0x67, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d,
|
0x52, 0x73, 0x70, 0x12, 0x2c, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x18, 0x01,
|
||||||
0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x73, 0x70, 0x22, 0x10, 0x82, 0xd3, 0xe4,
|
0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d,
|
||||||
0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x5c, 0x0a,
|
0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63,
|
||||||
0x0c, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x2e,
|
0x74, 0x22, 0x23, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x42, 0x72, 0x65, 0x61, 0x64, 0x63, 0x72, 0x75,
|
||||||
0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73,
|
0x6d, 0x62, 0x73, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62,
|
0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x45, 0x0a, 0x0e, 0x42, 0x72, 0x65, 0x61, 0x64, 0x63,
|
||||||
0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52,
|
0x72, 0x75, 0x6d, 0x62, 0x73, 0x52, 0x73, 0x70, 0x12, 0x33, 0x0a, 0x0a, 0x63, 0x61, 0x74, 0x65,
|
||||||
0x73, 0x70, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x70, 0x6f, 0x73,
|
0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63,
|
||||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0x09, 0x5a, 0x07, 0x70,
|
0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72,
|
||||||
0x6b, 0x67, 0x2f, 0x63, 0x72, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x32, 0xf1, 0x02,
|
||||||
|
0x0a, 0x03, 0x43, 0x52, 0x4d, 0x12, 0x4f, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x61,
|
||||||
|
0x6c, 0x6f, 0x67, 0x12, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e,
|
||||||
|
0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e,
|
||||||
|
0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f,
|
||||||
|
0x67, 0x52, 0x73, 0x70, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x63,
|
||||||
|
0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73,
|
||||||
|
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63,
|
||||||
|
0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52,
|
||||||
|
0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x50,
|
||||||
|
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x73, 0x70, 0x22, 0x17, 0x82, 0xd3, 0xe4,
|
||||||
|
0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f,
|
||||||
|
0x7b, 0x69, 0x64, 0x7d, 0x12, 0x55, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75,
|
||||||
|
0x63, 0x74, 0x12, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x47,
|
||||||
|
0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63,
|
||||||
|
0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
|
||||||
|
0x52, 0x73, 0x70, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x70, 0x72,
|
||||||
|
0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x64, 0x0a, 0x0e, 0x47,
|
||||||
|
0x65, 0x74, 0x42, 0x72, 0x65, 0x61, 0x64, 0x63, 0x72, 0x75, 0x6d, 0x62, 0x73, 0x12, 0x1c, 0x2e,
|
||||||
|
0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x65,
|
||||||
|
0x61, 0x64, 0x63, 0x72, 0x75, 0x6d, 0x62, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x63, 0x72,
|
||||||
|
0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x42, 0x72, 0x65, 0x61, 0x64, 0x63, 0x72, 0x75,
|
||||||
|
0x6d, 0x62, 0x73, 0x52, 0x73, 0x70, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11,
|
||||||
|
0x2f, 0x62, 0x72, 0x65, 0x61, 0x64, 0x63, 0x72, 0x75, 0x6d, 0x62, 0x73, 0x2f, 0x7b, 0x69, 0x64,
|
||||||
|
0x7d, 0x42, 0x09, 0x5a, 0x07, 0x70, 0x6b, 0x67, 0x2f, 0x63, 0x72, 0x6d, 0x62, 0x06, 0x70, 0x72,
|
||||||
|
0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -729,36 +942,46 @@ func file_main_proto_rawDescGZIP() []byte {
|
||||||
return file_main_proto_rawDescData
|
return file_main_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
|
||||||
var file_main_proto_goTypes = []interface{}{
|
var file_main_proto_goTypes = []interface{}{
|
||||||
(*GetCatalogReq)(nil), // 0: crabs.crm.GetCatalogReq
|
(*GetCatalogReq)(nil), // 0: crabs.crm.GetCatalogReq
|
||||||
(*CatalogRsp)(nil), // 1: crabs.crm.CatalogRsp
|
(*CatalogRsp)(nil), // 1: crabs.crm.CatalogRsp
|
||||||
(*Category)(nil), // 2: crabs.crm.Category
|
(*Category)(nil), // 2: crabs.crm.Category
|
||||||
(*GetPositionsReq)(nil), // 3: crabs.crm.GetPositionsReq
|
(*GetPositionsReq)(nil), // 3: crabs.crm.GetPositionsReq
|
||||||
(*PositionsRsp)(nil), // 4: crabs.crm.PositionsRsp
|
(*PositionsRsp)(nil), // 4: crabs.crm.PositionsRsp
|
||||||
(*Product)(nil), // 5: crabs.crm.Product
|
(*Product)(nil), // 5: crabs.crm.Product
|
||||||
(*GroupedProduct)(nil), // 6: crabs.crm.GroupedProduct
|
(*GroupedProduct)(nil), // 6: crabs.crm.GroupedProduct
|
||||||
(*Variant)(nil), // 7: crabs.crm.Variant
|
(*Variant)(nil), // 7: crabs.crm.Variant
|
||||||
(*Property)(nil), // 8: crabs.crm.Property
|
(*Property)(nil), // 8: crabs.crm.Property
|
||||||
(*Characteristic)(nil), // 9: crabs.crm.Characteristic
|
(*Characteristic)(nil), // 9: crabs.crm.Characteristic
|
||||||
|
(*GetProductReq)(nil), // 10: crabs.crm.GetProductReq
|
||||||
|
(*ProductRsp)(nil), // 11: crabs.crm.ProductRsp
|
||||||
|
(*GetBreadcrumbsReq)(nil), // 12: crabs.crm.GetBreadcrumbsReq
|
||||||
|
(*BreadcrumbsRsp)(nil), // 13: crabs.crm.BreadcrumbsRsp
|
||||||
}
|
}
|
||||||
var file_main_proto_depIdxs = []int32{
|
var file_main_proto_depIdxs = []int32{
|
||||||
2, // 0: crabs.crm.CatalogRsp.categories:type_name -> crabs.crm.Category
|
2, // 0: crabs.crm.CatalogRsp.categories:type_name -> crabs.crm.Category
|
||||||
2, // 1: crabs.crm.Category.children:type_name -> crabs.crm.Category
|
2, // 1: crabs.crm.Category.children:type_name -> crabs.crm.Category
|
||||||
5, // 2: crabs.crm.PositionsRsp.products:type_name -> crabs.crm.Product
|
5, // 2: crabs.crm.PositionsRsp.products:type_name -> crabs.crm.Product
|
||||||
6, // 3: crabs.crm.Product.grouped_products:type_name -> crabs.crm.GroupedProduct
|
6, // 3: crabs.crm.Product.grouped_products:type_name -> crabs.crm.GroupedProduct
|
||||||
7, // 4: crabs.crm.Product.variants:type_name -> crabs.crm.Variant
|
7, // 4: crabs.crm.Product.variants:type_name -> crabs.crm.Variant
|
||||||
9, // 5: crabs.crm.Product.characteristics:type_name -> crabs.crm.Characteristic
|
9, // 5: crabs.crm.Product.characteristics:type_name -> crabs.crm.Characteristic
|
||||||
8, // 6: crabs.crm.Variant.properties:type_name -> crabs.crm.Property
|
8, // 6: crabs.crm.Variant.properties:type_name -> crabs.crm.Property
|
||||||
0, // 7: crabs.crm.CRM.GetCatalog:input_type -> crabs.crm.GetCatalogReq
|
5, // 7: crabs.crm.ProductRsp.product:type_name -> crabs.crm.Product
|
||||||
3, // 8: crabs.crm.CRM.GetPositions:input_type -> crabs.crm.GetPositionsReq
|
2, // 8: crabs.crm.BreadcrumbsRsp.categories:type_name -> crabs.crm.Category
|
||||||
1, // 9: crabs.crm.CRM.GetCatalog:output_type -> crabs.crm.CatalogRsp
|
0, // 9: crabs.crm.CRM.GetCatalog:input_type -> crabs.crm.GetCatalogReq
|
||||||
4, // 10: crabs.crm.CRM.GetPositions:output_type -> crabs.crm.PositionsRsp
|
3, // 10: crabs.crm.CRM.GetPositions:input_type -> crabs.crm.GetPositionsReq
|
||||||
9, // [9:11] is the sub-list for method output_type
|
10, // 11: crabs.crm.CRM.GetProduct:input_type -> crabs.crm.GetProductReq
|
||||||
7, // [7:9] is the sub-list for method input_type
|
12, // 12: crabs.crm.CRM.GetBreadcrumbs:input_type -> crabs.crm.GetBreadcrumbsReq
|
||||||
7, // [7:7] is the sub-list for extension type_name
|
1, // 13: crabs.crm.CRM.GetCatalog:output_type -> crabs.crm.CatalogRsp
|
||||||
7, // [7:7] is the sub-list for extension extendee
|
4, // 14: crabs.crm.CRM.GetPositions:output_type -> crabs.crm.PositionsRsp
|
||||||
0, // [0:7] is the sub-list for field type_name
|
11, // 15: crabs.crm.CRM.GetProduct:output_type -> crabs.crm.ProductRsp
|
||||||
|
13, // 16: crabs.crm.CRM.GetBreadcrumbs:output_type -> crabs.crm.BreadcrumbsRsp
|
||||||
|
13, // [13:17] is the sub-list for method output_type
|
||||||
|
9, // [9:13] is the sub-list for method input_type
|
||||||
|
9, // [9:9] is the sub-list for extension type_name
|
||||||
|
9, // [9:9] is the sub-list for extension extendee
|
||||||
|
0, // [0:9] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_main_proto_init() }
|
func init() { file_main_proto_init() }
|
||||||
|
@ -887,6 +1110,54 @@ func file_main_proto_init() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_main_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*GetProductReq); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_main_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*ProductRsp); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_main_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*GetBreadcrumbsReq); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_main_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
|
||||||
|
switch v := v.(*BreadcrumbsRsp); i {
|
||||||
|
case 0:
|
||||||
|
return &v.state
|
||||||
|
case 1:
|
||||||
|
return &v.sizeCache
|
||||||
|
case 2:
|
||||||
|
return &v.unknownFields
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
|
@ -894,7 +1165,7 @@ func file_main_proto_init() {
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_main_proto_rawDesc,
|
RawDescriptor: file_main_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 10,
|
NumMessages: 14,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|
|
@ -101,6 +101,110 @@ func local_request_CRM_GetPositions_0(ctx context.Context, marshaler runtime.Mar
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func request_CRM_GetProduct_0(ctx context.Context, marshaler runtime.Marshaler, client CRMClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetProductReq
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int64(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.GetProduct(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_CRM_GetProduct_0(ctx context.Context, marshaler runtime.Marshaler, server CRMServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetProductReq
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int64(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.GetProduct(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func request_CRM_GetBreadcrumbs_0(ctx context.Context, marshaler runtime.Marshaler, client CRMClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetBreadcrumbsReq
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int64(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := client.GetBreadcrumbs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func local_request_CRM_GetBreadcrumbs_0(ctx context.Context, marshaler runtime.Marshaler, server CRMServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||||
|
var protoReq GetBreadcrumbsReq
|
||||||
|
var metadata runtime.ServerMetadata
|
||||||
|
|
||||||
|
var (
|
||||||
|
val string
|
||||||
|
ok bool
|
||||||
|
err error
|
||||||
|
_ = err
|
||||||
|
)
|
||||||
|
|
||||||
|
val, ok = pathParams["id"]
|
||||||
|
if !ok {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||||
|
}
|
||||||
|
|
||||||
|
protoReq.Id, err = runtime.Int64(val)
|
||||||
|
if err != nil {
|
||||||
|
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
msg, err := server.GetBreadcrumbs(ctx, &protoReq)
|
||||||
|
return msg, metadata, err
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterCRMHandlerServer registers the http handlers for service CRM to "mux".
|
// RegisterCRMHandlerServer registers the http handlers for service CRM to "mux".
|
||||||
// UnaryRPC :call CRMServer directly.
|
// UnaryRPC :call CRMServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
|
@ -157,6 +261,56 @@ func RegisterCRMHandlerServer(ctx context.Context, mux *runtime.ServeMux, server
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_CRM_GetProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.crm.CRM/GetProduct", runtime.WithHTTPPathPattern("/products/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_CRM_GetProduct_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_CRM_GetProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_CRM_GetBreadcrumbs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
var stream runtime.ServerTransportStream
|
||||||
|
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.crm.CRM/GetBreadcrumbs", runtime.WithHTTPPathPattern("/breadcrumbs/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := local_request_CRM_GetBreadcrumbs_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||||
|
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_CRM_GetBreadcrumbs_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +396,50 @@ func RegisterCRMHandlerClient(ctx context.Context, mux *runtime.ServeMux, client
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_CRM_GetProduct_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/crabs.crm.CRM/GetProduct", runtime.WithHTTPPathPattern("/products/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_CRM_GetProduct_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_CRM_GetProduct_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
mux.Handle("GET", pattern_CRM_GetBreadcrumbs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||||
|
ctx, cancel := context.WithCancel(req.Context())
|
||||||
|
defer cancel()
|
||||||
|
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||||
|
var err error
|
||||||
|
var annotatedContext context.Context
|
||||||
|
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/crabs.crm.CRM/GetBreadcrumbs", runtime.WithHTTPPathPattern("/breadcrumbs/{id}"))
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, md, err := request_CRM_GetBreadcrumbs_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||||
|
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||||
|
if err != nil {
|
||||||
|
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
forward_CRM_GetBreadcrumbs_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,10 +447,18 @@ var (
|
||||||
pattern_CRM_GetCatalog_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"catalog"}, ""))
|
pattern_CRM_GetCatalog_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"catalog"}, ""))
|
||||||
|
|
||||||
pattern_CRM_GetPositions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"positions", "id"}, ""))
|
pattern_CRM_GetPositions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"positions", "id"}, ""))
|
||||||
|
|
||||||
|
pattern_CRM_GetProduct_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"products", "id"}, ""))
|
||||||
|
|
||||||
|
pattern_CRM_GetBreadcrumbs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"breadcrumbs", "id"}, ""))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
forward_CRM_GetCatalog_0 = runtime.ForwardResponseMessage
|
forward_CRM_GetCatalog_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_CRM_GetPositions_0 = runtime.ForwardResponseMessage
|
forward_CRM_GetPositions_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_CRM_GetProduct_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_CRM_GetBreadcrumbs_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,6 +11,37 @@
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
|
"/breadcrumbs/{id}": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "CRM_GetBreadcrumbs",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/crmBreadcrumbsRsp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"description": "An unexpected error response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/runtimeError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"CRM"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/catalog": {
|
"/catalog": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "CRM_GetCatalog",
|
"operationId": "CRM_GetCatalog",
|
||||||
|
@ -63,9 +94,51 @@
|
||||||
"CRM"
|
"CRM"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/products/{id}": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "CRM_GetProduct",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "A successful response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/crmProductRsp"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"description": "An unexpected error response.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/runtimeError"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true,
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"CRM"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
"crmBreadcrumbsRsp": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"categories": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/crmCategory"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"crmCatalogRsp": {
|
"crmCatalogRsp": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -190,6 +263,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"crmProductRsp": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"product": {
|
||||||
|
"$ref": "#/definitions/crmProduct"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"crmProperty": {
|
"crmProperty": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -19,8 +19,10 @@ import (
|
||||||
const _ = grpc.SupportPackageIsVersion7
|
const _ = grpc.SupportPackageIsVersion7
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CRM_GetCatalog_FullMethodName = "/crabs.crm.CRM/GetCatalog"
|
CRM_GetCatalog_FullMethodName = "/crabs.crm.CRM/GetCatalog"
|
||||||
CRM_GetPositions_FullMethodName = "/crabs.crm.CRM/GetPositions"
|
CRM_GetPositions_FullMethodName = "/crabs.crm.CRM/GetPositions"
|
||||||
|
CRM_GetProduct_FullMethodName = "/crabs.crm.CRM/GetProduct"
|
||||||
|
CRM_GetBreadcrumbs_FullMethodName = "/crabs.crm.CRM/GetBreadcrumbs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CRMClient is the client API for CRM service.
|
// CRMClient is the client API for CRM service.
|
||||||
|
@ -29,6 +31,8 @@ const (
|
||||||
type CRMClient interface {
|
type CRMClient interface {
|
||||||
GetCatalog(ctx context.Context, in *GetCatalogReq, opts ...grpc.CallOption) (*CatalogRsp, error)
|
GetCatalog(ctx context.Context, in *GetCatalogReq, opts ...grpc.CallOption) (*CatalogRsp, error)
|
||||||
GetPositions(ctx context.Context, in *GetPositionsReq, opts ...grpc.CallOption) (*PositionsRsp, error)
|
GetPositions(ctx context.Context, in *GetPositionsReq, opts ...grpc.CallOption) (*PositionsRsp, error)
|
||||||
|
GetProduct(ctx context.Context, in *GetProductReq, opts ...grpc.CallOption) (*ProductRsp, error)
|
||||||
|
GetBreadcrumbs(ctx context.Context, in *GetBreadcrumbsReq, opts ...grpc.CallOption) (*BreadcrumbsRsp, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type cRMClient struct {
|
type cRMClient struct {
|
||||||
|
@ -57,12 +61,32 @@ func (c *cRMClient) GetPositions(ctx context.Context, in *GetPositionsReq, opts
|
||||||
return out, nil
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cRMClient) GetBreadcrumbs(ctx context.Context, in *GetBreadcrumbsReq, opts ...grpc.CallOption) (*BreadcrumbsRsp, error) {
|
||||||
|
out := new(BreadcrumbsRsp)
|
||||||
|
err := c.cc.Invoke(ctx, CRM_GetBreadcrumbs_FullMethodName, in, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
// CRMServer is the server API for CRM service.
|
// CRMServer is the server API for CRM service.
|
||||||
// All implementations must embed UnimplementedCRMServer
|
// All implementations must embed UnimplementedCRMServer
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
type CRMServer interface {
|
type CRMServer interface {
|
||||||
GetCatalog(context.Context, *GetCatalogReq) (*CatalogRsp, error)
|
GetCatalog(context.Context, *GetCatalogReq) (*CatalogRsp, error)
|
||||||
GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error)
|
GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error)
|
||||||
|
GetProduct(context.Context, *GetProductReq) (*ProductRsp, error)
|
||||||
|
GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error)
|
||||||
mustEmbedUnimplementedCRMServer()
|
mustEmbedUnimplementedCRMServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +100,12 @@ func (UnimplementedCRMServer) GetCatalog(context.Context, *GetCatalogReq) (*Cata
|
||||||
func (UnimplementedCRMServer) GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error) {
|
func (UnimplementedCRMServer) GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetPositions not implemented")
|
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) GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method GetBreadcrumbs not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedCRMServer) mustEmbedUnimplementedCRMServer() {}
|
func (UnimplementedCRMServer) mustEmbedUnimplementedCRMServer() {}
|
||||||
|
|
||||||
// UnsafeCRMServer may be embedded to opt out of forward compatibility for this service.
|
// UnsafeCRMServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
@ -125,6 +155,42 @@ func _CRM_GetPositions_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||||
return interceptor(ctx, in, info, handler)
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
func _CRM_GetBreadcrumbs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(GetBreadcrumbsReq)
|
||||||
|
if err := dec(in); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if interceptor == nil {
|
||||||
|
return srv.(CRMServer).GetBreadcrumbs(ctx, in)
|
||||||
|
}
|
||||||
|
info := &grpc.UnaryServerInfo{
|
||||||
|
Server: srv,
|
||||||
|
FullMethod: CRM_GetBreadcrumbs_FullMethodName,
|
||||||
|
}
|
||||||
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
|
return srv.(CRMServer).GetBreadcrumbs(ctx, req.(*GetBreadcrumbsReq))
|
||||||
|
}
|
||||||
|
return interceptor(ctx, in, info, handler)
|
||||||
|
}
|
||||||
|
|
||||||
// CRM_ServiceDesc is the grpc.ServiceDesc for CRM service.
|
// CRM_ServiceDesc is the grpc.ServiceDesc for CRM service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
@ -140,6 +206,14 @@ var CRM_ServiceDesc = grpc.ServiceDesc{
|
||||||
MethodName: "GetPositions",
|
MethodName: "GetPositions",
|
||||||
Handler: _CRM_GetPositions_Handler,
|
Handler: _CRM_GetPositions_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetProduct",
|
||||||
|
Handler: _CRM_GetProduct_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "GetBreadcrumbs",
|
||||||
|
Handler: _CRM_GetBreadcrumbs_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "main.proto",
|
Metadata: "main.proto",
|
||||||
|
|
Loading…
Reference in New Issue