瀏覽代碼

如何强制嵌入结构

duyong mac 2 月之前
父節點
當前提交
cc7a04ddc7

二進制
dyrpc/.DS_Store


+ 8 - 1
dyrpc/client/client.go

@@ -29,7 +29,7 @@ func main() {
 	defer conn.Close()
 
 	client := prod.NewProdServiceClient(conn)
-	res, err := client.GetProdStock(context.Background(), &prod.ProdRequest{ProdId: 100})
+	res, err := client.GetProdStock(context.Background(), &prod.ProdRequest{ProdId: 100, ProdArea: prod.ProdArea_C})
 	if err != nil {
 		log.Fatal(err)
 	}
@@ -43,4 +43,11 @@ func main() {
 		log.Fatal(err)
 	}
 	fmt.Println(prodList.ProdRes)
+
+	prodInfo, err := client.GetProdInfo(context.Background(), &prod.ProdRequest{ProdId: 100, ProdArea: prod.ProdArea_C})
+	if err != nil {
+		log.Fatal(err)
+	}
+	fmt.Println(prodInfo)
+
 }

+ 2 - 0
dyrpc/prod.sh

@@ -1,5 +1,7 @@
 #!/bin/bash
 
 cd ./proto
+protoc --go_out=../services --go-grpc_out=../services   models.proto
 protoc --go_out=../services --go-grpc_out=../services   prod.proto
+protoc --go_out=../services --go-grpc_out=../services   order.proto
 cd ..

+ 20 - 0
dyrpc/proto/models.proto

@@ -0,0 +1,20 @@
+syntax="proto3";
+package  services;
+
+option go_package = "/prod";
+
+import "google/protobuf/timestamp.proto";
+
+message ProdModel {
+  int32 prod_id = 1;
+  string prod_name = 2;
+  float  prod_price = 3;
+}
+
+message ProdMain {
+  int32  order_id = 1;
+  string order_no = 2;
+  int32  user_id = 3;
+  float  order_money=4;
+  google.protobuf.Timestamp order_time=5;
+}

+ 17 - 0
dyrpc/proto/order.proto

@@ -0,0 +1,17 @@
+syntax="proto3";
+package  services;
+
+option go_package = "/prod";
+
+import "google/api/annotations.proto";
+import "models.proto";
+
+
+message OrderResponse{
+  string status=1;
+  string message=2;
+}
+
+service OrderService{
+  rpc NewOrder(ProdMain)returns(OrderResponse){}
+}

+ 3 - 2
dyrpc/proto/prod.proto

@@ -4,6 +4,7 @@ package  services;
 option go_package = "/prod";
 
 import "google/api/annotations.proto";
+import "models.proto";
 
 enum ProdArea{
   A=0;
@@ -36,8 +37,8 @@ service ProdService {
     };
   }
 
-  rpc GetProdStocks(QueryProdStocks)returns(ProdStockList){
+  rpc GetProdStocks(QueryProdStocks)returns(ProdStockList){}
 
-  }
+  rpc GetProdInfo(ProdRequest)returns(ProdModel){}
 }
 

+ 34 - 0
dyrpc/proto语法.md

