Compare commits

..

5 Commits

Author SHA1 Message Date
Владимир Фёдоров 40dcee97ea Merge pull request 'add book order' (#1) from orders into master
continuous-integration/drone/push Build is passing Details
Reviewed-on: #1
2024-05-23 18:34:46 +00:00
Владимир Фёдоров c1f9809718 Merge branch 'refs/heads/master' into orders
continuous-integration/drone/push Build is passing Details
2024-05-24 01:33:47 +07:00
Владимир Фёдоров d49b4e9037 add empty line to drone.yml
continuous-integration/drone/push Build is passing Details
2024-05-24 01:18:23 +07:00
Владимир Фёдоров 8fbeae6fc1 add get card method
continuous-integration/drone/push Build is passing Details
2024-05-24 01:10:31 +07:00
Владимир Фёдоров 4bd82a34a1 add book order
continuous-integration/drone/push Build is passing Details
2024-05-23 01:40:59 +07:00
18 changed files with 1275 additions and 110 deletions

View File

@ -61,3 +61,4 @@ steps:
trigger:
event:
- push

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
.idea
bin
resources/order_bot_token.txt
resources/telegram_order_chat_id.txt

View File

@ -30,6 +30,18 @@ service CRM {
get: "/breadcrumbs/{id}"
};
}
rpc Order(OrderReq) returns (OrderRsp) {
option (google.api.http) = {
post: "/orders"
body: "order"
};
}
rpc GetCard(CardReq) returns (CardRsp) {
option (google.api.http) = {
post: "/card"
body: "items"
};
}
}
message GetCatalogReq {}
@ -104,3 +116,40 @@ message GetBreadcrumbsReq {
message BreadcrumbsRsp {
repeated Category categories = 1;
}
message OrderReq {
Order order = 1;
string name = 2;
string phone = 3;
}
message OrderRsp {}
message Order {
repeated OrderItem items = 1;
}
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;
}

View File

