From e547a46b90fe1ced019f4b74ae4e1c0fe8d3f640 Mon Sep 17 00:00:00 2001 From: wangpengfei <274878379@qq.com> Date: 星期六, 26 八月 2023 14:07:40 +0800 Subject: [PATCH] add --- .gitignore | 14 proto/product.proto | 43 ++ proto/product/product.pb.go | 565 +++++++++++++++++++++++++++++++++++++ proto/product/product_grpc.pb.go | 146 +++++++++ api/v1/test/product.go | 75 +++++ 5 files changed, 829 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index e2b35d7..4cfec98 100644 --- a/.gitignore +++ b/.gitignore @@ -21,19 +21,5 @@ *.exe *.test -/resource/* -/resource/plug_template/api/api.go.tpl -/resource/autocode_template/web/api.js.tpl -/resource/page/js/app.9fe02340.js -/resource/autocode_template/subcontract/api_enter.go.tpl -/resource/page/css/app.7832f89c.css -/resource/page/js/chunk-vendors.2e7c88f1.js -/resource/page/css/chunk-vendors.a16c4353.css -/resource/plug_template/config/config.go.tpl -/resource/page/fonts/element-icons.535877f5.woff -/resource/page/fonts/element-icons.732389de.ttf -/resource/plug_template/api/enter.go.tpl -/resource/plug_template/router/enter.go.tpl -/resource/plug_template/service/enter.go.tpl /log/* diff --git a/api/v1/test/product.go b/api/v1/test/product.go index c7b7457..fcec2e1 100644 --- a/api/v1/test/product.go +++ b/api/v1/test/product.go @@ -2,12 +2,15 @@ import ( "github.com/gin-gonic/gin" + "github.com/spf13/cast" "go.uber.org/zap" + "google.golang.org/grpc" "srm/global" "srm/model/common/request" "srm/model/common/response" "srm/model/test" testReq "srm/model/test/request" + "srm/proto/product" "srm/service" ) @@ -164,3 +167,75 @@ }, "鑾峰彇鎴愬姛", c) } } + +var ( + productServiceConn *grpc.ClientConn +) + +//func InitProductServiceConn() { +// var err error +// productServiceConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.Aps, grpc.WithTransportCredentials(insecure.NewCredentials())) +// if err != nil { +// logx.Errorf("grpc dial product service error: %v", err.Error()) +// return +// } +//} + +func CloseProductServiceConn() { + if productServiceConn != nil { + productServiceConn.Close() + } +} + +// GetProductListFromGrpc 鍒嗛〉鑾峰彇Product鍒楄〃 +// @Tags Product +// @Summary 鍒嗛〉鑾峰彇Product鍒楄〃 +// @Security ApiKeyAuth +// @accept application/json +// @Produce application/json +// @Param data query testReq.ProductSearch true "鍒嗛〉鑾峰彇Product鍒楄〃" +// @Success 200 {string} string "{"success":true,"data":{},"msg":"鑾峰彇鎴愬姛"}" +// @Router /p/getProductListFromGrpc [get] +func (pApi *ProductApi) GetProductListFromGrpc(c *gin.Context) { + var pageInfo testReq.ProductSearch + err := c.ShouldBindQuery(&pageInfo) + if err != nil { + response.FailWithMessage(err.Error(), c) + return + } + + cli := product.NewProductServiceClient(productServiceConn) + getProductListResponse, err := cli.GetProductList(c, &product.GetProductListRequest{ + Page: cast.ToInt32(pageInfo.Page), + PageSize: cast.ToInt32(pageInfo.PageSize), + ProductNumber: pageInfo.Number, + ProductName: pageInfo.Name, + }) + rawProductList := getProductListResponse.List + productList := make([]test.Product, len(rawProductList)) + + for k, v := range rawProductList { + productList[k].Number = v.Number + productList[k].Name = v.Name + productList[k].Unit = v.Unit + productList[k].PurchasePrice = &v.SalePrice + //productList[k].MinimumStock = &v.SalePrice + //productList[k].MaximumStock = &v.SalePrice + //productList[k].Remark = &v.SalePrice + productList[k].ProductType = v.MaterialMode + } + + if err != nil || getProductListResponse.Code != 0 { + global.GVA_LOG.Error("鑾峰彇澶辫触!", zap.Error(err)) + response.FailWithMessage("鑾峰彇澶辫触", c) + return + } + + response.OkWithDetailed(response.PageResult{ + List: productList, + Total: 0, + Page: pageInfo.Page, + PageSize: pageInfo.PageSize, + }, "鑾峰彇鎴愬姛", c) + +} diff --git a/proto/product.proto b/proto/product.proto new file mode 100644 index 0000000..bf9d1dd --- /dev/null +++ b/proto/product.proto @@ -0,0 +1,43 @@ +syntax = "proto3"; + +option go_package = "./product"; + +service productService { + rpc GetProductInfo(GetProductInfoRequest) returns(GetProductInfoResponse) {} + rpc GetProductList(GetProductListRequest) returns(GetProductListResponse) {} +} + +message GetProductInfoRequest{ + string ProductId = 1; //浜у搧id +} + +message GetProductInfoResponse{ + int32 Code = 1; + string Msg = 2; + Product Data = 3; +} +message Product { + string Number = 1; + string Name = 2; + string Unit = 3; + bool IsSale = 4; //鏄惁閿�鍞� + double SalePrice = 5; //閿�鍞环鏍� + float Amount = 6;//搴撳瓨鍓╀綑閲� + int32 MinInventory = 7;//瀹夊叏搴撳瓨 + string MaterialMode = 8; //鐗╂枡绫诲瀷 + string PurchaseType = 9;//閲囪喘绫诲瀷 +} + +message GetProductListRequest{ + int32 page = 1; + int32 pageSize = 2; + string ProductNumber = 3; + string ProductName = 4; +} + +message GetProductListResponse{ + int32 Code = 1; + string Msg = 2; + repeated Product List = 3; + int64 Total = 4; +} \ No newline at end of file diff --git a/proto/product/product.pb.go b/proto/product/product.pb.go new file mode 100644 index 0000000..fa286ea --- /dev/null +++ b/proto/product/product.pb.go @@ -0,0 +1,565 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.0 +// source: product.proto + +package product + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type GetProductInfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProductId string `protobuf:"bytes,1,opt,name=ProductId,proto3" json:"ProductId,omitempty"` //浜у搧id +} + +func (x *GetProductInfoRequest) Reset() { + *x = GetProductInfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductInfoRequest) ProtoMessage() {} + +func (x *GetProductInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[0] + 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 GetProductInfoRequest.ProtoReflect.Descriptor instead. +func (*GetProductInfoRequest) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{0} +} + +func (x *GetProductInfoRequest) GetProductId() string { + if x != nil { + return x.ProductId + } + return "" +} + +type GetProductInfoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` + Data *Product `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` +} + +func (x *GetProductInfoResponse) Reset() { + *x = GetProductInfoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductInfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductInfoResponse) ProtoMessage() {} + +func (x *GetProductInfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[1] + 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 GetProductInfoResponse.ProtoReflect.Descriptor instead. +func (*GetProductInfoResponse) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{1} +} + +func (x *GetProductInfoResponse) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *GetProductInfoResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *GetProductInfoResponse) GetData() *Product { + if x != nil { + return x.Data + } + return nil +} + +type Product struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Number string `protobuf:"bytes,1,opt,name=Number,proto3" json:"Number,omitempty"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` + Unit string `protobuf:"bytes,3,opt,name=Unit,proto3" json:"Unit,omitempty"` + IsSale bool `protobuf:"varint,4,opt,name=IsSale,proto3" json:"IsSale,omitempty"` //鏄惁閿�鍞� + SalePrice float64 `protobuf:"fixed64,5,opt,name=SalePrice,proto3" json:"SalePrice,omitempty"` //閿�鍞环鏍� + Amount float32 `protobuf:"fixed32,6,opt,name=Amount,proto3" json:"Amount,omitempty"` //搴撳瓨鍓╀綑閲� + MinInventory int32 `protobuf:"varint,7,opt,name=MinInventory,proto3" json:"MinInventory,omitempty"` //瀹夊叏搴撳瓨 + MaterialMode string `protobuf:"bytes,8,opt,name=MaterialMode,proto3" json:"MaterialMode,omitempty"` //鐗╂枡绫诲瀷 + PurchaseType string `protobuf:"bytes,9,opt,name=PurchaseType,proto3" json:"PurchaseType,omitempty"` //閲囪喘绫诲瀷 +} + +func (x *Product) Reset() { + *x = Product{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Product) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Product) ProtoMessage() {} + +func (x *Product) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[2] + 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 Product.ProtoReflect.Descriptor instead. +func (*Product) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{2} +} + +func (x *Product) GetNumber() string { + if x != nil { + return x.Number + } + return "" +} + +func (x *Product) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Product) GetUnit() string { + if x != nil { + return x.Unit + } + return "" +} + +func (x *Product) GetIsSale() bool { + if x != nil { + return x.IsSale + } + return false +} + +func (x *Product) GetSalePrice() float64 { + if x != nil { + return x.SalePrice + } + return 0 +} + +func (x *Product) GetAmount() float32 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *Product) GetMinInventory() int32 { + if x != nil { + return x.MinInventory + } + return 0 +} + +func (x *Product) GetMaterialMode() string { + if x != nil { + return x.MaterialMode + } + return "" +} + +func (x *Product) GetPurchaseType() string { + if x != nil { + return x.PurchaseType + } + return "" +} + +type GetProductListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"` + ProductNumber string `protobuf:"bytes,3,opt,name=ProductNumber,proto3" json:"ProductNumber,omitempty"` + ProductName string `protobuf:"bytes,4,opt,name=ProductName,proto3" json:"ProductName,omitempty"` +} + +func (x *GetProductListRequest) Reset() { + *x = GetProductListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductListRequest) ProtoMessage() {} + +func (x *GetProductListRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[3] + 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 GetProductListRequest.ProtoReflect.Descriptor instead. +func (*GetProductListRequest) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{3} +} + +func (x *GetProductListRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *GetProductListRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *GetProductListRequest) GetProductNumber() string { + if x != nil { + return x.ProductNumber + } + return "" +} + +func (x *GetProductListRequest) GetProductName() string { + if x != nil { + return x.ProductName + } + return "" +} + +type GetProductListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` + List []*Product `protobuf:"bytes,3,rep,name=List,proto3" json:"List,omitempty"` + Total int64 `protobuf:"varint,4,opt,name=Total,proto3" json:"Total,omitempty"` +} + +func (x *GetProductListResponse) Reset() { + *x = GetProductListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductListResponse) ProtoMessage() {} + +func (x *GetProductListResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_proto_msgTypes[4] + 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 GetProductListResponse.ProtoReflect.Descriptor instead. +func (*GetProductListResponse) Descriptor() ([]byte, []int) { + return file_product_proto_rawDescGZIP(), []int{4} +} + +func (x *GetProductListResponse) GetCode() int32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *GetProductListResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +func (x *GetProductListResponse) GetList() []*Product { + if x != nil { + return x.List + } + return nil +} + +func (x *GetProductListResponse) GetTotal() int64 { + if x != nil { + return x.Total + } + return 0 +} + +var File_product_proto protoreflect.FileDescriptor + +var file_product_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x35, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x5c, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, + 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x04, + 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x02, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x55, 0x6e, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x6e, 0x69, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x06, 0x49, 0x73, 0x53, 0x61, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x61, 0x6c, 0x65, + 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x01, 0x52, 0x09, 0x53, 0x61, 0x6c, + 0x65, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, + 0x0a, 0x0c, 0x4d, 0x69, 0x6e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x4d, 0x69, 0x6e, 0x49, 0x6e, 0x76, 0x65, 0x6e, 0x74, 0x6f, + 0x72, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x4d, 0x6f, + 0x64, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, + 0x61, 0x6c, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, + 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x50, 0x75, + 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x15, 0x47, + 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x72, 0x0a, 0x16, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, + 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x1c, 0x0a, 0x04, + 0x4c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x52, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, + 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x54, 0x6f, 0x74, 0x61, 0x6c, + 0x32, 0x9a, 0x01, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, + 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x47, 0x65, 0x74, + 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0b, 0x5a, + 0x09, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_product_proto_rawDescOnce sync.Once + file_product_proto_rawDescData = file_product_proto_rawDesc +) + +func file_product_proto_rawDescGZIP() []byte { + file_product_proto_rawDescOnce.Do(func() { + file_product_proto_rawDescData = protoimpl.X.CompressGZIP(file_product_proto_rawDescData) + }) + return file_product_proto_rawDescData +} + +var file_product_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_product_proto_goTypes = []interface{}{ + (*GetProductInfoRequest)(nil), // 0: GetProductInfoRequest + (*GetProductInfoResponse)(nil), // 1: GetProductInfoResponse + (*Product)(nil), // 2: Product + (*GetProductListRequest)(nil), // 3: GetProductListRequest + (*GetProductListResponse)(nil), // 4: GetProductListResponse +} +var file_product_proto_depIdxs = []int32{ + 2, // 0: GetProductInfoResponse.Data:type_name -> Product + 2, // 1: GetProductListResponse.List:type_name -> Product + 0, // 2: productService.GetProductInfo:input_type -> GetProductInfoRequest + 3, // 3: productService.GetProductList:input_type -> GetProductListRequest + 1, // 4: productService.GetProductInfo:output_type -> GetProductInfoResponse + 4, // 5: productService.GetProductList:output_type -> GetProductListResponse + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_product_proto_init() } +func file_product_proto_init() { + if File_product_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_product_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductInfoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Product); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductListResponse); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_product_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_product_proto_goTypes, + DependencyIndexes: file_product_proto_depIdxs, + MessageInfos: file_product_proto_msgTypes, + }.Build() + File_product_proto = out.File + file_product_proto_rawDesc = nil + file_product_proto_goTypes = nil + file_product_proto_depIdxs = nil +} diff --git a/proto/product/product_grpc.pb.go b/proto/product/product_grpc.pb.go new file mode 100644 index 0000000..16e851e --- /dev/null +++ b/proto/product/product_grpc.pb.go @@ -0,0 +1,146 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.19.0 +// source: product.proto + +package product + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + ProductService_GetProductInfo_FullMethodName = "/productService/GetProductInfo" + ProductService_GetProductList_FullMethodName = "/productService/GetProductList" +) + +// ProductServiceClient is the client API for ProductService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ProductServiceClient interface { + GetProductInfo(ctx context.Context, in *GetProductInfoRequest, opts ...grpc.CallOption) (*GetProductInfoResponse, error) + GetProductList(ctx context.Context, in *GetProductListRequest, opts ...grpc.CallOption) (*GetProductListResponse, error) +} + +type productServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { + return &productServiceClient{cc} +} + +func (c *productServiceClient) GetProductInfo(ctx context.Context, in *GetProductInfoRequest, opts ...grpc.CallOption) (*GetProductInfoResponse, error) { + out := new(GetProductInfoResponse) + err := c.cc.Invoke(ctx, ProductService_GetProductInfo_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productServiceClient) GetProductList(ctx context.Context, in *GetProductListRequest, opts ...grpc.CallOption) (*GetProductListResponse, error) { + out := new(GetProductListResponse) + err := c.cc.Invoke(ctx, ProductService_GetProductList_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ProductServiceServer is the server API for ProductService service. +// All implementations must embed UnimplementedProductServiceServer +// for forward compatibility +type ProductServiceServer interface { + GetProductInfo(context.Context, *GetProductInfoRequest) (*GetProductInfoResponse, error) + GetProductList(context.Context, *GetProductListRequest) (*GetProductListResponse, error) + mustEmbedUnimplementedProductServiceServer() +} + +// UnimplementedProductServiceServer must be embedded to have forward compatible implementations. +type UnimplementedProductServiceServer struct { +} + +func (UnimplementedProductServiceServer) GetProductInfo(context.Context, *GetProductInfoRequest) (*GetProductInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProductInfo not implemented") +} +func (UnimplementedProductServiceServer) GetProductList(context.Context, *GetProductListRequest) (*GetProductListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProductList not implemented") +} +func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} + +// UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ProductServiceServer will +// result in compilation errors. +type UnsafeProductServiceServer interface { + mustEmbedUnimplementedProductServiceServer() +} + +func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { + s.RegisterService(&ProductService_ServiceDesc, srv) +} + +func _ProductService_GetProductInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProductInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).GetProductInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ProductService_GetProductInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).GetProductInfo(ctx, req.(*GetProductInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ProductService_GetProductList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProductListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).GetProductList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ProductService_GetProductList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).GetProductList(ctx, req.(*GetProductListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ProductService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "productService", + HandlerType: (*ProductServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetProductInfo", + Handler: _ProductService_GetProductInfo_Handler, + }, + { + MethodName: "GetProductList", + Handler: _ProductService_GetProductList_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "product.proto", +} -- Gitblit v1.8.0