@@ -18,7 +18,41 @@ message ProdStockList {
 ## 枚举
 
 ```protobuf
+syntax="proto3";
+enum ProdArea{
+  A=0;
+  B=1;
+  C=2;
+}
 
+message ProdRequest {
+  int32 prod_id = 1;
+  ProdArea prod_area = 2;
+}
 ```
+## 外部文件引用
+
+```protobuf
+syntax="proto3";
 
+package  services;
 
+option go_package = "/prod";
+
+message ProdModel {
+  int32 prod_id = 1;
+  string prod_name = 2;
+  float  prod_price = 3;
+}
+```
+
+
+```protobuf
+syntax="proto3";
+package  services;
+import "google/api/annotations.proto";
+import "models.proto";
+
+rpc GetProdInfo(ProdRequest)returns(ProdModel){}
+ // 注意在同一包下时可以这样使用,如果models.proto中声明的package不是services包,则在使用时应该用 包名.ProdModel
+```

+ 20 - 0
dyrpc/services/order_service.go

@@ -0,0 +1,20 @@
+package services
+
+import (
+	"context"
+	"dy-test/dyrpc/services/prod"
+)
+
+type OrderService struct {
+	prod.UnimplementedOrderServiceServer
+}
+
+func (o *OrderService) NewOrder(ctx context.Context, main *prod.ProdMain) (*prod.OrderResponse, error) {
+	//TODO implement me
+	panic("implement me")
+}
+
+func (o *OrderService) mustEmbedUnimplementedOrderServiceServer() {
+	//TODO implement me
+	panic("implement me")
+}

+ 270 - 0
dyrpc/services/prod/models.pb.go

@@ -0,0 +1,270 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.34.0
+// 	protoc        v5.26.1
+// source: models.proto
+
+package prod
+
+import (
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	timestamppb "google.golang.org/protobuf/types/known/timestamppb"
+	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 ProdModel struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ProdId    int32   `protobuf:"varint,1,opt,name=prod_id,json=prodId,proto3" json:"prod_id,omitempty"`
+	ProdName  string  `protobuf:"bytes,2,opt,name=prod_name,json=prodName,proto3" json:"prod_name,omitempty"`
+	ProdPrice float32 `protobuf:"fixed32,3,opt,name=prod_price,json=prodPrice,proto3" json:"prod_price,omitempty"`
+}
+
+func (x *ProdModel) Reset() {
+	*x = ProdModel{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_models_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ProdModel) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ProdModel) ProtoMessage() {}
+
+func (x *ProdModel) ProtoReflect() protoreflect.Message {
+	mi := &file_models_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 ProdModel.ProtoReflect.Descriptor instead.
+func (*ProdModel) Descriptor() ([]byte, []int) {
+	return file_models_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *ProdModel) GetProdId() int32 {
+	if x != nil {
+		return x.ProdId
+	}
+	return 0
+}
+
+func (x *ProdModel) GetProdName() string {
+	if x != nil {
+		return x.ProdName
+	}
+	return ""
+}
+
+func (x *ProdModel) GetProdPrice() float32 {
+	if x != nil {
+		return x.ProdPrice
+	}
+	return 0
+}
+
+type ProdMain struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	OrderId    int32                  `protobuf:"varint,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
+	OrderNo    string                 `protobuf:"bytes,2,opt,name=order_no,json=orderNo,proto3" json:"order_no,omitempty"`
+	UserId     int32                  `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
+	OrderMoney float32                `protobuf:"fixed32,4,opt,name=order_money,json=orderMoney,proto3" json:"order_money,omitempty"`
+	OrderTime  *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=order_time,json=orderTime,proto3" json:"order_time,omitempty"`
+}
+
+func (x *ProdMain) Reset() {
+	*x = ProdMain{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_models_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ProdMain) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ProdMain) ProtoMessage() {}
+
+func (x *ProdMain) ProtoReflect() protoreflect.Message {
+	mi := &file_models_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 ProdMain.ProtoReflect.Descriptor instead.
+func (*ProdMain) Descriptor() ([]byte, []int) {
+	return file_models_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *ProdMain) GetOrderId() int32 {
+	if x != nil {
+		return x.OrderId
+	}
+	return 0
+}
+
+func (x *ProdMain) GetOrderNo() string {
+	if x != nil {
+		return x.OrderNo
+	}
+	return ""
+}
+
+func (x *ProdMain) GetUserId() int32 {
+	if x != nil {
+		return x.UserId
+	}
+	return 0
+}
+
+func (x *ProdMain) GetOrderMoney() float32 {
+	if x != nil {
+		return x.OrderMoney
+	}
+	return 0
+}
+
+func (x *ProdMain) GetOrderTime() *timestamppb.Timestamp {
+	if x != nil {
+		return x.OrderTime
+	}
+	return nil
+}
+
+var File_models_proto protoreflect.FileDescriptor
+
+var file_models_proto_rawDesc = []byte{
+	0x0a, 0x0c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08,
+	0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
+	0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
+	0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x60, 0x0a, 0x09, 0x50, 0x72, 0x6f,
+	0x64, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x5f, 0x69,
+	0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x64, 0x49, 0x64, 0x12,
+	0x1b, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a,
+	0x70, 0x72, 0x6f, 0x64, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02,
+	0x52, 0x09, 0x70, 0x72, 0x6f, 0x64, 0x50, 0x72, 0x69, 0x63, 0x65, 0x22, 0xb5, 0x01, 0x0a, 0x08,
+	0x50, 0x72, 0x6f, 0x64, 0x4d, 0x61, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65,
+	0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65,
+	0x72, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x6e, 0x6f, 0x18,
+	0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x12, 0x17,
+	0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
+	0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x6f, 0x72, 0x64, 0x65, 0x72,
+	0x5f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x6f, 0x72,
+	0x64, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x6f, 0x72, 0x64, 0x65,
+	0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67,
+	0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54,
+	0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x54,
+	0x69, 0x6d, 0x65, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x62, 0x06, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_models_proto_rawDescOnce sync.Once
+	file_models_proto_rawDescData = file_models_proto_rawDesc
+)
+
+func file_models_proto_rawDescGZIP() []byte {
+	file_models_proto_rawDescOnce.Do(func() {
+		file_models_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_proto_rawDescData)
+	})
+	return file_models_proto_rawDescData
+}
+
+var file_models_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_models_proto_goTypes = []interface{}{
+	(*ProdModel)(nil),             // 0: services.ProdModel
+	(*ProdMain)(nil),              // 1: services.ProdMain
+	(*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp
+}
+var file_models_proto_depIdxs = []int32{
+	2, // 0: services.ProdMain.order_time:type_name -> google.protobuf.Timestamp
+	1, // [1:1] is the sub-list for method output_type
+	1, // [1:1] is the sub-list for method input_type
+	1, // [1:1] is the sub-list for extension type_name
+	1, // [1:1] is the sub-list for extension extendee
+	0, // [0:1] is the sub-list for field type_name
+}
+
+func init() { file_models_proto_init() }
+func file_models_proto_init() {
+	if File_models_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_models_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ProdModel); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_models_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ProdMain); 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_models_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   0,
+		},
+		GoTypes:           file_models_proto_goTypes,
+		DependencyIndexes: file_models_proto_depIdxs,
+		MessageInfos:      file_models_proto_msgTypes,
+	}.Build()
+	File_models_proto = out.File
+	file_models_proto_rawDesc = nil
+	file_models_proto_goTypes = nil
+	file_models_proto_depIdxs = nil
+}

