add book order #1
|
@ -1,3 +1,6 @@
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
bin
|
bin
|
||||||
|
|
||||||
|
resources/order_bot_token.txt
|
||||||
|
resources/telegram_order_chat_id.txt
|
||||||
|
|
|
@ -30,6 +30,12 @@ service CRM {
|
||||||
get: "/breadcrumbs/{id}"
|
get: "/breadcrumbs/{id}"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
rpc Order(OrderReq) returns (OrderRsp) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/orders"
|
||||||
|
body: "order"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetCatalogReq {}
|
message GetCatalogReq {}
|
||||||
|
@ -104,3 +110,20 @@ message GetBreadcrumbsReq {
|
||||||
message BreadcrumbsRsp {
|
message BreadcrumbsRsp {
|
||||||
repeated Category categories = 1;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cake_crm/internal/app"
|
"cake_crm/internal/app"
|
||||||
|
"cake_crm/internal/models/messenger/telegram"
|
||||||
"cake_crm/internal/models/storage/storage_file"
|
"cake_crm/internal/models/storage/storage_file"
|
||||||
proto "cake_crm/proto"
|
proto "cake_crm/proto"
|
||||||
"context"
|
"context"
|
||||||
|
@ -12,11 +13,26 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
storage := storage_file.NewStorageFile()
|
storage := storage_file.NewStorageFile()
|
||||||
|
|
||||||
|
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
|
// Create a listener on TCP port
|
||||||
lis, err := net.Listen("tcp", ":8080")
|
lis, err := net.Listen("tcp", ":8080")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -26,7 +42,7 @@ func main() {
|
||||||
// Create a gRPC server object
|
// Create a gRPC server object
|
||||||
s := grpc.NewServer()
|
s := grpc.NewServer()
|
||||||
// Attach the Greeter service to the server
|
// Attach the Greeter service to the server
|
||||||
proto.RegisterCRMServer(s, app.NewServer(storage))
|
proto.RegisterCRMServer(s, app.NewServer(storage, messenger))
|
||||||
// Serve gRPC server
|
// Serve gRPC server
|
||||||
log.Println("Serving gRPC on 0.0.0.0:8080")
|
log.Println("Serving gRPC on 0.0.0.0:8080")
|
||||||
go func() {
|
go func() {
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module cake_crm
|
||||||
go 1.22
|
go 1.22
|
||||||
|
|
||||||
require (
|
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
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8
|
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8
|
||||||
google.golang.org/grpc v1.64.0
|
google.golang.org/grpc v1.64.0
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1,5 +1,5 @@
|
||||||
github.com/go-pkgz/routegroup v1.1.1 h1:Dm5IBiEmUbQT+3rliBimhX0SifnZp/uRF/WOu3XPmms=
|
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1 h1:wG8n/XJQ07TmjbITcGiUaOtXxdrINDz1b0J1w0SzqDc=
|
||||||
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/go.mod h1:A2S0CWkNylc2phvKXWBBdD3K0iGnDBGbzRpISP2zBl8=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
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/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
|
||||||
|
|
|
@ -1,19 +1,34 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"cake_crm/internal/models/messenger"
|
||||||
"cake_crm/internal/models/storage"
|
"cake_crm/internal/models/storage"
|
||||||
proto "cake_crm/proto"
|
proto "cake_crm/proto"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type orderItem struct {
|
||||||
proto.UnimplementedCRMServer
|
product *proto.Product
|
||||||
storage storage.IStorage
|
count int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(storage storage.IStorage) *Server {
|
type Server struct {
|
||||||
|
proto.UnsafeCRMServer
|
||||||
|
storage storage.IStorage
|
||||||
|
messenger messenger.IMessenger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServer(
|
||||||
|
storage storage.IStorage,
|
||||||
|
messenger messenger.IMessenger,
|
||||||
|
) proto.CRMServer {
|
||||||
return &Server{
|
return &Server{
|
||||||
storage: storage,
|
storage: storage,
|
||||||
|
messenger: messenger,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,3 +63,96 @@ func (s *Server) GetBreadcrumbs(ctx context.Context, req *proto.GetBreadcrumbsRe
|
||||||
}
|
}
|
||||||
return &proto.BreadcrumbsRsp{Categories: breadcrumbs}, nil
|
return &proto.BreadcrumbsRsp{Categories: breadcrumbs}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(
|
||||||
|
items,
|
||||||
|
&orderItem{
|
||||||
|
product: product,
|
||||||
|
count: item.Count,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
text, err := createOrderText(req, items)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &proto.OrderRsp{}, s.messenger.SendMessage(text)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createOrderText(req *proto.OrderReq, items []*orderItem) (string, error) {
|
||||||
|
buffer := bytes.Buffer{}
|
||||||
|
orderAmount := 0.0
|
||||||
|
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("\n")
|
||||||
|
unit, err := unitToText(item.product.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("\n")
|
||||||
|
}
|
||||||
|
buffer.WriteString("\n")
|
||||||
|
buffer.WriteString(fmt.Sprintf("ИТОГО: %.00fр\n", orderAmount))
|
||||||
|
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":
|
||||||
|
return "кг", nil
|
||||||
|
case "piece":
|
||||||
|
return "шт", nil
|
||||||
|
}
|
||||||
|
return "", errors.New("unit not found")
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package messenger
|
||||||
|
|
||||||
|
type IMessenger interface {
|
||||||
|
SendMessage(message string) error
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package telegram
|
||||||
|
|
||||||
|
import (
|
||||||
|
"cake_crm/internal/models/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
|
||||||
|
}
|
|
@ -1,8 +0,0 @@
|
||||||
package server_web
|
|
||||||
|
|
||||||
import "context"
|
|
||||||
|
|
||||||
type IServer interface {
|
|
||||||
Run(ctx context.Context) error
|
|
||||||
Stop(ctx context.Context) error
|
|
||||||
}
|
|
|
@ -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) {}
|
|
360
proto/main.pb.go
360
proto/main.pb.go
|
@ -823,6 +823,209 @@ func (x *BreadcrumbsRsp) GetCategories() []*Category {
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|
||||||
var File_main_proto protoreflect.FileDescriptor
|
var File_main_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_main_proto_rawDesc = []byte{
|
var file_main_proto_rawDesc = []byte{
|
||||||
|
@ -906,32 +1109,51 @@ var file_main_proto_rawDesc = []byte{
|
||||||
0x72, 0x75, 0x6d, 0x62, 0x73, 0x52, 0x73, 0x70, 0x12, 0x33, 0x0a, 0x0a, 0x63, 0x61, 0x74, 0x65,
|
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,
|
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,
|
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,
|
0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0x5c, 0x0a,
|
||||||
0x0a, 0x03, 0x43, 0x52, 0x4d, 0x12, 0x4f, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x61,
|
0x08, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x05, 0x6f, 0x72, 0x64,
|
||||||
0x6c, 0x6f, 0x67, 0x12, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e,
|
0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73,
|
||||||
0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e,
|
0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x05, 0x6f, 0x72, 0x64, 0x65,
|
||||||
0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f,
|
0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x67, 0x52, 0x73, 0x70, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f, 0x63,
|
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x03,
|
||||||
0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x0a, 0x0a, 0x08, 0x4f,
|
||||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63,
|
0x72, 0x64, 0x65, 0x72, 0x52, 0x73, 0x70, 0x22, 0x33, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72,
|
||||||
0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52,
|
0x12, 0x2a, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||||
0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x50,
|
0x14, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x4f, 0x72, 0x64, 0x65,
|
||||||
0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x73, 0x70, 0x22, 0x17, 0x82, 0xd3, 0xe4,
|
0x72, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x40, 0x0a, 0x09,
|
||||||
0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f,
|
0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f,
|
||||||
0x7b, 0x69, 0x64, 0x7d, 0x12, 0x55, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75,
|
0x64, 0x75, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70,
|
||||||
0x63, 0x74, 0x12, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x47,
|
0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e,
|
||||||
0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x63,
|
0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xbc,
|
||||||
0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74,
|
0x03, 0x0a, 0x03, 0x43, 0x52, 0x4d, 0x12, 0x4f, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74,
|
||||||
0x52, 0x73, 0x70, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x70, 0x72,
|
0x61, 0x6c, 0x6f, 0x67, 0x12, 0x18, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d,
|
||||||
0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x64, 0x0a, 0x0e, 0x47,
|
0x2e, 0x47, 0x65, 0x74, 0x43, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x15,
|
||||||
0x65, 0x74, 0x42, 0x72, 0x65, 0x61, 0x64, 0x63, 0x72, 0x75, 0x6d, 0x62, 0x73, 0x12, 0x1c, 0x2e,
|
0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x43, 0x61, 0x74, 0x61, 0x6c,
|
||||||
0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x72, 0x65,
|
0x6f, 0x67, 0x52, 0x73, 0x70, 0x22, 0x10, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0a, 0x12, 0x08, 0x2f,
|
||||||
0x61, 0x64, 0x63, 0x72, 0x75, 0x6d, 0x62, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x63, 0x72,
|
0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x12, 0x5c, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x50, 0x6f,
|
||||||
0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e, 0x42, 0x72, 0x65, 0x61, 0x64, 0x63, 0x72, 0x75,
|
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1a, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e,
|
||||||
0x6d, 0x62, 0x73, 0x52, 0x73, 0x70, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11,
|
0x63, 0x72, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||||
0x2f, 0x62, 0x72, 0x65, 0x61, 0x64, 0x63, 0x72, 0x75, 0x6d, 0x62, 0x73, 0x2f, 0x7b, 0x69, 0x64,
|
0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x63, 0x72, 0x61, 0x62, 0x73, 0x2e, 0x63, 0x72, 0x6d, 0x2e,
|
||||||
0x7d, 0x42, 0x0e, 0x92, 0x41, 0x00, 0x5a, 0x09, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x73, 0x70, 0x22, 0x17, 0x82, 0xd3,
|
||||||
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -946,7 +1168,7 @@ func file_main_proto_rawDescGZIP() []byte {
|
||||||
return file_main_proto_rawDescData
|
return file_main_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
|
var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 18)
|
||||||
var file_main_proto_goTypes = []interface{}{
|
var file_main_proto_goTypes = []interface{}{
|
||||||
(*GetCatalogReq)(nil), // 0: crabs.crm.GetCatalogReq
|
(*GetCatalogReq)(nil), // 0: crabs.crm.GetCatalogReq
|
||||||
(*CatalogRsp)(nil), // 1: crabs.crm.CatalogRsp
|
(*CatalogRsp)(nil), // 1: crabs.crm.CatalogRsp
|
||||||
|
@ -962,6 +1184,10 @@ var file_main_proto_goTypes = []interface{}{
|
||||||
(*ProductRsp)(nil), // 11: crabs.crm.ProductRsp
|
(*ProductRsp)(nil), // 11: crabs.crm.ProductRsp
|
||||||
(*GetBreadcrumbsReq)(nil), // 12: crabs.crm.GetBreadcrumbsReq
|
(*GetBreadcrumbsReq)(nil), // 12: crabs.crm.GetBreadcrumbsReq
|
||||||
(*BreadcrumbsRsp)(nil), // 13: crabs.crm.BreadcrumbsRsp
|
(*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
|
||||||
}
|
}
|
||||||
var file_main_proto_depIdxs = []int32{
|
var file_main_proto_depIdxs = []int32{
|
||||||
2, // 0: crabs.crm.CatalogRsp.categories:type_name -> crabs.crm.Category
|
2, // 0: crabs.crm.CatalogRsp.categories:type_name -> crabs.crm.Category
|
||||||
|
@ -973,19 +1199,23 @@ var file_main_proto_depIdxs = []int32{
|
||||||
8, // 6: crabs.crm.Variant.properties:type_name -> crabs.crm.Property
|
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
|
2, // 8: crabs.crm.BreadcrumbsRsp.categories:type_name -> crabs.crm.Category
|
||||||
0, // 9: crabs.crm.CRM.GetCatalog:input_type -> crabs.crm.GetCatalogReq
|
16, // 9: crabs.crm.OrderReq.order:type_name -> crabs.crm.Order
|
||||||
3, // 10: crabs.crm.CRM.GetPositions:input_type -> crabs.crm.GetPositionsReq
|
17, // 10: crabs.crm.Order.items:type_name -> crabs.crm.OrderItem
|
||||||
10, // 11: crabs.crm.CRM.GetProduct:input_type -> crabs.crm.GetProductReq
|
0, // 11: crabs.crm.CRM.GetCatalog:input_type -> crabs.crm.GetCatalogReq
|
||||||
12, // 12: crabs.crm.CRM.GetBreadcrumbs:input_type -> crabs.crm.GetBreadcrumbsReq
|
3, // 12: crabs.crm.CRM.GetPositions:input_type -> crabs.crm.GetPositionsReq
|
||||||
1, // 13: crabs.crm.CRM.GetCatalog:output_type -> crabs.crm.CatalogRsp
|
10, // 13: crabs.crm.CRM.GetProduct:input_type -> crabs.crm.GetProductReq
|
||||||
4, // 14: crabs.crm.CRM.GetPositions:output_type -> crabs.crm.PositionsRsp
|
12, // 14: crabs.crm.CRM.GetBreadcrumbs:input_type -> crabs.crm.GetBreadcrumbsReq
|
||||||
11, // 15: crabs.crm.CRM.GetProduct:output_type -> crabs.crm.ProductRsp
|
14, // 15: crabs.crm.CRM.Order:input_type -> crabs.crm.OrderReq
|
||||||
13, // 16: crabs.crm.CRM.GetBreadcrumbs:output_type -> crabs.crm.BreadcrumbsRsp
|
1, // 16: crabs.crm.CRM.GetCatalog:output_type -> crabs.crm.CatalogRsp
|
||||||
13, // [13:17] is the sub-list for method output_type
|
4, // 17: crabs.crm.CRM.GetPositions:output_type -> crabs.crm.PositionsRsp
|
||||||
9, // [9:13] is the sub-list for method input_type
|
11, // 18: crabs.crm.CRM.GetProduct:output_type -> crabs.crm.ProductRsp
|
||||||
9, // [9:9] is the sub-list for extension type_name
|
13, // 19: crabs.crm.CRM.GetBreadcrumbs:output_type -> crabs.crm.BreadcrumbsRsp
|
||||||
9, // [9:9] is the sub-list for extension extendee
|
15, // 20: crabs.crm.CRM.Order:output_type -> crabs.crm.OrderRsp
|
||||||
0, // [0:9] is the sub-list for field type_name
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_main_proto_init() }
|
func init() { file_main_proto_init() }
|
||||||
|
@ -1162,6 +1392,54 @@ func file_main_proto_init() {
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
type x struct{}
|
type x struct{}
|
||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
|
@ -1169,7 +1447,7 @@ func file_main_proto_init() {
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_main_proto_rawDesc,
|
RawDescriptor: file_main_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 14,
|
NumMessages: 18,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|
|
@ -205,6 +205,50 @@ 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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// RegisterCRMHandlerServer registers the http handlers for service CRM to "mux".
|
// RegisterCRMHandlerServer registers the http handlers for service CRM to "mux".
|
||||||
// UnaryRPC :call CRMServer directly.
|
// UnaryRPC :call CRMServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||||
|
@ -311,6 +355,31 @@ 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()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,6 +509,28 @@ 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()...)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,6 +542,8 @@ var (
|
||||||
pattern_CRM_GetProduct_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"products", "id"}, ""))
|
pattern_CRM_GetProduct_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"products", "id"}, ""))
|
||||||
|
|
||||||
pattern_CRM_GetBreadcrumbs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"breadcrumbs", "id"}, ""))
|
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"}, ""))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -461,4 +554,6 @@ var (
|
||||||
forward_CRM_GetProduct_0 = runtime.ForwardResponseMessage
|
forward_CRM_GetProduct_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
forward_CRM_GetBreadcrumbs_0 = runtime.ForwardResponseMessage
|
forward_CRM_GetBreadcrumbs_0 = runtime.ForwardResponseMessage
|
||||||
|
|
||||||
|
forward_CRM_Order_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,7 @@ const (
|
||||||
CRM_GetPositions_FullMethodName = "/crabs.crm.CRM/GetPositions"
|
CRM_GetPositions_FullMethodName = "/crabs.crm.CRM/GetPositions"
|
||||||
CRM_GetProduct_FullMethodName = "/crabs.crm.CRM/GetProduct"
|
CRM_GetProduct_FullMethodName = "/crabs.crm.CRM/GetProduct"
|
||||||
CRM_GetBreadcrumbs_FullMethodName = "/crabs.crm.CRM/GetBreadcrumbs"
|
CRM_GetBreadcrumbs_FullMethodName = "/crabs.crm.CRM/GetBreadcrumbs"
|
||||||
|
CRM_Order_FullMethodName = "/crabs.crm.CRM/Order"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CRMClient is the client API for CRM service.
|
// CRMClient is the client API for CRM service.
|
||||||
|
@ -33,6 +34,7 @@ type CRMClient interface {
|
||||||
GetPositions(ctx context.Context, in *GetPositionsReq, opts ...grpc.CallOption) (*PositionsRsp, error)
|
GetPositions(ctx context.Context, in *GetPositionsReq, opts ...grpc.CallOption) (*PositionsRsp, error)
|
||||||
GetProduct(ctx context.Context, in *GetProductReq, opts ...grpc.CallOption) (*ProductRsp, error)
|
GetProduct(ctx context.Context, in *GetProductReq, opts ...grpc.CallOption) (*ProductRsp, error)
|
||||||
GetBreadcrumbs(ctx context.Context, in *GetBreadcrumbsReq, opts ...grpc.CallOption) (*BreadcrumbsRsp, error)
|
GetBreadcrumbs(ctx context.Context, in *GetBreadcrumbsReq, opts ...grpc.CallOption) (*BreadcrumbsRsp, error)
|
||||||
|
Order(ctx context.Context, in *OrderReq, opts ...grpc.CallOption) (*OrderRsp, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type cRMClient struct {
|
type cRMClient struct {
|
||||||
|
@ -79,6 +81,15 @@ func (c *cRMClient) GetBreadcrumbs(ctx context.Context, in *GetBreadcrumbsReq, o
|
||||||
return out, nil
|
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
|
||||||
|
}
|
||||||
|
|
||||||
// CRMServer is the server API for CRM service.
|
// CRMServer is the server API for CRM service.
|
||||||
// All implementations must embed UnimplementedCRMServer
|
// All implementations must embed UnimplementedCRMServer
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
|
@ -87,6 +98,7 @@ type CRMServer interface {
|
||||||
GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error)
|
GetPositions(context.Context, *GetPositionsReq) (*PositionsRsp, error)
|
||||||
GetProduct(context.Context, *GetProductReq) (*ProductRsp, error)
|
GetProduct(context.Context, *GetProductReq) (*ProductRsp, error)
|
||||||
GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error)
|
GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error)
|
||||||
|
Order(context.Context, *OrderReq) (*OrderRsp, error)
|
||||||
mustEmbedUnimplementedCRMServer()
|
mustEmbedUnimplementedCRMServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +118,9 @@ func (UnimplementedCRMServer) GetProduct(context.Context, *GetProductReq) (*Prod
|
||||||
func (UnimplementedCRMServer) GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error) {
|
func (UnimplementedCRMServer) GetBreadcrumbs(context.Context, *GetBreadcrumbsReq) (*BreadcrumbsRsp, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetBreadcrumbs not implemented")
|
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) mustEmbedUnimplementedCRMServer() {}
|
func (UnimplementedCRMServer) mustEmbedUnimplementedCRMServer() {}
|
||||||
|
|
||||||
// UnsafeCRMServer may be embedded to opt out of forward compatibility for this service.
|
// UnsafeCRMServer may be embedded to opt out of forward compatibility for this service.
|
||||||
|
@ -191,6 +206,24 @@ func _CRM_GetBreadcrumbs_Handler(srv interface{}, ctx context.Context, dec func(
|
||||||
return interceptor(ctx, in, info, handler)
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
// CRM_ServiceDesc is the grpc.ServiceDesc for CRM service.
|
// CRM_ServiceDesc is the grpc.ServiceDesc for CRM service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
|
@ -214,6 +247,10 @@ var CRM_ServiceDesc = grpc.ServiceDesc{
|
||||||
MethodName: "GetBreadcrumbs",
|
MethodName: "GetBreadcrumbs",
|
||||||
Handler: _CRM_GetBreadcrumbs_Handler,
|
Handler: _CRM_GetBreadcrumbs_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "Order",
|
||||||
|
Handler: _CRM_Order_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "main.proto",
|
Metadata: "main.proto",
|
||||||
|
|
|
@ -69,6 +69,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}": {
|
"/positions/{id}": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "CRM_GetPositions",
|
"operationId": "CRM_GetPositions",
|
||||||
|
@ -133,6 +177,18 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
"crabscrmOrder": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"items": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"$ref": "#/definitions/crmOrderItem"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"crmBreadcrumbsRsp": {
|
"crmBreadcrumbsRsp": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -204,6 +260,22 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"crmOrderItem": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"productId": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
"count": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "int64"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"crmOrderRsp": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"crmPositionsRsp": {
|
"crmPositionsRsp": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
Loading…
Reference in New Issue