add get card method
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
4bd82a34a1
commit
8fbeae6fc1
|
@ -36,6 +36,12 @@ service CRM {
|
|||
body: "order"
|
||||
};
|
||||
}
|
||||
rpc GetCard(CardReq) returns (CardRsp) {
|
||||
option (google.api.http) = {
|
||||
post: "/card"
|
||||
body: "items"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
message GetCatalogReq {}
|
||||
|
@ -127,3 +133,23 @@ message OrderItem {
|
|||
int64 product_id = 1;
|
||||
int64 count = 2;
|
||||
}
|
||||
|
||||
message CardItem {
|
||||
int64 id = 1;
|
||||
string article = 2;
|
||||
string name = 3;
|
||||
string uri = 4;
|
||||
repeated string images = 5;
|
||||
string unit = 8;
|
||||
double inventory = 9;
|
||||
int64 count = 10;
|
||||
int64 amount = 11;
|
||||
}
|
||||
|
||||
message CardReq {
|
||||
repeated OrderItem items = 1;
|
||||
}
|
||||
|
||||
message CardRsp {
|
||||
repeated CardItem items = 1;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ package main
|
|||
|
||||
import (
|
||||
"cake_crm/internal/app"
|
||||
"cake_crm/internal/models/messenger/telegram"
|
||||
"cake_crm/internal/models/storage/storage_file"
|
||||
"cake_crm/internal/modules/messenger/telegram"
|
||||
"cake_crm/internal/modules/storage/storage_file"
|
||||
"cake_crm/internal/services/card"
|
||||
proto "cake_crm/proto"
|
||||
"context"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
|
@ -19,6 +20,8 @@ import (
|
|||
func main() {
|
||||
storage := storage_file.NewStorageFile()
|
||||
|
||||
cardService := card.NewService(storage)
|
||||
|
||||
tokenData, err := os.ReadFile("resources/order_bot_token.txt")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -42,7 +45,7 @@ func main() {
|
|||
// Create a gRPC server object
|
||||
s := grpc.NewServer()
|
||||
// Attach the Greeter service to the server
|
||||
proto.RegisterCRMServer(s, app.NewServer(storage, messenger))
|
||||
proto.RegisterCRMServer(s, app.NewServer(storage, messenger, cardService))
|
||||
// Serve gRPC server
|
||||
log.Println("Serving gRPC on 0.0.0.0:8080")
|
||||
go func() {
|
||||
|
|
|
@ -2,33 +2,27 @@ package app
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"cake_crm/internal/models/messenger"
|
||||
"cake_crm/internal/models/storage"
|
||||
"cake_crm/internal/modules/messenger"
|
||||
"cake_crm/internal/modules/storage"
|
||||
"cake_crm/internal/services/card"
|
||||
proto "cake_crm/proto"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type orderItem struct {
|
||||
product *proto.Product
|
||||
count int64
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
proto.UnsafeCRMServer
|
||||
storage storage.IStorage
|
||||
messenger messenger.IMessenger
|
||||
cardService *card.Service
|
||||
}
|
||||
|
||||
func NewServer(
|
||||
storage storage.IStorage,
|
||||
messenger messenger.IMessenger,
|
||||
) proto.CRMServer {
|
||||
func NewServer(storage storage.IStorage, messenger messenger.IMessenger, cardService *card.Service) proto.CRMServer {
|
||||
return &Server{
|
||||
storage: storage,
|
||||
messenger: messenger,
|
||||
cardService: cardService,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,88 +59,39 @@ func (s *Server) GetBreadcrumbs(ctx context.Context, req *proto.GetBreadcrumbsRe
|
|||
}
|
||||
|
||||
func (s *Server) Order(ctx context.Context, req *proto.OrderReq) (*proto.OrderRsp, error) {
|
||||
items := make([]*orderItem, 0, len(req.Order.Items))
|
||||
for _, item := range req.Order.Items {
|
||||
product, err := s.storage.GetProduct(ctx, item.ProductId)
|
||||
enrichItems, err := s.cardService.GetCard(ctx, req.Order.Items)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(
|
||||
items,
|
||||
&orderItem{
|
||||
product: product,
|
||||
count: item.Count,
|
||||
},
|
||||
)
|
||||
}
|
||||
text, err := createOrderText(req, items)
|
||||
text, err := createOrderText(req, enrichItems)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.OrderRsp{}, s.messenger.SendMessage(text)
|
||||
}
|
||||
|
||||
func createOrderText(req *proto.OrderReq, items []*orderItem) (string, error) {
|
||||
func createOrderText(req *proto.OrderReq, items []*proto.CardItem) (string, error) {
|
||||
buffer := bytes.Buffer{}
|
||||
orderAmount := 0.0
|
||||
var orderAmount int64
|
||||
buffer.WriteString(fmt.Sprintf("Заказ от:\n%s\n%s\n", req.Name, req.Phone))
|
||||
buffer.WriteString("\n")
|
||||
for _, item := range items {
|
||||
buffer.WriteString(item.product.Name)
|
||||
buffer.WriteString(item.Name)
|
||||
buffer.WriteString("\n")
|
||||
unit, err := unitToText(item.product.Unit)
|
||||
unit, err := unitToText(item.Unit)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
buffer.WriteString(fmt.Sprintf("Количество: %d%s\n", item.count, unit))
|
||||
amount, err := calcItemAmount(item)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
orderAmount += amount
|
||||
buffer.WriteString(fmt.Sprintf("Сумма: %.00fр\n", amount))
|
||||
buffer.WriteString(fmt.Sprintf("Количество: %d%s\n", item.Count, unit))
|
||||
orderAmount += item.Amount
|
||||
buffer.WriteString(fmt.Sprintf("Сумма: %.00fр\n", float64(item.Amount)/100))
|
||||
buffer.WriteString("\n")
|
||||
}
|
||||
buffer.WriteString("\n")
|
||||
buffer.WriteString(fmt.Sprintf("ИТОГО: %.00fр\n", orderAmount))
|
||||
buffer.WriteString(fmt.Sprintf("ИТОГО: %.00fр\n", float64(orderAmount)/100))
|
||||
return buffer.String(), nil
|
||||
}
|
||||
|
||||
func calcItemAmount(item *orderItem) (float64, error) {
|
||||
var variant *proto.Variant
|
||||
for _, v := range item.product.Variants {
|
||||
check := true
|
||||
for _, property := range v.Properties {
|
||||
if property.Name == "min" {
|
||||
minBorder, err := strconv.ParseInt(property.Value, 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if item.count < minBorder {
|
||||
check = false
|
||||
}
|
||||
}
|
||||
if property.Name == "max" {
|
||||
maxBorder, err := strconv.ParseInt(property.Value, 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if item.count > maxBorder {
|
||||
check = false
|
||||
}
|
||||
}
|
||||
if check {
|
||||
variant = v
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if variant == nil {
|
||||
return 0, errors.New("variant not found")
|
||||
}
|
||||
return float64(variant.Price) * float64(item.count) / 100, nil
|
||||
}
|
||||
|
||||
func unitToText(unit string) (string, error) {
|
||||
switch unit {
|
||||
case "kg":
|
||||
|
@ -156,3 +101,11 @@ func unitToText(unit string) (string, error) {
|
|||
}
|
||||
return "", errors.New("unit not found")
|
||||
}
|
||||
|
||||
func (s *Server) GetCard(ctx context.Context, req *proto.CardReq) (*proto.CardRsp, error) {
|
||||
enrichItems, err := s.cardService.GetCard(ctx, req.Items)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &proto.CardRsp{Items: enrichItems}, nil
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package telegram
|
||||
|
||||
import (
|
||||
"cake_crm/internal/models/messenger"
|
||||
"cake_crm/internal/modules/messenger"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package storage_file
|
||||
|
||||
import (
|
||||
"cake_crm/internal/models/storage"
|
||||
"cake_crm/internal/modules/storage"
|
||||
crm "cake_crm/proto"
|
||||
"context"
|
||||
"encoding/json"
|
|
@ -0,0 +1,93 @@
|
|||
package card
|
||||
|
||||
import (
|
||||
"cake_crm/internal/modules/storage"
|
||||
"cake_crm/proto"
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type ProductAndCount struct {
|
||||
product *proto.Product
|
||||
count int64
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
storage storage.IStorage
|
||||
}
|
||||
|
||||
func NewService(storage storage.IStorage) *Service {
|
||||
return &Service{
|
||||
storage: storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) GetCard(ctx context.Context, items []*proto.OrderItem) ([]*proto.CardItem, error) {
|
||||
res := make([]*proto.CardItem, 0, len(items))
|
||||
for _, item := range items {
|
||||
product, err := s.storage.GetProduct(ctx, item.ProductId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
amount, err := calcItemAmount(
|
||||
&ProductAndCount{
|
||||
product: product,
|
||||
count: item.Count,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res = append(
|
||||
res,
|
||||
&proto.CardItem{
|
||||
Id: product.Id,
|
||||
Article: product.Article,
|
||||
Name: product.Name,
|
||||
Uri: product.Uri,
|
||||
Images: product.Images,
|
||||
Unit: product.Unit,
|
||||
Inventory: product.Inventory,
|
||||
Count: item.Count,
|
||||
Amount: amount,
|
||||
},
|
||||
)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func calcItemAmount(item *ProductAndCount) (int64, error) {
|
||||
var variant *proto.Variant
|
||||
for _, v := range item.product.Variants {
|
||||
check := true
|
||||
for _, property := range v.Properties {
|
||||
if property.Name == "min" {
|
||||
minBorder, err := strconv.ParseInt(property.Value, 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if item.count < minBorder {
|
||||
check = false
|
||||
}
|
||||
}
|
||||
if property.Name == "max" {
|
||||
maxBorder, err := strconv.ParseInt(property.Value, 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if item.count > maxBorder {
|
||||
check = false
|
||||
}
|
||||
}
|
||||
if check {
|
||||
variant = v
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if variant == nil {
|
||||
return 0, errors.New("variant not found")
|
||||
}
|
||||
return variant.Price * item.count, nil
|
||||
}
|
382
proto/main.pb.go
382
proto/main.pb.go
|
@ -318,7 +318,7 @@ func (x *Product) ProtoReflect() protoreflect.Message {
|
|||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Product.ProtoReflect.Descriptor instead.
|
||||
// Deprecated: Use product.ProtoReflect.Descriptor instead.
|
||||
func (*Product) Descriptor() ([]byte, []int) {
|
||||
return file_main_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
@ -1026,6 +1026,211 @@ func (x *OrderItem) GetCount() int64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
type CardItem struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Article string `protobuf:"bytes,2,opt,name=article,proto3" json:"article,omitempty"`
|
||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Uri string `protobuf:"bytes,4,opt,name=uri,proto3" json:"uri,omitempty"`
|
||||
Images []string `protobuf:"bytes,5,rep,name=images,proto3" json:"images,omitempty"`
|
||||
Unit string `protobuf:"bytes,8,opt,name=unit,proto3" json:"unit,omitempty"`
|
||||
Inventory float64 `protobuf:"fixed64,9,opt,name=inventory,proto3" json:"inventory,omitempty"`
|
||||
Count int64 `protobuf:"varint,10,opt,name=count,proto3" json:"count,omitempty"`
|
||||
Amount int64 `protobuf:"varint,11,opt,name=amount,proto3" json:"amount,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CardItem) Reset() {
|
||||
*x = CardItem{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_main_proto_msgTypes[18]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CardItem) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CardItem) ProtoMessage() {}
|
||||
|
||||
func (x *CardItem) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_main_proto_msgTypes[18]
|
||||
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 CardItem.ProtoReflect.Descriptor instead.
|
||||
func (*CardItem) Descriptor() ([]byte, []int) {
|
||||
return file_main_proto_rawDescGZIP(), []int{18}
|
||||
}
|
||||
|
||||
func (x *CardItem) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CardItem) GetArticle() string {
|
||||
if x != nil {
|
||||
return x.Article
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CardItem) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CardItem) GetUri() string {
|
||||
if x != nil {
|
||||
return x.Uri
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CardItem) GetImages() []string {
|
||||
if x != nil {
|
||||
return x.Images
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *CardItem) GetUnit() string {
|
||||
if x != nil {
|
||||
return x.Unit
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CardItem) GetInventory() float64 {
|
||||
if x != nil {
|
||||
return x.Inventory
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CardItem) GetCount() int64 {
|
||||
if x != nil {
|
||||
return x.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *CardItem) GetAmount() int64 {
|
||||
if x != nil {
|
||||
return x.Amount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type CardReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Items []*OrderItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CardReq) Reset() {
|
||||
*x = CardReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_main_proto_msgTypes[19]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CardReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CardReq) ProtoMessage() {}
|
||||
|
||||
func (x *CardReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_main_proto_msgTypes[19]
|
||||
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 CardReq.ProtoReflect.Descriptor instead.
|
||||
func (*CardReq) Descriptor() ([]byte, []int) {
|
||||
return file_main_proto_rawDescGZIP(), []int{19}
|
||||
}
|
||||
|
||||
func (x *CardReq) GetItems() []*OrderItem {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CardRsp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Items []*CardItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
|
||||
}
|
||||
|
||||
func (x *CardRsp) Reset() {
|
||||
*x = CardRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_main_proto_msgTypes[20]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *CardRsp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CardRsp) ProtoMessage() {}
|
||||
|
||||
func (x *CardRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_main_proto_msgTypes[20]
|
||||
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 CardRsp.ProtoReflect.Descriptor instead.
|
||||
func (*CardRsp) Descriptor() ([]byte, []int) {
|
||||
return file_main_proto_rawDescGZIP(), []int{20}
|
||||
}
|
||||
|
||||
func (x *CardRsp) GetItems() []*CardItem {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_main_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_main_proto_rawDesc = []byte{
|
||||
|
@ -1123,37 +1328,61 @@ var file_main_proto_rawDesc = []byte{
|
|||
0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f,
|
||||
0x64, 0x75, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70,
|
||||
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xbc,
|
||||
0x03, 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, 0x12, 0x49, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x13, 0x2e, 0x63, 0x72,
|
||||
0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71,
|
||||
0x1a, 0x13, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f, 0x72, 0x64,
|
||||
0x65, 0x72, 0x52, 0x73, 0x70, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x3a, 0x05, 0x6f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x22, 0x07, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x42, 0x0e, 0x92,
|
||||
0x41, 0x00, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xd2,
|
||||
0x01, 0x0a, 0x08, 0x43, 0x61, 0x72, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
||||
0x72, 0x74, 0x69, 0x63, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x72,
|
||||
0x74, 0x69, 0x63, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x16, 0x0a, 0x06, 0x69,
|
||||
0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x69, 0x6d, 0x61,
|
||||
0x67, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x6e, 0x69, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x75, 0x6e, 0x69, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x76, 0x65, 0x6e,
|
||||
0x74, 0x6f, 0x72, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x69, 0x6e, 0x76, 0x65,
|
||||
0x6e, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0a,
|
||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61,
|
||||
0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x61, 0x6d, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x22, 0x35, 0x0a, 0x07, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x12, 0x2a,
|
||||
0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e,
|
||||
0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x34, 0x0a, 0x07, 0x43, 0x61,
|
||||
0x72, 0x64, 0x52, 0x73, 0x70, 0x12, 0x29, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01,
|
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d,
|
||||
0x2e, 0x43, 0x61, 0x72, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73,
|
||||
0x32, 0x85, 0x04, 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, 0x12, 0x49, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x13, 0x2e,
|
||||
0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52,
|
||||
0x65, 0x71, 0x1a, 0x13, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x52, 0x73, 0x70, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x3a,
|
||||
0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x07, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x12,
|
||||
0x47, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x43, 0x61, 0x72, 0x64, 0x12, 0x12, 0x2e, 0x63, 0x72, 0x61,
|
||||
0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x12,
|
||||
0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x43, 0x61, 0x72, 0x64, 0x52,
|
||||
0x73, 0x70, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x3a, 0x05, 0x69, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x22, 0x05, 0x2f, 0x63, 0x61, 0x72, 0x64, 0x42, 0x0e, 0x92, 0x41, 0x00, 0x5a, 0x09, 0x70,
|
||||
0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -1168,14 +1397,14 @@ func file_main_proto_rawDescGZIP() []byte {
|
|||
return file_main_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 18)
|
||||
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 21)
|
||||
var file_main_proto_goTypes = []interface{}{
|
||||
(*GetCatalogReq)(nil), // 0: crabs.crm.GetCatalogReq
|
||||
(*CatalogRsp)(nil), // 1: crabs.crm.CatalogRsp
|
||||
(*Category)(nil), // 2: crabs.crm.Category
|
||||
(*GetPositionsReq)(nil), // 3: crabs.crm.GetPositionsReq
|
||||
(*PositionsRsp)(nil), // 4: crabs.crm.PositionsRsp
|
||||
(*Product)(nil), // 5: crabs.crm.Product
|
||||
(*Product)(nil), // 5: crabs.crm.product
|
||||
(*GroupedProduct)(nil), // 6: crabs.crm.GroupedProduct
|
||||
(*Variant)(nil), // 7: crabs.crm.Variant
|
||||
(*Property)(nil), // 8: crabs.crm.Property
|
||||
|
@ -1188,34 +1417,41 @@ var file_main_proto_goTypes = []interface{}{
|
|||
(*OrderRsp)(nil), // 15: crabs.crm.OrderRsp
|
||||
(*Order)(nil), // 16: crabs.crm.Order
|
||||
(*OrderItem)(nil), // 17: crabs.crm.OrderItem
|
||||
(*CardItem)(nil), // 18: crabs.crm.CardItem
|
||||
(*CardReq)(nil), // 19: crabs.crm.CardReq
|
||||
(*CardRsp)(nil), // 20: crabs.crm.CardRsp
|
||||
}
|
||||
var file_main_proto_depIdxs = []int32{
|
||||
2, // 0: crabs.crm.CatalogRsp.categories: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
|
||||
6, // 3: crabs.crm.Product.grouped_products:type_name -> crabs.crm.GroupedProduct
|
||||
7, // 4: crabs.crm.Product.variants:type_name -> crabs.crm.Variant
|
||||
9, // 5: crabs.crm.Product.characteristics:type_name -> crabs.crm.Characteristic
|
||||
5, // 2: crabs.crm.PositionsRsp.products:type_name -> crabs.crm.product
|
||||
6, // 3: crabs.crm.product.grouped_products:type_name -> crabs.crm.GroupedProduct
|
||||
7, // 4: crabs.crm.product.variants:type_name -> crabs.crm.Variant
|
||||
9, // 5: crabs.crm.product.characteristics:type_name -> crabs.crm.Characteristic
|
||||
8, // 6: crabs.crm.Variant.properties:type_name -> crabs.crm.Property
|
||||
5, // 7: crabs.crm.ProductRsp.product:type_name -> crabs.crm.Product
|
||||
5, // 7: crabs.crm.ProductRsp.product:type_name -> crabs.crm.product
|
||||
2, // 8: crabs.crm.BreadcrumbsRsp.categories:type_name -> crabs.crm.Category
|
||||
16, // 9: crabs.crm.OrderReq.order:type_name -> crabs.crm.Order
|
||||
17, // 10: crabs.crm.Order.items:type_name -> crabs.crm.OrderItem
|
||||
0, // 11: crabs.crm.CRM.GetCatalog:input_type -> crabs.crm.GetCatalogReq
|
||||
3, // 12: crabs.crm.CRM.GetPositions:input_type -> crabs.crm.GetPositionsReq
|
||||
10, // 13: crabs.crm.CRM.GetProduct:input_type -> crabs.crm.GetProductReq
|
||||
12, // 14: crabs.crm.CRM.GetBreadcrumbs:input_type -> crabs.crm.GetBreadcrumbsReq
|
||||
14, // 15: crabs.crm.CRM.Order:input_type -> crabs.crm.OrderReq
|
||||
1, // 16: crabs.crm.CRM.GetCatalog:output_type -> crabs.crm.CatalogRsp
|
||||
4, // 17: crabs.crm.CRM.GetPositions:output_type -> crabs.crm.PositionsRsp
|
||||
11, // 18: crabs.crm.CRM.GetProduct:output_type -> crabs.crm.ProductRsp
|
||||
13, // 19: crabs.crm.CRM.GetBreadcrumbs:output_type -> crabs.crm.BreadcrumbsRsp
|
||||
15, // 20: crabs.crm.CRM.Order:output_type -> crabs.crm.OrderRsp
|
||||
16, // [16:21] is the sub-list for method output_type
|
||||
11, // [11:16] is the sub-list for method input_type
|
||||
11, // [11:11] is the sub-list for extension type_name
|
||||
11, // [11:11] is the sub-list for extension extendee
|
||||
0, // [0:11] is the sub-list for field type_name
|
||||
17, // 11: crabs.crm.CardReq.items:type_name -> crabs.crm.OrderItem
|
||||
18, // 12: crabs.crm.CardRsp.items:type_name -> crabs.crm.CardItem
|
||||
0, // 13: crabs.crm.CRM.GetCatalog:input_type -> crabs.crm.GetCatalogReq
|
||||
3, // 14: crabs.crm.CRM.GetPositions:input_type -> crabs.crm.GetPositionsReq
|
||||
10, // 15: crabs.crm.CRM.GetProduct:input_type -> crabs.crm.GetProductReq
|
||||
12, // 16: crabs.crm.CRM.GetBreadcrumbs:input_type -> crabs.crm.GetBreadcrumbsReq
|
||||
14, // 17: crabs.crm.CRM.Order:input_type -> crabs.crm.OrderReq
|
||||
19, // 18: crabs.crm.CRM.GetCard:input_type -> crabs.crm.CardReq
|
||||
1, // 19: crabs.crm.CRM.GetCatalog:output_type -> crabs.crm.CatalogRsp
|
||||
4, // 20: crabs.crm.CRM.GetPositions:output_type -> crabs.crm.PositionsRsp
|
||||
11, // 21: crabs.crm.CRM.GetProduct:output_type -> crabs.crm.ProductRsp
|
||||
13, // 22: crabs.crm.CRM.GetBreadcrumbs:output_type -> crabs.crm.BreadcrumbsRsp
|
||||
15, // 23: crabs.crm.CRM.Order:output_type -> crabs.crm.OrderRsp
|
||||
20, // 24: crabs.crm.CRM.GetCard:output_type -> crabs.crm.CardRsp
|
||||
19, // [19:25] is the sub-list for method output_type
|
||||
13, // [13:19] is the sub-list for method input_type
|
||||
13, // [13:13] is the sub-list for extension type_name
|
||||
13, // [13:13] is the sub-list for extension extendee
|
||||
0, // [0:13] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_main_proto_init() }
|
||||
|
@ -1440,6 +1676,42 @@ func file_main_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_main_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CardItem); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_main_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CardReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_main_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*CardRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
|
@ -1447,7 +1719,7 @@ func file_main_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_main_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 18,
|
||||
NumMessages: 21,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
|
|
@ -249,6 +249,32 @@ func local_request_CRM_Order_0(ctx context.Context, marshaler runtime.Marshaler,
|
|||
|
||||
}
|
||||
|
||||
func request_CRM_GetCard_0(ctx context.Context, marshaler runtime.Marshaler, client CRMClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CardReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Items); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.GetCard(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_CRM_GetCard_0(ctx context.Context, marshaler runtime.Marshaler, server CRMServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq CardReq
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Items); err != nil && err != io.EOF {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.GetCard(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterCRMHandlerServer registers the http handlers for service CRM to "mux".
|
||||
// UnaryRPC :call CRMServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
|
@ -380,6 +406,31 @@ func RegisterCRMHandlerServer(ctx context.Context, mux *runtime.ServeMux, server
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_CRM_GetCard_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/GetCard", runtime.WithHTTPPathPattern("/card"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_CRM_GetCard_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_GetCard_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -531,6 +582,28 @@ func RegisterCRMHandlerClient(ctx context.Context, mux *runtime.ServeMux, client
|
|||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_CRM_GetCard_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/GetCard", runtime.WithHTTPPathPattern("/card"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_CRM_GetCard_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_GetCard_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -544,6 +617,8 @@ var (
|
|||
pattern_CRM_GetBreadcrumbs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"breadcrumbs", "id"}, ""))
|
||||
|
||||
pattern_CRM_Order_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"orders"}, ""))
|
||||
|
||||
pattern_CRM_GetCard_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"card"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -556,4 +631,6 @@ var (
|
|||
forward_CRM_GetBreadcrumbs_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_CRM_Order_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_CRM_GetCard_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
|
|
@ -24,6 +24,7 @@ const (
|
|||
CRM_GetProduct_FullMethodName = "/crabs.crm.CRM/GetProduct"
|
||||
CRM_GetBreadcrumbs_FullMethodName = "/crabs.crm.CRM/GetBreadcrumbs"
|
||||
CRM_Order_FullMethodName = "/crabs.crm.CRM/Order"
|
||||
CRM_GetCard_FullMethodName = "/crabs.crm.CRM/GetCard"
|
||||
)
|
||||
|
||||
// CRMClient is the client API for CRM service.
|
||||
|
@ -35,6 +36,7 @@ type CRMClient interface {
|
|||
GetProduct(ctx context.Context, in *GetProductReq, opts ...grpc.CallOption) (*ProductRsp, error)
|
||||
GetBreadcrumbs(ctx context.Context, in *GetBreadcrumbsReq, opts ...grpc.CallOption) (*BreadcrumbsRsp, error)
|
||||
Order(ctx context.Context, in *OrderReq, opts ...grpc.CallOption) (*OrderRsp, error)
|
||||
GetCard(ctx context.Context, in *CardReq, opts ...grpc.CallOption) (*CardRsp, error)
|
||||
}
|
||||
|
||||
type cRMClient struct {
|
||||
|
@ -90,6 +92,15 @@ func (c *cRMClient) Order(ctx context.Context, in *OrderReq, opts ...grpc.CallOp
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *cRMClient) GetCard(ctx context.Context, in *CardReq, opts ...grpc.CallOption) (*CardRsp, error) {
|
||||
out := new(CardRsp)
|
||||
err := c.cc.Invoke(ctx, CRM_GetCard_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
|
||||
|
@ -99,6 +110,7 @@ type CRMServer interface {
|
|||
GetProduct(context.Context, *GetProductReq) (*ProductRsp, error)
|
||||
GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error)
|
||||
Order(context.Context, *OrderReq) (*OrderRsp, error)
|
||||
GetCard(context.Context, *CardReq) (*CardRsp, error)
|
||||
mustEmbedUnimplementedCRMServer()
|
||||
}
|
||||
|
||||
|
@ -121,6 +133,9 @@ func (UnimplementedCRMServer) GetBreadcrumbs(context.Context, *GetBreadcrumbsReq
|
|||
func (UnimplementedCRMServer) Order(context.Context, *OrderReq) (*OrderRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Order not implemented")
|
||||
}
|
||||
func (UnimplementedCRMServer) GetCard(context.Context, *CardReq) (*CardRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetCard not implemented")
|
||||
}
|
||||
func (UnimplementedCRMServer) mustEmbedUnimplementedCRMServer() {}
|
||||
|
||||
// UnsafeCRMServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
@ -224,6 +239,24 @@ func _CRM_Order_Handler(srv interface{}, ctx context.Context, dec func(interface
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _CRM_GetCard_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CardReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(CRMServer).GetCard(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: CRM_GetCard_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(CRMServer).GetCard(ctx, req.(*CardReq))
|
||||
}
|
||||
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)
|
||||
|
@ -251,6 +284,10 @@ var CRM_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "Order",
|
||||
Handler: _CRM_Order_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetCard",
|
||||
Handler: _CRM_GetCard_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "main.proto",
|
||||
|
|
|
@ -47,6 +47,42 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/card": {
|
||||
"post": {
|
||||
"operationId": "CRM_GetCard",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/crmCardRsp"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "An unexpected error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/rpcStatus"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "items",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/crmOrderItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"CRM"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/catalog": {
|
||||
"get": {
|
||||
"operationId": "CRM_GetCatalog",
|
||||
|
@ -201,6 +237,57 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"crmCardItem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"article": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"uri": {
|
||||
"type": "string"
|
||||
},
|
||||
"images": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"unit": {
|
||||
"type": "string"
|
||||
},
|
||||
"inventory": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"count": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
},
|
||||
"amount": {
|
||||
"type": "string",
|
||||
"format": "int64"
|
||||
}
|
||||
}
|
||||
},
|
||||
"crmCardRsp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/crmCardItem"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"crmCatalogRsp": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
Loading…
Reference in New Issue