+ 164 - 0
dyrpc/services/prod/order.pb.go

@@ -0,0 +1,164 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.34.0
+// 	protoc        v5.26.1
+// source: order.proto
+
+package prod
+
+import (
+	_ "google.golang.org/genproto/googleapis/api/annotations"
+	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 OrderResponse struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Status  string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
+	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
+}
+
+func (x *OrderResponse) Reset() {
+	*x = OrderResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_order_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *OrderResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OrderResponse) ProtoMessage() {}
+
+func (x *OrderResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_order_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 OrderResponse.ProtoReflect.Descriptor instead.
+func (*OrderResponse) Descriptor() ([]byte, []int) {
+	return file_order_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *OrderResponse) GetStatus() string {
+	if x != nil {
+		return x.Status
+	}
+	return ""
+}
+
+func (x *OrderResponse) GetMessage() string {
+	if x != nil {
+		return x.Message
+	}
+	return ""
+}
+
+var File_order_proto protoreflect.FileDescriptor
+
+var file_order_proto_rawDesc = []byte{
+	0x0a, 0x0b, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x73,
+	0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,
+	0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x22, 0x41, 0x0a, 0x0d, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
+	0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07,
+	0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x49, 0x0a, 0x0c, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53,
+	0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x08, 0x4e, 0x65, 0x77, 0x4f, 0x72, 0x64,
+	0x65, 0x72, 0x12, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72,
+	0x6f, 0x64, 0x4d, 0x61, 0x69, 0x6e, 0x1a, 0x17, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
+	0x73, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
+	0x00, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
+	0x6f, 0x33,
+}
+
+var (
+	file_order_proto_rawDescOnce sync.Once
+	file_order_proto_rawDescData = file_order_proto_rawDesc
+)
+
+func file_order_proto_rawDescGZIP() []byte {
+	file_order_proto_rawDescOnce.Do(func() {
+		file_order_proto_rawDescData = protoimpl.X.CompressGZIP(file_order_proto_rawDescData)
+	})
+	return file_order_proto_rawDescData
+}
+
+var file_order_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
+var file_order_proto_goTypes = []interface{}{
+	(*OrderResponse)(nil), // 0: services.OrderResponse
+	(*ProdMain)(nil),      // 1: services.ProdMain
+}
+var file_order_proto_depIdxs = []int32{
+	1, // 0: services.OrderService.NewOrder:input_type -> services.ProdMain
+	0, // 1: services.OrderService.NewOrder:output_type -> services.OrderResponse
+	1, // [1:2] is the sub-list for method output_type
+	0, // [0:1] is the sub-list for method input_type
+	0, // [0:0] is the sub-list for extension type_name
+	0, // [0:0] is the sub-list for extension extendee
+	0, // [0:0] is the sub-list for field type_name
+}
+
+func init() { file_order_proto_init() }
+func file_order_proto_init() {
+	if File_order_proto != nil {
+		return
+	}
+	file_models_proto_init()
+	if !protoimpl.UnsafeEnabled {
+		file_order_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*OrderResponse); 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_order_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   1,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_order_proto_goTypes,
+		DependencyIndexes: file_order_proto_depIdxs,
+		MessageInfos:      file_order_proto_msgTypes,
+	}.Build()
+	File_order_proto = out.File
+	file_order_proto_rawDesc = nil
+	file_order_proto_goTypes = nil
+	file_order_proto_depIdxs = nil
+}

