From afecd0e06555527fcca14c06d4e03a63844e0240 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 12 Jul 2022 14:24:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BC=96=E8=A7=A3=E7=A0=81?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/codec/core/core.go | 3 ++ lego/sys/codec/factory/factory.go | 17 ++++++++ lego/sys/codec/factory/factory_array.go | 17 ++++++-- lego/sys/codec/factory/factory_interface.go | 9 ++++ lego/sys/codec/factory/factory_map.go | 46 ++++++++++++++++----- lego/sys/codec/factory/factory_native.go | 37 +++++++++++++++++ lego/sys/codec/factory/factory_optional.go | 13 ++++++ lego/sys/codec/factory/factory_slice.go | 7 ++++ lego/sys/codec/factory/factory_struct.go | 15 +++++++ lego/sys/codec/sys_test.go | 31 ++++++++++++++ modules/items/module_test.go | 6 ++- pb/items_msg.pb.go | 16 +++---- pb/proto/items/items_msg.proto | 4 +- 13 files changed, 195 insertions(+), 26 deletions(-) diff --git a/lego/sys/codec/core/core.go b/lego/sys/codec/core/core.go index d569e4ea0..191765a3a 100644 --- a/lego/sys/codec/core/core.go +++ b/lego/sys/codec/core/core.go @@ -1,6 +1,7 @@ package core import ( + "reflect" "unsafe" "github.com/modern-go/reflect2" @@ -113,6 +114,7 @@ type ( } //Json 编码器 IEncoder interface { + GetType() reflect.Kind IsEmpty(ptr unsafe.Pointer) bool Encode(ptr unsafe.Pointer, stream IStream) } @@ -127,6 +129,7 @@ type ( //Json 解码器 IDecoder interface { + GetType() reflect.Kind Decode(ptr unsafe.Pointer, extra IExtractor) } //MapJson 解码器 diff --git a/lego/sys/codec/factory/factory.go b/lego/sys/codec/factory/factory.go index 4876ec615..560cea74c 100644 --- a/lego/sys/codec/factory/factory.go +++ b/lego/sys/codec/factory/factory.go @@ -132,6 +132,9 @@ type rootDecoder struct { decoder core.IDecoder } +func (this *rootDecoder) GetType() reflect.Kind { + return reflect.Ptr +} func (this *rootDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { this.decoder.Decode(ptr, extra) } @@ -140,6 +143,9 @@ type rootEncoder struct { encoder core.IEncoder } +func (this *rootEncoder) GetType() reflect.Kind { + return reflect.Ptr +} func (this *rootEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { this.encoder.Encode(ptr, stream) } @@ -157,6 +163,10 @@ type onePtrEncoder struct { encoder core.IEncoder } +func (this *onePtrEncoder) GetType() reflect.Kind { + return reflect.Ptr +} + func (this *onePtrEncoder) IsEmpty(ptr unsafe.Pointer) bool { return this.encoder.IsEmpty(unsafe.Pointer(&ptr)) } @@ -179,6 +189,9 @@ type lazyErrorDecoder struct { err error } +func (this *lazyErrorDecoder) GetType() reflect.Kind { + return reflect.Ptr +} func (this *lazyErrorDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if extra.Error() == nil { extra.SetErr(this.err) @@ -189,6 +202,10 @@ type lazyErrorEncoder struct { err error } +func (this *lazyErrorEncoder) GetType() reflect.Kind { + return reflect.Ptr +} + func (this *lazyErrorEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { if ptr == nil { stream.WriteNil() diff --git a/lego/sys/codec/factory/factory_array.go b/lego/sys/codec/factory/factory_array.go index 34453632f..7f50618ec 100644 --- a/lego/sys/codec/factory/factory_array.go +++ b/lego/sys/codec/factory/factory_array.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "reflect" "unsafe" "go_dreamfactory/lego/sys/codec/core" @@ -20,7 +21,7 @@ func decoderOfArray(ctx *core.Ctx, typ reflect2.Type) core.IDecoder { func encoderOfArray(ctx *core.Ctx, typ reflect2.Type) core.IEncoder { arrayType := typ.(*reflect2.UnsafeArrayType) if arrayType.Len() == 0 { - return emptyArrayEncoder{} + return &emptyArrayEncoder{} } encoder := EncoderOfType(ctx.Append("[arrayElem]"), arrayType.Elem()) return &arrayEncoder{ctx.ICodec, arrayType, encoder} @@ -33,6 +34,9 @@ type arrayEncoder struct { elemEncoder core.IEncoder } +func (codec *arrayEncoder) GetType() reflect.Kind { + return reflect.Array +} func (this *arrayEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { stream.WriteArrayStart() elemPtr := unsafe.Pointer(ptr) @@ -75,6 +79,9 @@ type arrayDecoder struct { elemDecoder core.IDecoder } +func (codec *arrayDecoder) GetType() reflect.Kind { + return reflect.Array +} func (this *arrayDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { arrayType := this.arrayType if extra.ReadNil() { @@ -125,10 +132,14 @@ func (this *arrayDecoder) DecodeForSliceJson(ptr unsafe.Pointer, data []string) type emptyArrayEncoder struct{} -func (this emptyArrayEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { +func (this *emptyArrayEncoder) GetType() reflect.Kind { + return reflect.Array +} + +func (this *emptyArrayEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { stream.WriteEmptyArray() } -func (this emptyArrayEncoder) IsEmpty(ptr unsafe.Pointer) bool { +func (this *emptyArrayEncoder) IsEmpty(ptr unsafe.Pointer) bool { return true } diff --git a/lego/sys/codec/factory/factory_interface.go b/lego/sys/codec/factory/factory_interface.go index 1d91f3b76..d9e446285 100644 --- a/lego/sys/codec/factory/factory_interface.go +++ b/lego/sys/codec/factory/factory_interface.go @@ -14,6 +14,9 @@ type dynamicEncoder struct { valType reflect2.Type } +func (codec *dynamicEncoder) GetType() reflect.Kind { + return reflect.Interface +} func (encoder *dynamicEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { obj := encoder.valType.UnsafeIndirect(ptr) stream.WriteVal(obj) @@ -26,6 +29,9 @@ func (encoder *dynamicEncoder) IsEmpty(ptr unsafe.Pointer) bool { type efaceDecoder struct { } +func (codec *efaceDecoder) GetType() reflect.Kind { + return reflect.Interface +} func (decoder *efaceDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { pObj := (*interface{})(ptr) obj := *pObj @@ -60,6 +66,9 @@ type ifaceDecoder struct { valType *reflect2.UnsafeIFaceType } +func (codec *ifaceDecoder) GetType() reflect.Kind { + return reflect.Interface +} func (decoder *ifaceDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if extra.ReadNil() { decoder.valType.UnsafeSet(ptr, decoder.valType.UnsafeNew()) diff --git a/lego/sys/codec/factory/factory_map.go b/lego/sys/codec/factory/factory_map.go index f694a62fd..eaf19b4c7 100644 --- a/lego/sys/codec/factory/factory_map.go +++ b/lego/sys/codec/factory/factory_map.go @@ -84,6 +84,9 @@ type mapEncoder struct { elemEncoder core.IEncoder } +func (codec *mapEncoder) GetType() reflect.Kind { + return reflect.Map +} func (this *mapEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { if *(*unsafe.Pointer)(ptr) == nil { stream.WriteNil() @@ -141,6 +144,9 @@ type mapDecoder struct { elemDecoder core.IDecoder } +func (codec *mapDecoder) GetType() reflect.Kind { + return reflect.Map +} func (this *mapDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { mapType := this.mapType if extra.ReadNil() { @@ -184,20 +190,28 @@ func (this *mapDecoder) DecodeForMapJson(ptr unsafe.Pointer, extra map[string]st keyext := this.codec.BorrowExtractor([]byte{}) elemext := this.codec.BorrowExtractor([]byte{}) for k, v := range extra { - keyext.ResetBytes(StringToBytes(k)) key := this.keyType.UnsafeNew() - this.keyDecoder.Decode(key, keyext) - if keyext.Error() != nil && keyext.Error() != io.EOF { - err = keyext.Error() - return + if this.keyDecoder.GetType() != reflect.String { + keyext.ResetBytes(StringToBytes(k)) + this.keyDecoder.Decode(key, keyext) + if keyext.Error() != nil && keyext.Error() != io.EOF { + err = keyext.Error() + return + } + } else { + *((*string)(key)) = k } - elemext.ResetBytes(StringToBytes(v)) elem := this.elemType.UnsafeNew() - this.elemDecoder.Decode(elem, elemext) - this.mapType.UnsafeSetIndex(ptr, key, elem) - if elemext.Error() != nil && elemext.Error() != io.EOF { - err = elemext.Error() - return + if this.elemDecoder.GetType() != reflect.String { + elemext.ResetBytes(StringToBytes(v)) + this.elemDecoder.Decode(elem, elemext) + this.mapType.UnsafeSetIndex(ptr, key, elem) + if elemext.Error() != nil && elemext.Error() != io.EOF { + err = elemext.Error() + return + } + } else { + *((*string)(elem)) = v } } return @@ -208,6 +222,9 @@ type numericMapKeyDecoder struct { decoder core.IDecoder } +func (this *numericMapKeyDecoder) GetType() reflect.Kind { + return this.decoder.GetType() +} func (this *numericMapKeyDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if extra.ReadKeyStart() { return @@ -222,6 +239,9 @@ type numericMapKeyEncoder struct { encoder core.IEncoder } +func (this *numericMapKeyEncoder) GetType() reflect.Kind { + return this.encoder.GetType() +} func (this *numericMapKeyEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { stream.WriteKeyStart() this.encoder.Encode(ptr, stream) @@ -238,6 +258,10 @@ type dynamicMapKeyEncoder struct { valType reflect2.Type } +func (this *dynamicMapKeyEncoder) GetType() reflect.Kind { + return reflect.Interface +} + func (this *dynamicMapKeyEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { obj := this.valType.UnsafeIndirect(ptr) encoderOfMapKey(this.ctx, reflect2.TypeOf(obj)).Encode(reflect2.PtrOf(obj), stream) diff --git a/lego/sys/codec/factory/factory_native.go b/lego/sys/codec/factory/factory_native.go index bd4f4dd72..c8cfdb0f1 100644 --- a/lego/sys/codec/factory/factory_native.go +++ b/lego/sys/codec/factory/factory_native.go @@ -198,6 +198,9 @@ func createEncoderOfNative(ctx *core.Ctx, typ reflect2.Type) core.IEncoder { type stringCodec struct { } +func (codec *stringCodec) GetType() reflect.Kind { + return reflect.String +} func (codec *stringCodec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { *((*string)(ptr)) = extra.ReadString() } @@ -214,6 +217,10 @@ func (codec *stringCodec) IsEmpty(ptr unsafe.Pointer) bool { type int8Codec struct { } +func (codec *int8Codec) GetType() reflect.Kind { + return reflect.Int8 +} + func (codec *int8Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*int8)(ptr)) = extra.ReadInt8() @@ -231,6 +238,9 @@ func (codec *int8Codec) IsEmpty(ptr unsafe.Pointer) bool { type int16Codec struct { } +func (codec *int16Codec) GetType() reflect.Kind { + return reflect.Int16 +} func (codec *int16Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*int16)(ptr)) = extra.ReadInt16() @@ -248,6 +258,9 @@ func (codec *int16Codec) IsEmpty(ptr unsafe.Pointer) bool { type int32Codec struct { } +func (codec *int32Codec) GetType() reflect.Kind { + return reflect.Int32 +} func (codec *int32Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*int32)(ptr)) = extra.ReadInt32() @@ -264,6 +277,9 @@ func (codec *int32Codec) IsEmpty(ptr unsafe.Pointer) bool { type int64Codec struct { } +func (codec *int64Codec) GetType() reflect.Kind { + return reflect.Int64 +} func (codec *int64Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*int64)(ptr)) = extra.ReadInt64() @@ -281,6 +297,9 @@ func (codec *int64Codec) IsEmpty(ptr unsafe.Pointer) bool { type uint8Codec struct { } +func (codec *uint8Codec) GetType() reflect.Kind { + return reflect.Uint8 +} func (codec *uint8Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*uint8)(ptr)) = extra.ReadUint8() @@ -298,6 +317,9 @@ func (codec *uint8Codec) IsEmpty(ptr unsafe.Pointer) bool { type uint16Codec struct { } +func (codec *uint16Codec) GetType() reflect.Kind { + return reflect.Uint16 +} func (codec *uint16Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*uint16)(ptr)) = extra.ReadUint16() @@ -315,6 +337,9 @@ func (codec *uint16Codec) IsEmpty(ptr unsafe.Pointer) bool { type uint32Codec struct { } +func (codec *uint32Codec) GetType() reflect.Kind { + return reflect.Uint32 +} func (codec *uint32Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*uint32)(ptr)) = extra.ReadUint32() @@ -331,6 +356,9 @@ func (codec *uint32Codec) IsEmpty(ptr unsafe.Pointer) bool { type uint64Codec struct { } +func (codec *uint64Codec) GetType() reflect.Kind { + return reflect.Uint64 +} func (codec *uint64Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*uint64)(ptr)) = extra.ReadUint64() @@ -348,6 +376,9 @@ func (codec *uint64Codec) IsEmpty(ptr unsafe.Pointer) bool { type float32Codec struct { } +func (codec *float32Codec) GetType() reflect.Kind { + return reflect.Float32 +} func (codec *float32Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*float32)(ptr)) = extra.ReadFloat32() @@ -365,6 +396,9 @@ func (codec *float32Codec) IsEmpty(ptr unsafe.Pointer) bool { type float64Codec struct { } +func (codec *float64Codec) GetType() reflect.Kind { + return reflect.Float64 +} func (codec *float64Codec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*float64)(ptr)) = extra.ReadFloat64() @@ -382,6 +416,9 @@ func (codec *float64Codec) IsEmpty(ptr unsafe.Pointer) bool { type boolCodec struct { } +func (codec *boolCodec) GetType() reflect.Kind { + return reflect.Bool +} func (codec *boolCodec) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadNil() { *((*bool)(ptr)) = extra.ReadBool() diff --git a/lego/sys/codec/factory/factory_optional.go b/lego/sys/codec/factory/factory_optional.go index 433be370a..f1d1f2f75 100644 --- a/lego/sys/codec/factory/factory_optional.go +++ b/lego/sys/codec/factory/factory_optional.go @@ -2,6 +2,7 @@ package factory import ( "fmt" + "reflect" "unsafe" "go_dreamfactory/lego/sys/codec/core" @@ -30,6 +31,9 @@ type OptionalDecoder struct { ValueDecoder core.IDecoder } +func (this *OptionalDecoder) GetType() reflect.Kind { + return this.ValueDecoder.GetType() +} func (this *OptionalDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if extra.ReadNil() { *((*unsafe.Pointer)(ptr)) = nil @@ -48,6 +52,9 @@ type OptionalEncoder struct { ValueEncoder core.IEncoder } +func (this *OptionalEncoder) GetType() reflect.Kind { + return this.ValueEncoder.GetType() +} func (this *OptionalEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { if *((*unsafe.Pointer)(ptr)) == nil { stream.WriteNil() @@ -96,6 +103,9 @@ type dereferenceDecoder struct { valueDecoder core.IDecoder } +func (this *dereferenceDecoder) GetType() reflect.Kind { + return this.valueDecoder.GetType() +} func (this *dereferenceDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if *((*unsafe.Pointer)(ptr)) == nil { newPtr := this.valueType.UnsafeNew() @@ -110,6 +120,9 @@ type dereferenceEncoder struct { ValueEncoder core.IEncoder } +func (this *dereferenceEncoder) GetType() reflect.Kind { + return this.ValueEncoder.GetType() +} func (this *dereferenceEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { if *((*unsafe.Pointer)(ptr)) == nil { stream.WriteNil() diff --git a/lego/sys/codec/factory/factory_slice.go b/lego/sys/codec/factory/factory_slice.go index 96871b600..291c59e78 100644 --- a/lego/sys/codec/factory/factory_slice.go +++ b/lego/sys/codec/factory/factory_slice.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "io" + "reflect" "unsafe" "go_dreamfactory/lego/sys/codec/core" @@ -28,6 +29,9 @@ type sliceEncoder struct { elemEncoder core.IEncoder } +func (codec *sliceEncoder) GetType() reflect.Kind { + return reflect.Slice +} func (this *sliceEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { if this.sliceType.UnsafeIsNil(ptr) { stream.WriteNil() @@ -86,6 +90,9 @@ type sliceDecoder struct { elemDecoder core.IDecoder } +func (codec *sliceDecoder) GetType() reflect.Kind { + return reflect.Slice +} func (this *sliceDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { sliceType := this.sliceType if extra.ReadNil() { diff --git a/lego/sys/codec/factory/factory_struct.go b/lego/sys/codec/factory/factory_struct.go index 06ecb764f..a07ae27ce 100644 --- a/lego/sys/codec/factory/factory_struct.go +++ b/lego/sys/codec/factory/factory_struct.go @@ -250,6 +250,9 @@ type structEncoder struct { fields []structFieldTo } +func (codec *structEncoder) GetType() reflect.Kind { + return reflect.Struct +} func (this *structEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { stream.WriteObjectStart() isNotFirst := false @@ -305,6 +308,9 @@ type structDecoder struct { disallowUnknownFields bool } +func (codec *structDecoder) GetType() reflect.Kind { + return reflect.Struct +} func (this *structDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { if !extra.ReadObjectStart() { return @@ -384,6 +390,9 @@ type structFieldEncoder struct { omitempty bool } +func (this *structFieldEncoder) GetType() reflect.Kind { + return this.fieldEncoder.GetType() +} func (encoder *structFieldEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { fieldPtr := encoder.field.UnsafeGet(ptr) encoder.fieldEncoder.Encode(fieldPtr, stream) @@ -411,6 +420,9 @@ type structFieldDecoder struct { fieldDecoder core.IDecoder } +func (this *structFieldDecoder) GetType() reflect.Kind { + return this.fieldDecoder.GetType() +} func (decoder *structFieldDecoder) Decode(ptr unsafe.Pointer, extra core.IExtractor) { fieldPtr := decoder.field.UnsafeGet(ptr) decoder.fieldDecoder.Decode(fieldPtr, extra) @@ -423,6 +435,9 @@ func (decoder *structFieldDecoder) Decode(ptr unsafe.Pointer, extra core.IExtrac type emptyStructEncoder struct { } +func (codec *emptyStructEncoder) GetType() reflect.Kind { + return reflect.Struct +} func (encoder *emptyStructEncoder) Encode(ptr unsafe.Pointer, stream core.IStream) { stream.WriteEmptyObject() } diff --git a/lego/sys/codec/sys_test.go b/lego/sys/codec/sys_test.go index 50bb7bca4..9d74319bc 100644 --- a/lego/sys/codec/sys_test.go +++ b/lego/sys/codec/sys_test.go @@ -2,10 +2,13 @@ package codec_test import ( "fmt" + "reflect" "testing" "go_dreamfactory/lego/sys/codec" "go_dreamfactory/lego/sys/log" + + "github.com/modern-go/reflect2" ) type TestData struct { @@ -52,3 +55,31 @@ func Test_sys_mapjson(t *testing.T) { fmt.Printf("codec UnmarshalJson data:%v err:%v", data, err) } } + +func Test_sys_reflect2(t *testing.T) { + data := []string{"123"} + ptr := reflect2.TypeOf(&data) + kind := ptr.Kind() + switch kind { + case reflect.Interface: + return + case reflect.Struct: + return + case reflect.Array: + return + case reflect.Slice: + return + case reflect.Map: + return + case reflect.Ptr: + ptrType := ptr.(*reflect2.UnsafePtrType) + elemType := ptrType.Elem() + kind = elemType.Kind() + if kind == reflect.Slice { + return + } + return + default: + return + } +} diff --git a/modules/items/module_test.go b/modules/items/module_test.go index cee4d4ae1..3f7471f1c 100644 --- a/modules/items/module_test.go +++ b/modules/items/module_test.go @@ -11,6 +11,7 @@ import ( "go_dreamfactory/modules/equipment" "go_dreamfactory/modules/hero" "go_dreamfactory/modules/items" + "go_dreamfactory/modules/task" "go_dreamfactory/modules/user" "go_dreamfactory/pb" "go_dreamfactory/services" @@ -74,6 +75,7 @@ func TestMain(m *testing.M) { hero.NewModule(), user.NewModule(), equipment.NewModule(), + task.NewModule(), ) }() time.Sleep(time.Second * 3) @@ -82,9 +84,9 @@ func TestMain(m *testing.M) { func Test_Modules(t *testing.T) { data, _ := ptypes.MarshalAny(&pb.ItemsGetlistReq{}) - s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{MainType: "pack", SubType: "getlist", Message: data}, &pb.RPCMessageReply{}) + s_gateComp.ReceiveMsg(context.Background(), &pb.AgentMessage{UserId: "0_62c259916d8cf3e4e06311a8", MainType: "items", SubType: "getlist", Message: data}, &pb.RPCMessageReply{}) // items, err := module.db_comp.Pack_QueryUserPack("liwei1dao") - // log.Debugf("item:%v err:%v", items, err) + log.Debugf("data:%v", data) } func Test_Modules_AddItems(t *testing.T) { diff --git a/pb/items_msg.pb.go b/pb/items_msg.pb.go index 2ee494aef..82183d34f 100644 --- a/pb/items_msg.pb.go +++ b/pb/items_msg.pb.go @@ -122,7 +122,7 @@ type ItemsUseItemReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GridId int32 `protobuf:"varint,1,opt,name=GridId,proto3" json:"GridId"` //格子Id + GridId string `protobuf:"bytes,1,opt,name=GridId,proto3" json:"GridId"` //格子Id ItemId int32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId"` //物品Id Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount"` //使用数量 } @@ -159,11 +159,11 @@ func (*ItemsUseItemReq) Descriptor() ([]byte, []int) { return file_items_items_msg_proto_rawDescGZIP(), []int{2} } -func (x *ItemsUseItemReq) GetGridId() int32 { +func (x *ItemsUseItemReq) GetGridId() string { if x != nil { return x.GridId } - return 0 + return "" } func (x *ItemsUseItemReq) GetItemId() int32 { @@ -225,7 +225,7 @@ type ItemsSellItemReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GridId int32 `protobuf:"varint,1,opt,name=GridId,proto3" json:"GridId"` //格子Id + GridId string `protobuf:"bytes,1,opt,name=GridId,proto3" json:"GridId"` //格子Id ItemId int32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId"` //物品Id Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount"` //使用数量 } @@ -262,11 +262,11 @@ func (*ItemsSellItemReq) Descriptor() ([]byte, []int) { return file_items_items_msg_proto_rawDescGZIP(), []int{4} } -func (x *ItemsSellItemReq) GetGridId() int32 { +func (x *ItemsSellItemReq) GetGridId() string { if x != nil { return x.GridId } - return 0 + return "" } func (x *ItemsSellItemReq) GetItemId() int32 { @@ -336,14 +336,14 @@ var file_items_items_msg_proto_rawDesc = []byte{ 0x73, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, 0x22, 0x59, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x12, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x5a, 0x0a, 0x10, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x0a, diff --git a/pb/proto/items/items_msg.proto b/pb/proto/items/items_msg.proto index a6e480837..83f52391c 100644 --- a/pb/proto/items/items_msg.proto +++ b/pb/proto/items/items_msg.proto @@ -14,7 +14,7 @@ message ItemsGetlistResp { //使用物品请求 message ItemsUseItemReq { - int32 GridId = 1; //格子Id + string GridId = 1; //格子Id int32 ItemId = 2; //物品Id uint32 Amount = 3; //使用数量 } @@ -26,7 +26,7 @@ message ItemsUseItemResp { //出售道具请求sailitem message ItemsSellItemReq { - int32 GridId = 1; //格子Id + string GridId = 1; //格子Id int32 ItemId = 2; //物品Id uint32 Amount = 3; //使用数量 }