@ -2,7 +2,9 @@ package main
import (
"cake_crm/internal/app"
"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"
@ -12,11 +14,28 @@ import (
"net"
"net/http"
"os"
"strconv"
)
func main() {
storage := storage_file.NewStorageFile()
cardService := card.NewService(storage)
tokenData, err := os.ReadFile("resources/order_bot_token.txt")
if err != nil {
panic(err)
}
token := string(tokenData)
chatIdData, err := os.ReadFile("resources/telegram_order_chat_id.txt")
if err != nil {
panic(err)
}
chatID, err := strconv.ParseInt(string(chatIdData), 10, 64)
messenger, err := telegram.NewMessenger(chatID, token)
// Create a listener on TCP port
lis, err := net.Listen("tcp", ":8080")
if err != nil {
@ -26,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))
proto.RegisterCRMServer(s, app.NewServer(storage, messenger, cardService))
// Serve gRPC server
log.Println("Serving gRPC on 0.0.0.0:8080")
go func() {

2
go.mod
View File

@ -3,7 +3,7 @@ module cake_crm
go 1.22
require (
github.com/go-pkgz/routegroup v1.1.1
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8
google.golang.org/grpc v1.64.0

4
go.sum
View File

@ -1,5 +1,5 @@
github.com/go-pkgz/routegroup v1.1.1 h1:Dm5IBiEmUbQT+3rliBimhX0SifnZp/uRF/WOu3XPmms=
github.com/go-pkgz/routegroup v1.1.1/go.mod h1:kDDPDRLRiRY1vnENrZJw1jQAzQX7fvsbsHGRQFNQfKc=
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=

View File

@ -1,19 +1,28 @@
package app
import (
"cake_crm/internal/models/storage"
"bytes"
"cake_crm/internal/modules/messenger"
"cake_crm/internal/modules/storage"
"cake_crm/internal/services/card"
proto "cake_crm/proto"
"context"
"errors"
"fmt"
)
type Server struct {
proto.UnimplementedCRMServer
storage storage.IStorage
proto.UnsafeCRMServer
storage storage.IStorage
messenger messenger.IMessenger
cardService *card.Service
}
func NewServer(storage storage.IStorage) *Server {
func NewServer(storage storage.IStorage, messenger messenger.IMessenger, cardService *card.Service) proto.CRMServer {
return &Server{
storage: storage,
storage: storage,
messenger: messenger,
cardService: cardService,
}
}
@ -48,3 +57,55 @@ func (s *Server) GetBreadcrumbs(ctx context.Context, req *proto.GetBreadcrumbsRe
}
return &proto.BreadcrumbsRsp{Categories: breadcrumbs}, nil
}
func (s *Server) Order(ctx context.Context, req *proto.OrderReq) (*proto.OrderRsp, error) {
enrichItems, err := s.cardService.GetCard(ctx, req.Order.Items)
if err != nil {
return nil, err
}
text, err := createOrderText(req, enrichItems)
if err != nil {
return nil, err
}
return &proto.OrderRsp{}, s.messenger.SendMessage(text)
}
func createOrderText(req *proto.OrderReq, items []*proto.CardItem) (string, error) {
buffer := bytes.Buffer{}
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.Name)
buffer.WriteString("\n")
unit, err := unitToText(item.Unit)
if err != nil {
return "", err
}
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", float64(orderAmount)/100))
return buffer.String(), nil
}
func unitToText(unit string) (string, error) {
switch unit {
case "kg":
return "кг", nil
case "piece":
return "шт", nil
}
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
}

View File

@ -0,0 +1,5 @@
package messenger
type IMessenger interface {
SendMessage(message string) error
}

View File

@ -0,0 +1,30 @@
package telegram
import (
"cake_crm/internal/modules/messenger"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
type messengerTelegram struct {
chatID int64
bot *tgbotapi.BotAPI
}
func NewMessenger(
chatID int64,
token string,
) (messenger.IMessenger, error) {
bot, err := tgbotapi.NewBotAPI(token)
if err != nil {
return nil, err
}
return &messengerTelegram{
chatID: chatID,
bot: bot,
}, nil
}
func (m *messengerTelegram) SendMessage(message string) error {
_, err := m.bot.Send(tgbotapi.NewMessage(m.chatID, message))
return err
}

View File

@ -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"

View File

@ -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
}

View File

@ -1,8 +0,0 @@
package server_web
import "context"
type IServer interface {
Run(ctx context.Context) error
Stop(ctx context.Context) error
}

View File

@ -1,43 +0,0 @@
package server_web
import (
"cake_crm/internal/models/storage"
"context"
"fmt"
"github.com/go-pkgz/routegroup"
"net/http"
)
type server struct {
storage storage.IStorage
port int
}
func NewServer(
storage storage.IStorage,
port int,
) IServer {
return &server{
storage: storage,
port: port,
}
}
func (s *server) Run(ctx context.Context) error {
router := routegroup.New(http.NewServeMux())
router.HandleFunc("GET /products", s.getAllProductsHandler)
router.HandleFunc("GET /products/:id", s.getProductById)
router.HandleFunc("GET /category/:id/breadcrumbs", s.getBreadcrumbsByCategoryId)
return http.ListenAndServe(fmt.Sprintf(":%d", s.port), router)
}
func (s *server) Stop(ctx context.Context) error {
//TODO implement me
panic("implement me")
}
func (s *server) getAllProductsHandler(w http.ResponseWriter, r *http.Request) {}
func (s *server) getProductById(w http.ResponseWriter, r *http.Request) {}
func (s *server) getBreadcrumbsByCategoryId(w http.ResponseWriter, r *http.Request) {}

View File

@ -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}
}
@ -823,6 +823,414 @@ func (x *BreadcrumbsRsp) GetCategories() []*Category {
return nil
}
type OrderReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Order *Order `protobuf:"bytes,1,opt,name=order,proto3" json:"order,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Phone string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone,omitempty"`
}
func (x *OrderReq) Reset() {
*x = OrderReq{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *OrderReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*OrderReq) ProtoMessage() {}
func (x *OrderReq) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[14]
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 OrderReq.ProtoReflect.Descriptor instead.
func (*OrderReq) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{14}
}
func (x *OrderReq) GetOrder() *Order {
if x != nil {
return x.Order
}
return nil
}
func (x *OrderReq) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *OrderReq) GetPhone() string {
if x != nil {
return x.Phone
}
return ""
}
type OrderRsp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *OrderRsp) Reset() {
*x = OrderRsp{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *OrderRsp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*OrderRsp) ProtoMessage() {}
func (x *OrderRsp) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[15]
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 OrderRsp.ProtoReflect.Descriptor instead.
func (*OrderRsp) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{15}
}
type Order struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Items []*OrderItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
}
func (x *Order) Reset() {
*x = Order{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Order) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Order) ProtoMessage() {}
func (x *Order) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[16]
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 Order.ProtoReflect.Descriptor instead.
func (*Order) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{16}
}
func (x *Order) GetItems() []*OrderItem {
if x != nil {
return x.Items
}
return nil
}
type OrderItem struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ProductId int64 `protobuf:"varint,1,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"`
Count int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
}
func (x *OrderItem) Reset() {
*x = OrderItem{}
if protoimpl.UnsafeEnabled {
mi := &file_main_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *OrderItem) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*OrderItem) ProtoMessage() {}
func (x *OrderItem) ProtoReflect() protoreflect.Message {
mi := &file_main_proto_msgTypes[17]
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 OrderItem.ProtoReflect.Descriptor instead.
func (*OrderItem) Descriptor() ([]byte, []int) {
return file_main_proto_rawDescGZIP(), []int{17}
}
func (x *OrderItem) GetProductId() int64 {
if x != nil {
return x.ProductId
}
return 0
}
func (x *OrderItem) GetCount() int64 {
if x != nil {
return x.Count
}
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{
@ -906,32 +1314,75 @@ var file_main_proto_rawDesc = []byte{
0x72, 0x75, 0x6d, 0x62, 0x73, 0x52, 0x73, 0x70, 0x12, 0x33, 0x0a, 0x0a, 0x63, 0x61, 0x74, 0x65,
0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63,
0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72,
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, 0x0e, 0x92, 0x41, 0x00, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0x5c, 0x0a,
0x08, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x05, 0x6f, 0x72, 0x64,
0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73,
0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x05, 0x6f, 0x72, 0x64, 0x65,
0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x0a, 0x0a, 0x08, 0x4f,
0x72, 0x64, 0x65, 0x72, 0x52, 0x73, 0x70, 0x22, 0x33, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72,
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, 0x40, 0x0a, 0x09,
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, 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 (
@ -946,14 +1397,14 @@ func file_main_proto_rawDescGZIP() []byte {
return file_main_proto_rawDescData
}
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
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
@ -962,30 +1413,45 @@ var file_main_proto_goTypes = []interface{}{
(*ProductRsp)(nil), // 11: crabs.crm.ProductRsp
(*GetBreadcrumbsReq)(nil), // 12: crabs.crm.GetBreadcrumbsReq
(*BreadcrumbsRsp)(nil), // 13: crabs.crm.BreadcrumbsRsp
(*OrderReq)(nil), // 14: crabs.crm.OrderReq
(*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
0, // 9: crabs.crm.CRM.GetCatalog:input_type -> crabs.crm.GetCatalogReq
3, // 10: crabs.crm.CRM.GetPositions:input_type -> crabs.crm.GetPositionsReq
10, // 11: crabs.crm.CRM.GetProduct:input_type -> crabs.crm.GetProductReq
12, // 12: crabs.crm.CRM.GetBreadcrumbs:input_type -> crabs.crm.GetBreadcrumbsReq
1, // 13: crabs.crm.CRM.GetCatalog:output_type -> crabs.crm.CatalogRsp
4, // 14: crabs.crm.CRM.GetPositions:output_type -> crabs.crm.PositionsRsp
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
16, // 9: crabs.crm.OrderReq.order:type_name -> crabs.crm.Order
17, // 10: crabs.crm.Order.items:type_name -> crabs.crm.OrderItem
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() }
@ -1162,6 +1628,90 @@ func file_main_proto_init() {
return nil
}
}
file_main_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*OrderReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_main_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*OrderRsp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_main_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Order); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_main_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*OrderItem); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
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{
@ -1169,7 +1719,7 @@ func file_main_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_main_proto_rawDesc,
NumEnums: 0,
NumMessages: 14,
NumMessages: 21,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -205,6 +205,76 @@ func local_request_CRM_GetBreadcrumbs_0(ctx context.Context, marshaler runtime.M
}
var (
filter_CRM_Order_0 = &utilities.DoubleArray{Encoding: map[string]int{"order": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)
func request_CRM_Order_0(ctx context.Context, marshaler runtime.Marshaler, client CRMClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrderReq
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Order); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CRM_Order_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Order(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_CRM_Order_0(ctx context.Context, marshaler runtime.Marshaler, server CRMServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq OrderReq
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Order); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CRM_Order_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Order(ctx, &protoReq)
return msg, metadata, err
}
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.
@ -311,6 +381,56 @@ func RegisterCRMHandlerServer(ctx context.Context, mux *runtime.ServeMux, server
})
mux.Handle("POST", pattern_CRM_Order_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/Order", runtime.WithHTTPPathPattern("/orders"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_CRM_Order_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_Order_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
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
}
@ -440,6 +560,50 @@ func RegisterCRMHandlerClient(ctx context.Context, mux *runtime.ServeMux, client
})
mux.Handle("POST", pattern_CRM_Order_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/Order", runtime.WithHTTPPathPattern("/orders"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_CRM_Order_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_Order_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
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
}
@ -451,6 +615,10 @@ var (
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"}, ""))
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 (
@ -461,4 +629,8 @@ var (
forward_CRM_GetProduct_0 = runtime.ForwardResponseMessage
forward_CRM_GetBreadcrumbs_0 = runtime.ForwardResponseMessage
forward_CRM_Order_0 = runtime.ForwardResponseMessage
forward_CRM_GetCard_0 = runtime.ForwardResponseMessage
)

View File

@ -23,6 +23,8 @@ const (
CRM_GetPositions_FullMethodName = "/crabs.crm.CRM/GetPositions"
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.
@ -33,6 +35,8 @@ type CRMClient interface {
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)
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 {
@ -79,6 +83,24 @@ func (c *cRMClient) GetBreadcrumbs(ctx context.Context, in *GetBreadcrumbsReq, o
return out, nil
}
func (c *cRMClient) Order(ctx context.Context, in *OrderReq, opts ...grpc.CallOption) (*OrderRsp, error) {
out := new(OrderRsp)
err := c.cc.Invoke(ctx, CRM_Order_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
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
@ -87,6 +109,8 @@ type CRMServer interface {
GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error)
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()
}
@ -106,6 +130,12 @@ func (UnimplementedCRMServer) GetProduct(context.Context, *GetProductReq) (*Prod
func (UnimplementedCRMServer) GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetBreadcrumbs not implemented")
}
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.
@ -191,6 +221,42 @@ func _CRM_GetBreadcrumbs_Handler(srv interface{}, ctx context.Context, dec func(
return interceptor(ctx, in, info, handler)
}
func _CRM_Order_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(OrderReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(CRMServer).Order(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: CRM_Order_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(CRMServer).Order(ctx, req.(*OrderReq))
}
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)
@ -214,6 +280,14 @@ var CRM_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetBreadcrumbs",
Handler: _CRM_GetBreadcrumbs_Handler,
},
{
MethodName: "Order",
Handler: _CRM_Order_Handler,
},
{
MethodName: "GetCard",
Handler: _CRM_GetCard_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "main.proto",

View File

@ -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",
@ -69,6 +105,50 @@
]
}
},
"/orders": {
"post": {
"operationId": "CRM_Order",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/crmOrderRsp"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "order",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/crabscrmOrder"
}
},
{
"name": "name",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "phone",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"CRM"
]
}
},
"/positions/{id}": {
"get": {
"operationId": "CRM_GetPositions",
@ -133,6 +213,18 @@
}
},
"definitions": {
"crabscrmOrder": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/crmOrderItem"
}
}
}
},
"crmBreadcrumbsRsp": {
"type": "object",
"properties": {
@ -145,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": {
@ -204,6 +347,22 @@
}
}
},
"crmOrderItem": {
"type": "object",
"properties": {
"productId": {
"type": "string",
"format": "int64"
},
"count": {
"type": "string",
"format": "int64"
}
}
},
"crmOrderRsp": {
"type": "object"
},
"crmPositionsRsp": {
"type": "object",
"properties": {