+ 109 - 0
dyrpc/services/prod/order_grpc.pb.go

@@ -0,0 +1,109 @@
+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
+// versions:
+// - protoc-gen-go-grpc v1.3.0
+// - protoc             v5.26.1
+// source: order.proto
+
+package prod
+
+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 (
+	OrderService_NewOrder_FullMethodName = "/services.OrderService/NewOrder"
+)
+
+// OrderServiceClient is the client API for OrderService 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 OrderServiceClient interface {
+	NewOrder(ctx context.Context, in *ProdMain, opts ...grpc.CallOption) (*OrderResponse, error)
+}
+
+type orderServiceClient struct {
+	cc grpc.ClientConnInterface
+}
+
+func NewOrderServiceClient(cc grpc.ClientConnInterface) OrderServiceClient {
+	return &orderServiceClient{cc}
+}
+
+func (c *orderServiceClient) NewOrder(ctx context.Context, in *ProdMain, opts ...grpc.CallOption) (*OrderResponse, error) {
+	out := new(OrderResponse)
+	err := c.cc.Invoke(ctx, OrderService_NewOrder_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+// OrderServiceServer is the server API for OrderService service.
+// All implementations must embed UnimplementedOrderServiceServer
+// for forward compatibility
+type OrderServiceServer interface {
+	NewOrder(context.Context, *ProdMain) (*OrderResponse, error)
+	mustEmbedUnimplementedOrderServiceServer()
+}
+
+// UnimplementedOrderServiceServer must be embedded to have forward compatible implementations.
+type UnimplementedOrderServiceServer struct {
+}
+
+func (UnimplementedOrderServiceServer) NewOrder(context.Context, *ProdMain) (*OrderResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method NewOrder not implemented")
+}
+func (UnimplementedOrderServiceServer) mustEmbedUnimplementedOrderServiceServer() {}
+
+// UnsafeOrderServiceServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to OrderServiceServer will
+// result in compilation errors.
+type UnsafeOrderServiceServer interface {
+	mustEmbedUnimplementedOrderServiceServer()
+}
+
+func RegisterOrderServiceServer(s grpc.ServiceRegistrar, srv OrderServiceServer) {
+	s.RegisterService(&OrderService_ServiceDesc, srv)
+}
+
+func _OrderService_NewOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ProdMain)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrderServiceServer).NewOrder(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: OrderService_NewOrder_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrderServiceServer).NewOrder(ctx, req.(*ProdMain))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+// OrderService_ServiceDesc is the grpc.ServiceDesc for OrderService service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var OrderService_ServiceDesc = grpc.ServiceDesc{
+	ServiceName: "services.OrderService",
+	HandlerType: (*OrderServiceServer)(nil),
+	Methods: []grpc.MethodDesc{
+		{
+			MethodName: "NewOrder",
+			Handler:    _OrderService_NewOrder_Handler,
+		},
+	},
+	Streams:  []grpc.StreamDesc{},
+	Metadata: "order.proto",
+}

