diff --git a/modules/pack/db_comp.go b/modules/pack/db_comp.go index 1a5fc4c63..2ad75fa7a 100644 --- a/modules/pack/db_comp.go +++ b/modules/pack/db_comp.go @@ -1,12 +1,14 @@ package pack import ( + "context" "fmt" "go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/pb" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) @@ -16,16 +18,29 @@ type DB_Comp struct { mgo mgo.ISys } -func (this *DB_Comp) Pack_InitUserPack(uId string) (pack *pb.DB_UserPackData, err error) { - pack = &pb.DB_UserPackData{UserId: uId, Pack: make([]*pb.DB_GridData, 0)} - _, err = this.mgo.InsertOne(DB_PackTable, pack) - return -} +// func (this *DB_Comp) Pack_InitUserPack(uId string) (pack []*pb.DB_UserItemData, err error) { +// pack = &pb.DB_UserPackData{UserId: uId, Pack: make([]*pb.DB_GridData, 0)} +// _, err = this.mgo.InsertOne(DB_PackTable, pack) +// return +// } ///查询用户背包数据 -func (this *DB_Comp) Pack_QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error) { - pack = &pb.DB_UserPackData{} - err = this.mgo.FindOne(DB_PackTable, bson.M{"_id": uId}).Decode(pack) +func (this *DB_Comp) Pack_QueryUserPack(uId string) (items []*pb.DB_UserItemData, err error) { + var ( + cursor *mongo.Cursor + ) + items = make([]*pb.DB_UserItemData, 0) + if cursor, err = this.mgo.Find(DB_PackTable, bson.M{"uid": uId}); err != nil { + return + } else { + for cursor.Next(context.Background()) { + temp := &pb.DB_UserItemData{} + if err = cursor.Decode(temp); err != nil { + return + } + items = append(items, temp) + } + } return } diff --git a/pb/pack_db.pb.go b/pb/pack_db.pb.go index dce5c063f..235c28ad7 100644 --- a/pb/pack_db.pb.go +++ b/pb/pack_db.pb.go @@ -21,22 +21,23 @@ const ( ) //背包格子 -type DB_GridData struct { +type DB_UserItemData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GridId int32 `protobuf:"varint,1,opt,name=GridId,proto3" json:"GridId,omitempty"` //背包格子Id 所在背包数组的下表 - IsEmpty bool `protobuf:"varint,2,opt,name=IsEmpty,proto3" json:"IsEmpty,omitempty"` //是否是空格子 - ItemId int32 `protobuf:"varint,3,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id - Amount uint32 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量 - CTime int64 `protobuf:"varint,5,opt,name=CTime,proto3" json:"CTime,omitempty"` //物品获取时间 - ETime int64 `protobuf:"varint,6,opt,name=ETime,proto3" json:"ETime,omitempty"` //物品过期时间 - IsNewItem bool `protobuf:"varint,7,opt,name=IsNewItem,proto3" json:"IsNewItem,omitempty"` //是否是新的 + GridId string `protobuf:"bytes,1,opt,name=GridId,proto3" json:"GridId,omitempty"` //背包格子Id + UId string `protobuf:"bytes,2,opt,name=UId,proto3" json:"UId,omitempty"` //用户id + IsEmpty bool `protobuf:"varint,3,opt,name=IsEmpty,proto3" json:"IsEmpty,omitempty"` //是否是空格子 + ItemId int32 `protobuf:"varint,4,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id + Amount uint32 `protobuf:"varint,5,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量 + CTime int64 `protobuf:"varint,6,opt,name=CTime,proto3" json:"CTime,omitempty"` //物品获取时间 + ETime int64 `protobuf:"varint,7,opt,name=ETime,proto3" json:"ETime,omitempty"` //物品过期时间 + IsNewItem bool `protobuf:"varint,8,opt,name=IsNewItem,proto3" json:"IsNewItem,omitempty"` //是否是新的 } -func (x *DB_GridData) Reset() { - *x = DB_GridData{} +func (x *DB_UserItemData) Reset() { + *x = DB_UserItemData{} if protoimpl.UnsafeEnabled { mi := &file_pack_pack_db_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -44,13 +45,13 @@ func (x *DB_GridData) Reset() { } } -func (x *DB_GridData) String() string { +func (x *DB_UserItemData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DB_GridData) ProtoMessage() {} +func (*DB_UserItemData) ProtoMessage() {} -func (x *DB_GridData) ProtoReflect() protoreflect.Message { +func (x *DB_UserItemData) ProtoReflect() protoreflect.Message { mi := &file_pack_pack_db_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -62,138 +63,86 @@ func (x *DB_GridData) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DB_GridData.ProtoReflect.Descriptor instead. -func (*DB_GridData) Descriptor() ([]byte, []int) { +// Deprecated: Use DB_UserItemData.ProtoReflect.Descriptor instead. +func (*DB_UserItemData) Descriptor() ([]byte, []int) { return file_pack_pack_db_proto_rawDescGZIP(), []int{0} } -func (x *DB_GridData) GetGridId() int32 { +func (x *DB_UserItemData) GetGridId() string { if x != nil { return x.GridId } - return 0 + return "" } -func (x *DB_GridData) GetIsEmpty() bool { +func (x *DB_UserItemData) GetUId() string { + if x != nil { + return x.UId + } + return "" +} + +func (x *DB_UserItemData) GetIsEmpty() bool { if x != nil { return x.IsEmpty } return false } -func (x *DB_GridData) GetItemId() int32 { +func (x *DB_UserItemData) GetItemId() int32 { if x != nil { return x.ItemId } return 0 } -func (x *DB_GridData) GetAmount() uint32 { +func (x *DB_UserItemData) GetAmount() uint32 { if x != nil { return x.Amount } return 0 } -func (x *DB_GridData) GetCTime() int64 { +func (x *DB_UserItemData) GetCTime() int64 { if x != nil { return x.CTime } return 0 } -func (x *DB_GridData) GetETime() int64 { +func (x *DB_UserItemData) GetETime() int64 { if x != nil { return x.ETime } return 0 } -func (x *DB_GridData) GetIsNewItem() bool { +func (x *DB_UserItemData) GetIsNewItem() bool { if x != nil { return x.IsNewItem } return false } -//用户背包 -type DB_UserPackData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` // 用户Id - Pack []*DB_GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表 -} - -func (x *DB_UserPackData) Reset() { - *x = DB_UserPackData{} - if protoimpl.UnsafeEnabled { - mi := &file_pack_pack_db_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DB_UserPackData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DB_UserPackData) ProtoMessage() {} - -func (x *DB_UserPackData) ProtoReflect() protoreflect.Message { - mi := &file_pack_pack_db_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 DB_UserPackData.ProtoReflect.Descriptor instead. -func (*DB_UserPackData) Descriptor() ([]byte, []int) { - return file_pack_pack_db_proto_rawDescGZIP(), []int{1} -} - -func (x *DB_UserPackData) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -func (x *DB_UserPackData) GetPack() []*DB_GridData { - if x != nil { - return x.Pack - } - return nil -} - var File_pack_pack_db_proto protoreflect.FileDescriptor var file_pack_pack_db_proto_rawDesc = []byte{ 0x0a, 0x12, 0x70, 0x61, 0x63, 0x6b, 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb9, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x47, 0x72, 0x69, 0x64, - 0x44, 0x61, 0x74, 0x61, 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, 0x18, 0x0a, 0x07, - 0x49, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x49, - 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, - 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, - 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x54, 0x69, 0x6d, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x43, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x45, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x45, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, - 0x22, 0x4b, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x44, - 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x04, 0x50, - 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x47, - 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcf, 0x01, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, + 0x49, 0x74, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x72, 0x69, 0x64, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x47, 0x72, 0x69, 0x64, 0x49, 0x64, + 0x12, 0x10, 0x0a, 0x03, 0x55, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x55, + 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x07, 0x49, 0x73, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, + 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, + 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, + 0x43, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x43, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x05, 0x45, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x73, 0x4e, 0x65, + 0x77, 0x49, 0x74, 0x65, 0x6d, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x49, 0x73, 0x4e, + 0x65, 0x77, 0x49, 0x74, 0x65, 0x6d, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -208,18 +157,16 @@ func file_pack_pack_db_proto_rawDescGZIP() []byte { return file_pack_pack_db_proto_rawDescData } -var file_pack_pack_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_pack_pack_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_pack_pack_db_proto_goTypes = []interface{}{ - (*DB_GridData)(nil), // 0: DB_GridData - (*DB_UserPackData)(nil), // 1: DB_UserPackData + (*DB_UserItemData)(nil), // 0: DB_UserItemData } var file_pack_pack_db_proto_depIdxs = []int32{ - 0, // 0: DB_UserPackData.Pack:type_name -> DB_GridData - 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 + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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_pack_pack_db_proto_init() } @@ -229,19 +176,7 @@ func file_pack_pack_db_proto_init() { } if !protoimpl.UnsafeEnabled { file_pack_pack_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DB_GridData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pack_pack_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DB_UserPackData); i { + switch v := v.(*DB_UserItemData); i { case 0: return &v.state case 1: @@ -259,7 +194,7 @@ func file_pack_pack_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pack_pack_db_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 1, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/pack_msg.pb.go b/pb/pack_msg.pb.go index cd1be6dad..ca8145d3d 100644 --- a/pb/pack_msg.pb.go +++ b/pb/pack_msg.pb.go @@ -26,7 +26,7 @@ type GetlistReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IType int32 `protobuf:"varint,1,opt,name=IType,proto3" json:"IType,omitempty"` + IType int32 `protobuf:"varint,1,opt,name=IType,proto3" json:"IType,omitempty"` //道具类型 } func (x *GetlistReq) Reset() { @@ -74,7 +74,7 @@ type GetlistResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Grids []*DB_GridData `protobuf:"bytes,1,rep,name=Grids,proto3" json:"Grids,omitempty"` + Grids []*DB_UserItemData `protobuf:"bytes,1,rep,name=Grids,proto3" json:"Grids,omitempty"` //用户背包列表 } func (x *GetlistResp) Reset() { @@ -109,7 +109,7 @@ func (*GetlistResp) Descriptor() ([]byte, []int) { return file_pack_pack_msg_proto_rawDescGZIP(), []int{1} } -func (x *GetlistResp) GetGrids() []*DB_GridData { +func (x *GetlistResp) GetGrids() []*DB_UserItemData { if x != nil { return x.Grids } @@ -329,24 +329,24 @@ var file_pack_pack_msg_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x70, 0x61, 0x63, 0x6b, 0x2f, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x22, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x31, 0x0a, - 0x0b, 0x47, 0x65, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x05, - 0x47, 0x72, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, - 0x5f, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, 0x72, 0x69, 0x64, 0x73, - 0x22, 0x54, 0x0a, 0x0a, 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, 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, 0x0d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, - 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x55, 0x0a, 0x0b, 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, 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, 0x0e, 0x0a, 0x0c, - 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, - 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x35, 0x0a, + 0x0b, 0x47, 0x65, 0x74, 0x6c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x05, + 0x47, 0x72, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, + 0x5f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x47, + 0x72, 0x69, 0x64, 0x73, 0x22, 0x54, 0x0a, 0x0a, 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, 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, 0x0d, 0x0a, 0x0b, 0x55, 0x73, + 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x55, 0x0a, 0x0b, 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, 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, 0x0e, 0x0a, 0x0c, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, + 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -363,16 +363,16 @@ func file_pack_pack_msg_proto_rawDescGZIP() []byte { var file_pack_pack_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_pack_pack_msg_proto_goTypes = []interface{}{ - (*GetlistReq)(nil), // 0: GetlistReq - (*GetlistResp)(nil), // 1: GetlistResp - (*UseItemReq)(nil), // 2: UseItemReq - (*UseItemResp)(nil), // 3: UseItemResp - (*SellItemReq)(nil), // 4: SellItemReq - (*SellItemResp)(nil), // 5: SellItemResp - (*DB_GridData)(nil), // 6: DB_GridData + (*GetlistReq)(nil), // 0: GetlistReq + (*GetlistResp)(nil), // 1: GetlistResp + (*UseItemReq)(nil), // 2: UseItemReq + (*UseItemResp)(nil), // 3: UseItemResp + (*SellItemReq)(nil), // 4: SellItemReq + (*SellItemResp)(nil), // 5: SellItemResp + (*DB_UserItemData)(nil), // 6: DB_UserItemData } var file_pack_pack_msg_proto_depIdxs = []int32{ - 6, // 0: GetlistResp.Grids:type_name -> DB_GridData + 6, // 0: GetlistResp.Grids:type_name -> DB_UserItemData 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 diff --git a/pb/proto/pack/pack_db.proto b/pb/proto/pack/pack_db.proto index de63fa96a..2afbf07a6 100644 --- a/pb/proto/pack/pack_db.proto +++ b/pb/proto/pack/pack_db.proto @@ -3,18 +3,13 @@ option go_package = ".;pb"; //背包格子 -message DB_GridData { - int32 GridId = 1; //背包格子Id 所在背包数组的下表 - bool IsEmpty = 2; //是否是空格子 - int32 ItemId = 3; //存放物品的Id - uint32 Amount = 4; //存放物品的数量 - int64 CTime = 5; //物品获取时间 - int64 ETime = 6; //物品过期时间 - bool IsNewItem = 7; //是否是新的 +message DB_UserItemData { + string GridId = 1; //背包格子Id + string UId = 2; //用户id + bool IsEmpty = 3; //是否是空格子 + int32 ItemId = 4; //存放物品的Id + uint32 Amount = 5; //存放物品的数量 + int64 CTime = 6; //物品获取时间 + int64 ETime = 7; //物品过期时间 + bool IsNewItem = 8; //是否是新的 } - -//用户背包 -message DB_UserPackData { - string UserId = 1; // @go_tags(`bson:"_id"`) 用户Id - repeated DB_GridData Pack = 2; //背包列表 -} \ No newline at end of file diff --git a/pb/proto/pack/pack_msg.proto b/pb/proto/pack/pack_msg.proto index 5bd1496b2..7b7085a92 100644 --- a/pb/proto/pack/pack_msg.proto +++ b/pb/proto/pack/pack_msg.proto @@ -9,7 +9,7 @@ message GetlistReq { //查询用户背包请求 回应 message GetlistResp { - repeated DB_GridData Grids = 1; //用户背包列表 + repeated DB_UserItemData Grids = 1; //用户背包列表 } //使用物品请求 diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 1ea0a64fc..01542ad56 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -88,7 +88,7 @@ type DB_UserData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty"` //tags:{bson:"_id"}动态Id + UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` // ID Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"` NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"` diff --git a/pb_2.7.py b/pb_2.7.py deleted file mode 100644 index 77fd6d866..000000000 --- a/pb_2.7.py +++ /dev/null @@ -1,37 +0,0 @@ -import io -import os -import re - -def buildProto(outpath,ipath,pbpath,pbfile): - cmdstr = 'protoc.exe --go_out={0} -I{1} {2}/{3}.proto'.format(outpath,ipath,pbpath,pbfile) - os.system(cmdstr) - file_data = "" - tags = {} - tagsstr = "" - file = "{0}/{1}.pb.go".format(outpath,pbfile) - with io.open(file, "r", encoding='utf-8') as f: - for line in f: - if 'tags:' in line: - for v in re.findall(r"`(.+?)`",line)[0].split(' '): - tag = v.split(':') - tags[tag[0]] = tag[1] - for v in re.findall(r"tags:{(.+?)}",line)[0].split(' '): - tag = v.split(':') - tags[tag[0]] = tag[1] - for key,value in tags.items(): - tagsstr += "{0}:{1} ".format(key,value) - line = re.sub(r"`(.+?)`", "`{0}`".format(tagsstr[0:len(tagsstr)-1]), line) - file_data += line - with io.open(file,"w",encoding='utf-8') as f: - f.write(file_data) - -buildProto('./pb','./pb/proto','./pb/proto','comm') -buildProto('./pb','./pb/proto','./pb/proto','errorcode') -buildProto('./pb','./pb/proto','./pb/proto/user','user_db') -buildProto('./pb','./pb/proto','./pb/proto/user','user_msg') -buildProto('./pb','./pb/proto','./pb/proto/pack','pack_db') -buildProto('./pb','./pb/proto','./pb/proto/pack','pack_msg') -buildProto('./pb','./pb/proto','./pb/proto/mail','mail_db') -buildProto('./pb','./pb/proto','./pb/proto/mail','mail_msg') -buildProto('./pb','./pb/proto','./pb/proto/friend','friend_db') -buildProto('./pb','./pb/proto','./pb/proto/friend','friend_msg') \ No newline at end of file