+ 45 - 36
dyrpc/services/prod/prod.pb.go

@@ -280,38 +280,43 @@ var file_prod_proto_rawDesc = []byte{
 	0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x73, 0x65,
 	0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61,
 	0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70,
-	0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01,
-	0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x09,
-	0x70, 0x72, 0x6f, 0x64, 0x5f, 0x61, 0x72, 0x65, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32,
-	0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x41,
-	0x72, 0x65, 0x61, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x41, 0x72, 0x65, 0x61, 0x22, 0x2d, 0x0a,
-	0x0c, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a,
-	0x0a, 0x70, 0x72, 0x6f, 0x64, 0x5f, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28,
-	0x05, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x22, 0x45, 0x0a, 0x0f,
-	0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x73, 0x12,
-	0x16, 0x0a, 0x06, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
-	0x06, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x6f, 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, 0x22, 0x41, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b,
-	0x4c, 0x69, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x18,
-	0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
-	0x2e, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x70,
-	0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x2a, 0x1f, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x64, 0x41, 0x72,
-	0x65, 0x61, 0x12, 0x05, 0x0a, 0x01, 0x41, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x01,
-	0x12, 0x05, 0x0a, 0x01, 0x43, 0x10, 0x02, 0x32, 0xaf, 0x01, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x64,
-	0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x59, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x50, 0x72,
-	0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
-	0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16,
-	0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65,
-	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12,
-	0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x2f, 0x7b, 0x70, 0x72, 0x6f, 0x64, 0x5f, 0x69,
-	0x64, 0x7d, 0x12, 0x45, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f,
-	0x63, 0x6b, 0x73, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x51,
-	0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x73, 0x1a, 0x17,
-	0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74,
-	0x6f, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x70, 0x72,
-	0x6f, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0c, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f,
+	0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+	0x74, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
+	0x28, 0x05, 0x52, 0x06, 0x70, 0x72, 0x6f, 0x64, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x09, 0x70, 0x72,
+	0x6f, 0x64, 0x5f, 0x61, 0x72, 0x65, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e,
+	0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x41, 0x72, 0x65,
+	0x61, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x41, 0x72, 0x65, 0x61, 0x22, 0x2d, 0x0a, 0x0c, 0x50,
+	0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70,
+	0x72, 0x6f, 0x64, 0x5f, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
+	0x09, 0x70, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x22, 0x45, 0x0a, 0x0f, 0x51, 0x75,
+	0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x73, 0x12, 0x16, 0x0a,
+	0x06, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x70,
+	0x61, 0x67, 0x65, 0x4e, 0x6f, 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, 0x22, 0x41, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x4c, 0x69,
+	0x73, 0x74, 0x12, 0x30, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x18, 0x01, 0x20,
+	0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50,
+	0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f,
+	0x64, 0x52, 0x65, 0x73, 0x2a, 0x1f, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x64, 0x41, 0x72, 0x65, 0x61,
+	0x12, 0x05, 0x0a, 0x01, 0x41, 0x10, 0x00, 0x12, 0x05, 0x0a, 0x01, 0x42, 0x10, 0x01, 0x12, 0x05,
+	0x0a, 0x01, 0x43, 0x10, 0x02, 0x32, 0xec, 0x01, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x65,
+	0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x59, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64,
+	0x53, 0x74, 0x6f, 0x63, 0x6b, 0x12, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
+	0x2e, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x73,
+	0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x73, 0x70,
+	0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x76,
+	0x31, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x2f, 0x7b, 0x70, 0x72, 0x6f, 0x64, 0x5f, 0x69, 0x64, 0x7d,
+	0x12, 0x45, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b,
+	0x73, 0x12, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x51, 0x75, 0x65,
+	0x72, 0x79, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x73, 0x1a, 0x17, 0x2e, 0x73,
+	0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x53, 0x74, 0x6f, 0x63,
+	0x6b, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x50, 0x72,
+	0x6f, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x15, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
+	0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e,
+	0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x4d, 0x6f, 0x64,
+	0x65, 0x6c, 0x22, 0x00, 0x42, 0x07, 0x5a, 0x05, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x62, 0x06, 0x70,
+	0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -334,16 +339,19 @@ var file_prod_proto_goTypes = []interface{}{
 	(*ProdResponse)(nil),    // 2: services.ProdResponse
 	(*QueryProdStocks)(nil), // 3: services.QueryProdStocks
 	(*ProdStockList)(nil),   // 4: services.ProdStockList
+	(*ProdModel)(nil),       // 5: services.ProdModel
 }
 var file_prod_proto_depIdxs = []int32{
 	0, // 0: services.ProdRequest.prod_area:type_name -> services.ProdArea
 	2, // 1: services.ProdStockList.prodRes:type_name -> services.ProdResponse
 	1, // 2: services.ProdService.GetProdStock:input_type -> services.ProdRequest
 	3, // 3: services.ProdService.GetProdStocks:input_type -> services.QueryProdStocks
-	2, // 4: services.ProdService.GetProdStock:output_type -> services.ProdResponse
-	4, // 5: services.ProdService.GetProdStocks:output_type -> services.ProdStockList
-	4, // [4:6] is the sub-list for method output_type
-	2, // [2:4] is the sub-list for method input_type
+	1, // 4: services.ProdService.GetProdInfo:input_type -> services.ProdRequest
+	2, // 5: services.ProdService.GetProdStock:output_type -> services.ProdResponse
+	4, // 6: services.ProdService.GetProdStocks:output_type -> services.ProdStockList
+	5, // 7: services.ProdService.GetProdInfo:output_type -> services.ProdModel
+	5, // [5:8] is the sub-list for method output_type
+	2, // [2:5] 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
@@ -354,6 +362,7 @@ func file_prod_proto_init() {
 	if File_prod_proto != nil {
 		return
 	}
+	file_models_proto_init()
 	if !protoimpl.UnsafeEnabled {
 		file_prod_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
 			switch v := v.(*ProdRequest); i {

+ 37 - 0
dyrpc/services/prod/prod_grpc.pb.go

@@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion7
 const (
 	ProdService_GetProdStock_FullMethodName  = "/services.ProdService/GetProdStock"
 	ProdService_GetProdStocks_FullMethodName = "/services.ProdService/GetProdStocks"
+	ProdService_GetProdInfo_FullMethodName   = "/services.ProdService/GetProdInfo"
 )
 
 // ProdServiceClient is the client API for ProdService service.
@@ -29,6 +30,7 @@ const (
 type ProdServiceClient interface {
 	GetProdStock(ctx context.Context, in *ProdRequest, opts ...grpc.CallOption) (*ProdResponse, error)
 	GetProdStocks(ctx context.Context, in *QueryProdStocks, opts ...grpc.CallOption) (*ProdStockList, error)
+	GetProdInfo(ctx context.Context, in *ProdRequest, opts ...grpc.CallOption) (*ProdModel, error)
 }
 
 type prodServiceClient struct {
@@ -57,12 +59,22 @@ func (c *prodServiceClient) GetProdStocks(ctx context.Context, in *QueryProdStoc
 	return out, nil
 }
 
+func (c *prodServiceClient) GetProdInfo(ctx context.Context, in *ProdRequest, opts ...grpc.CallOption) (*ProdModel, error) {
+	out := new(ProdModel)
+	err := c.cc.Invoke(ctx, ProdService_GetProdInfo_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ProdServiceServer is the server API for ProdService service.
 // All implementations must embed UnimplementedProdServiceServer
 // for forward compatibility
 type ProdServiceServer interface {
 	GetProdStock(context.Context, *ProdRequest) (*ProdResponse, error)
 	GetProdStocks(context.Context, *QueryProdStocks) (*ProdStockList, error)
+	GetProdInfo(context.Context, *ProdRequest) (*ProdModel, error)
 	mustEmbedUnimplementedProdServiceServer()
 }
 
@@ -76,6 +88,9 @@ func (UnimplementedProdServiceServer) GetProdStock(context.Context, *ProdRequest
 func (UnimplementedProdServiceServer) GetProdStocks(context.Context, *QueryProdStocks) (*ProdStockList, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetProdStocks not implemented")
 }
+func (UnimplementedProdServiceServer) GetProdInfo(context.Context, *ProdRequest) (*ProdModel, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetProdInfo not implemented")
+}
 func (UnimplementedProdServiceServer) mustEmbedUnimplementedProdServiceServer() {}
 
 // UnsafeProdServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -125,6 +140,24 @@ func _ProdService_GetProdStocks_Handler(srv interface{}, ctx context.Context, de
 	return interceptor(ctx, in, info, handler)
 }
 
+func _ProdService_GetProdInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ProdRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ProdServiceServer).GetProdInfo(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: ProdService_GetProdInfo_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ProdServiceServer).GetProdInfo(ctx, req.(*ProdRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // ProdService_ServiceDesc is the grpc.ServiceDesc for ProdService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -140,6 +173,10 @@ var ProdService_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "GetProdStocks",
 			Handler:    _ProdService_GetProdStocks_Handler,
 		},
+		{
+			MethodName: "GetProdInfo",
+			Handler:    _ProdService_GetProdInfo_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "prod.proto",

+ 18 - 1
dyrpc/services/prod_service.go

@@ -10,7 +10,16 @@ type ProdService struct {
 }
 
 func (p *ProdService) GetProdStock(ctx context.Context, request *prod.ProdRequest) (*prod.ProdResponse, error) {
-	return &prod.ProdResponse{ProdStock: 20}, nil
+	var stock int32
+	switch request.ProdArea {
+	case prod.ProdArea_A:
+		stock = 0
+	case prod.ProdArea_B:
+		stock = 10
+	case prod.ProdArea_C:
+		stock = 20
+	}
+	return &prod.ProdResponse{ProdStock: stock}, nil
 }
 
 func (p *ProdService) GetProdStocks(context.Context, *prod.QueryProdStocks) (*prod.ProdStockList, error) {
@@ -23,6 +32,14 @@ func (p *ProdService) GetProdStocks(context.Context, *prod.QueryProdStocks) (*pr
 	return &prod.ProdStockList{ProdRes: prdRes}, nil
 }
 
+func (p *ProdService) GetProdInfo(ctx context.Context, request *prod.ProdRequest) (*prod.ProdModel, error) {
+	return &prod.ProdModel{
+		ProdId:    request.ProdId,
+		ProdName:  "aaa",
+		ProdPrice: 20.5,
+	}, nil
+}
+
 func (p *ProdService) mustEmbedUnimplementedProdServiceServer() {
 
 }

+ 12 - 0
embed/main.go

@@ -0,0 +1,12 @@
+package main
+
+import (
+	"dy-test/embed/user_pkg"
+	"fmt"
+)
+
+// embed
+func main() {
+	a := &user_pkg.UserPkg{}
+	fmt.Println(a.GetID())
+}

+ 23 - 0
embed/third_pkg/third_pkg.go

@@ -0,0 +1,23 @@
+package third_pkg
+
+// 从grpc的生成文件中学习到的,当我实现一个接口时,结构中必须嵌入作者给定的一个结构,可以这样做。
+
+// ThirdPkg 假设作者定义了一个接口,接口中有一个小写函数。再别的包中定义的结构是无法实现这个接口的。
+// 此时我们在本包内定义一个结构来实现该接口,这样在别的包中,如果有外部包的结构想实现ThirdPkg这个接口,就必须嵌入我们这个包内的结构UnimplementedThirdPkg
+type ThirdPkg interface {
+	GetID() string
+	getName() string
+}
+
+type UnimplementedThirdPkg struct {
+}
+
+func (u UnimplementedThirdPkg) GetID() string {
+	//TODO implement me
+	panic("implement me")
+}
+
+func (u UnimplementedThirdPkg) getName() string {
+	//TODO implement me
+	panic("implement me")
+}

+ 15 - 0
embed/user_pkg/user_pkg.go

@@ -0,0 +1,15 @@
+package user_pkg
+
+import "dy-test/embed/third_pkg"
+
+type UserPkg struct {
+	third_pkg.ThirdPkg // 必须嵌入这个结构,才能实现接口
+}
+
+func (u UserPkg) GetID() string {
+	return "1"
+}
+
+func (u UserPkg) getName() string {
+	return "1"
+}