diff --git a/modules/comp_model.go b/modules/comp_model.go index a859fdcf7..16be63719 100644 --- a/modules/comp_model.go +++ b/modules/comp_model.go @@ -123,6 +123,11 @@ func (this *MCompModel) Gets(ids []string, data interface{}, opt ...db.DBOption) return this.DBModel.Gets(ids, data, opt...) } +// 读取多个数据对象 by 用户id +func (this *MCompModel) GetByUids(uids []string, data interface{}, opt ...db.DBOption) (onfound []string, err error) { + return this.DBModel.GetByUids(uids, data, opt...) +} + // 获取列表数据 注意 data 必须是 切片的指针 *[]type func (this *MCompModel) GetList(uid string, data interface{}) (err error) { return this.DBModel.GetList(uid, data) diff --git a/modules/guildgve/api_challengefinish.go b/modules/guildgve/api_challengefinish.go index 1f7dc72ad..0cfac7fbf 100644 --- a/modules/guildgve/api_challengefinish.go +++ b/modules/guildgve/api_challengefinish.go @@ -97,7 +97,6 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.GuildGve if v.Hp > 0 { ok = true v.Hp -= score.Hp - record := &pb.DBGveRecord{ User: &pb.DBSimpleUser{ Uid: session.GetUserId(), @@ -111,6 +110,7 @@ func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.GuildGve Rating: score.Id, Harm: req.Report.Harm, } + member.Record[req.Boosid] = record for i, v := range req.Report.Info.Redflist[0].Team { if int32(i) == req.Report.Info.Redflist[0].Leadpos && v != nil { record.CaptainHeroId = v.HeroID diff --git a/modules/guildgve/api_friendsrecord.go b/modules/guildgve/api_friendsrecord.go new file mode 100644 index 000000000..831b021e8 --- /dev/null +++ b/modules/guildgve/api_friendsrecord.go @@ -0,0 +1,48 @@ +package guildgve + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" +) + +// 参数校验 +func (this *apiComp) FriendsRecordCheck(session comm.IUserSession, req *pb.GuildGveFriendsRecordReq) (errdata *pb.ErrorData) { + if len(req.Friends) == 0 || len(req.Friends) > 50 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + Message: req.String(), + } + } + return +} + +// 获取工会boos战信息 +func (this *apiComp) FriendsRecord(session comm.IUserSession, req *pb.GuildGveFriendsRecordReq) (errdata *pb.ErrorData) { + var ( + member []*pb.DBGuildMember + record []*pb.DBGveRecord + err error + ) + if errdata = this.FriendsRecordCheck(session, req); errdata != nil { + return + } + + if member, err = this.module.modelGuildMember.inquireGuildMembers(req.Friends); err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_DBError, + Title: pb.ErrorCode_DBError.ToString(), + Message: err.Error(), + } + return + } + + for _, v := range member { + if r, ok := v.Record[req.Boosid]; ok { + record = append(record, r) + } + } + + session.SendMsg(string(this.module.GetType()), "friendsrecord", &pb.GuildGveFriendsRecordResp{Boosid: req.Boosid, Record: record}) + return +} diff --git a/modules/guildgve/modelGuildMember.go b/modules/guildgve/modelGuildMember.go index 0dfabedda..3d43b5b31 100644 --- a/modules/guildgve/modelGuildMember.go +++ b/modules/guildgve/modelGuildMember.go @@ -62,6 +62,7 @@ func (this *ModelGuildMember) getGuildMember(guild, uid string) (results *pb.DBG Guild: guild, Boosticket: conf.GuildBossCeiling, Refreshtime: configure.Now().Unix(), + Record: make(map[int32]*pb.DBGveRecord), } err = this.Add(uid, results) } @@ -76,9 +77,20 @@ func (this *ModelGuildMember) updateGuildMember(data *pb.DBGuildMember) (err err "guild": data.Guild, "boosticket": data.Boosticket, "refreshtime": data.Refreshtime, + "record": data.Record, }); err != nil { this.module.Error("更新工会成员信息 错误!", log.Field{Key: "err", Value: err.Error()}) return } return } + +// 查询多个用户的数据 +func (this *ModelGuildMember) inquireGuildMembers(uids []string) (results []*pb.DBGuildMember, err error) { + results = make([]*pb.DBGuildMember, 0) + if _, err = this.GetByUids(uids, &results); err != nil && err != mgo.MongodbNil { + this.module.Errorln(err) + return + } + return +} diff --git a/pb/guildgve_db.pb.go b/pb/guildgve_db.pb.go index 16c98c400..73a6ba3c1 100644 --- a/pb/guildgve_db.pb.go +++ b/pb/guildgve_db.pb.go @@ -202,11 +202,12 @@ type DBGuildMember struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id - Guild string `protobuf:"bytes,3,opt,name=guild,proto3" json:"guild"` //工会id - Boosticket int32 `protobuf:"varint,4,opt,name=boosticket,proto3" json:"boosticket"` //工会boos战门票 - Refreshtime int64 `protobuf:"varint,5,opt,name=refreshtime,proto3" json:"refreshtime"` //门票刷新时间 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id + Guild string `protobuf:"bytes,3,opt,name=guild,proto3" json:"guild"` //工会id + Boosticket int32 `protobuf:"varint,4,opt,name=boosticket,proto3" json:"boosticket"` //工会boos战门票 + Refreshtime int64 `protobuf:"varint,5,opt,name=refreshtime,proto3" json:"refreshtime"` //门票刷新时间 + Record map[int32]*DBGveRecord `protobuf:"bytes,6,rep,name=record,proto3" json:"record" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //战斗记录 } func (x *DBGuildMember) Reset() { @@ -276,6 +277,13 @@ func (x *DBGuildMember) GetRefreshtime() int64 { return 0 } +func (x *DBGuildMember) GetRecord() map[int32]*DBGveRecord { + if x != nil { + return x.Record + } + return nil +} + //工会轮盘记录 type DBGuildRouletteRecord struct { state protoimpl.MessageState @@ -707,7 +715,7 @@ var file_guildgve_guildgve_db_proto_rawDesc = []byte{ 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x12, 0x23, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65, 0x42, 0x6f, 0x73, 0x73, - 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x73, 0x22, 0x89, 0x01, 0x0a, 0x0d, 0x44, 0x42, 0x47, 0x75, 0x69, + 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x73, 0x22, 0x86, 0x02, 0x0a, 0x0d, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x67, 0x75, @@ -716,49 +724,57 @@ var file_guildgve_guildgve_db_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x62, 0x6f, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x74, 0x69, - 0x6d, 0x65, 0x22, 0x63, 0x0a, 0x15, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x6f, 0x75, - 0x6c, 0x65, 0x74, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x47, - 0x75, 0x69, 0x6c, 0x64, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x47, 0x75, - 0x69, 0x6c, 0x64, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x6c, 0x65, 0x74, 0x74, - 0x65, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, - 0x6f, 0x75, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x08, 0x72, - 0x6f, 0x75, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x22, 0x5e, 0x0a, 0x0e, 0x44, 0x42, 0x47, 0x75, 0x69, - 0x6c, 0x64, 0x47, 0x76, 0x65, 0x42, 0x6f, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, - 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, - 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x68, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x68, - 0x70, 0x12, 0x24, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, - 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x22, 0xc3, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x47, 0x76, - 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x21, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, - 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x24, - 0x0a, 0x0d, 0x63, 0x61, 0x70, 0x74, 0x61, 0x69, 0x6e, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x61, 0x70, 0x74, 0x61, 0x69, 0x6e, 0x48, 0x65, - 0x72, 0x6f, 0x49, 0x64, 0x12, 0x2b, 0x0a, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x53, 0x69, 0x6d, 0x70, - 0x6c, 0x65, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x72, - 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x68, 0x61, 0x72, 0x6d, 0x22, 0x72, 0x0a, - 0x0c, 0x44, 0x42, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x10, 0x0a, - 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, - 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, - 0x6b, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x6b, 0x69, 0x6e, 0x12, - 0x10, 0x0a, 0x03, 0x73, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x65, - 0x78, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, - 0x76, 0x22, 0x50, 0x0a, 0x0c, 0x44, 0x42, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x48, 0x65, 0x72, - 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, - 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, - 0x12, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, - 0x74, 0x61, 0x72, 0x22, 0x4a, 0x0a, 0x13, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x6f, 0x75, 0x6c, - 0x65, 0x74, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x05, - 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x65, 0x12, 0x32, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x06, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x4d, 0x65, 0x6d, 0x62, + 0x65, 0x72, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, + 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x1a, 0x47, 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x65, + 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, + 0x63, 0x0a, 0x15, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x6f, 0x75, 0x6c, 0x65, 0x74, + 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x47, 0x75, 0x69, 0x6c, + 0x64, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x47, 0x75, 0x69, 0x6c, 0x64, + 0x69, 0x64, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x6f, 0x75, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x18, 0x07, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x6f, 0x75, 0x6c, + 0x65, 0x74, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x08, 0x72, 0x6f, 0x75, 0x6c, + 0x65, 0x74, 0x74, 0x65, 0x22, 0x5e, 0x0a, 0x0e, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, + 0x76, 0x65, 0x42, 0x6f, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x12, 0x0e, + 0x0a, 0x02, 0x68, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x68, 0x70, 0x12, 0x24, + 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, + 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, + 0x63, 0x6f, 0x72, 0x64, 0x22, 0xc3, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x65, + 0x63, 0x6f, 0x72, 0x64, 0x12, 0x21, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x63, + 0x61, 0x70, 0x74, 0x61, 0x69, 0x6e, 0x48, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x63, 0x61, 0x70, 0x74, 0x61, 0x69, 0x6e, 0x48, 0x65, 0x72, 0x6f, 0x49, + 0x64, 0x12, 0x2b, 0x0a, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x48, + 0x65, 0x72, 0x6f, 0x52, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, + 0x0a, 0x06, 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, + 0x72, 0x61, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x72, 0x6d, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x68, 0x61, 0x72, 0x6d, 0x22, 0x72, 0x0a, 0x0c, 0x44, 0x42, + 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, + 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x6b, 0x69, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x6b, 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, + 0x73, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x65, 0x78, 0x12, 0x0e, + 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x22, 0x50, + 0x0a, 0x0c, 0x44, 0x42, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x48, 0x65, 0x72, 0x6f, 0x12, 0x16, + 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, + 0x73, 0x74, 0x61, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x73, 0x74, 0x61, 0x72, + 0x22, 0x4a, 0x0a, 0x13, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, 0x6f, 0x75, 0x6c, 0x65, 0x74, 0x74, + 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x05, 0x61, 0x77, 0x61, + 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, + 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -773,7 +789,7 @@ func file_guildgve_guildgve_db_proto_rawDescGZIP() []byte { return file_guildgve_guildgve_db_proto_rawDescData } -var file_guildgve_guildgve_db_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_guildgve_guildgve_db_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_guildgve_guildgve_db_proto_goTypes = []interface{}{ (*DBGuildGveBossConf)(nil), // 0: DBGuildGveBossConf (*DBGuildGve)(nil), // 1: DBGuildGve @@ -784,20 +800,23 @@ var file_guildgve_guildgve_db_proto_goTypes = []interface{}{ (*DBSimpleUser)(nil), // 6: DBSimpleUser (*DBSimpleHero)(nil), // 7: DBSimpleHero (*DBGveRouletteRecord)(nil), // 8: DBGveRouletteRecord - (*UserAssets)(nil), // 9: UserAssets + nil, // 9: DBGuildMember.RecordEntry + (*UserAssets)(nil), // 10: UserAssets } var file_guildgve_guildgve_db_proto_depIdxs = []int32{ - 4, // 0: DBGuildGve.boos:type_name -> DBGuildGveBoss - 8, // 1: DBGuildRouletteRecord.roulette:type_name -> DBGveRouletteRecord - 5, // 2: DBGuildGveBoss.record:type_name -> DBGveRecord - 6, // 3: DBGveRecord.user:type_name -> DBSimpleUser - 7, // 4: DBGveRecord.formation:type_name -> DBSimpleHero - 9, // 5: DBGveRouletteRecord.award:type_name -> UserAssets - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 4, // 0: DBGuildGve.boos:type_name -> DBGuildGveBoss + 9, // 1: DBGuildMember.record:type_name -> DBGuildMember.RecordEntry + 8, // 2: DBGuildRouletteRecord.roulette:type_name -> DBGveRouletteRecord + 5, // 3: DBGuildGveBoss.record:type_name -> DBGveRecord + 6, // 4: DBGveRecord.user:type_name -> DBSimpleUser + 7, // 5: DBGveRecord.formation:type_name -> DBSimpleHero + 10, // 6: DBGveRouletteRecord.award:type_name -> UserAssets + 5, // 7: DBGuildMember.RecordEntry.value:type_name -> DBGveRecord + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_guildgve_guildgve_db_proto_init() } @@ -922,7 +941,7 @@ func file_guildgve_guildgve_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_guildgve_guildgve_db_proto_rawDesc, NumEnums: 0, - NumMessages: 9, + NumMessages: 10, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/guildgve_msg.pb.go b/pb/guildgve_msg.pb.go index 5c21d7f5c..87c694754 100644 --- a/pb/guildgve_msg.pb.go +++ b/pb/guildgve_msg.pb.go @@ -970,6 +970,118 @@ func (x *GuildGveRouletteChangePush) GetRecord() *DBGuildRouletteRecord { return nil } +//好友战斗记录请求 +type GuildGveFriendsRecordReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Boosid int32 `protobuf:"varint,1,opt,name=boosid,proto3" json:"boosid"` + Friends []string `protobuf:"bytes,2,rep,name=friends,proto3" json:"friends"` //奖励 +} + +func (x *GuildGveFriendsRecordReq) Reset() { + *x = GuildGveFriendsRecordReq{} + if protoimpl.UnsafeEnabled { + mi := &file_guildgve_guildgve_msg_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GuildGveFriendsRecordReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GuildGveFriendsRecordReq) ProtoMessage() {} + +func (x *GuildGveFriendsRecordReq) ProtoReflect() protoreflect.Message { + mi := &file_guildgve_guildgve_msg_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GuildGveFriendsRecordReq.ProtoReflect.Descriptor instead. +func (*GuildGveFriendsRecordReq) Descriptor() ([]byte, []int) { + return file_guildgve_guildgve_msg_proto_rawDescGZIP(), []int{17} +} + +func (x *GuildGveFriendsRecordReq) GetBoosid() int32 { + if x != nil { + return x.Boosid + } + return 0 +} + +func (x *GuildGveFriendsRecordReq) GetFriends() []string { + if x != nil { + return x.Friends + } + return nil +} + +//好友战斗记录请求 回应 +type GuildGveFriendsRecordResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Boosid int32 `protobuf:"varint,1,opt,name=boosid,proto3" json:"boosid"` + Record []*DBGveRecord `protobuf:"bytes,2,rep,name=record,proto3" json:"record"` +} + +func (x *GuildGveFriendsRecordResp) Reset() { + *x = GuildGveFriendsRecordResp{} + if protoimpl.UnsafeEnabled { + mi := &file_guildgve_guildgve_msg_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GuildGveFriendsRecordResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GuildGveFriendsRecordResp) ProtoMessage() {} + +func (x *GuildGveFriendsRecordResp) ProtoReflect() protoreflect.Message { + mi := &file_guildgve_guildgve_msg_proto_msgTypes[18] + 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 GuildGveFriendsRecordResp.ProtoReflect.Descriptor instead. +func (*GuildGveFriendsRecordResp) Descriptor() ([]byte, []int) { + return file_guildgve_guildgve_msg_proto_rawDescGZIP(), []int{18} +} + +func (x *GuildGveFriendsRecordResp) GetBoosid() int32 { + if x != nil { + return x.Boosid + } + return 0 +} + +func (x *GuildGveFriendsRecordResp) GetRecord() []*DBGveRecord { + if x != nil { + return x.Record + } + return nil +} + var File_guildgve_guildgve_msg_proto protoreflect.FileDescriptor var file_guildgve_guildgve_msg_proto_rawDesc = []byte{ @@ -1066,8 +1178,18 @@ var file_guildgve_guildgve_msg_proto_rawDesc = []byte{ 0x50, 0x75, 0x73, 0x68, 0x12, 0x2e, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x44, 0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x6f, 0x75, 0x6c, 0x65, 0x74, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, - 0x63, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x72, 0x64, 0x22, 0x4c, 0x0a, 0x18, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65, + 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, + 0x12, 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x73, 0x22, 0x59, 0x0a, 0x19, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65, 0x46, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, + 0x16, 0x0a, 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x06, 0x62, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, + 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x47, 0x76, 0x65, 0x52, + 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x06, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1082,7 +1204,7 @@ func file_guildgve_guildgve_msg_proto_rawDescGZIP() []byte { return file_guildgve_guildgve_msg_proto_rawDescData } -var file_guildgve_guildgve_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_guildgve_guildgve_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 19) var file_guildgve_guildgve_msg_proto_goTypes = []interface{}{ (*GuildGveInfoReq)(nil), // 0: GuildGveInfoReq (*GuildGveInfoResp)(nil), // 1: GuildGveInfoResp @@ -1101,30 +1223,34 @@ var file_guildgve_guildgve_msg_proto_goTypes = []interface{}{ (*GuildGveStageChangePush)(nil), // 14: GuildGveStageChangePush (*GuildGveBoosChangePush)(nil), // 15: GuildGveBoosChangePush (*GuildGveRouletteChangePush)(nil), // 16: GuildGveRouletteChangePush - (*DBGuildGve)(nil), // 17: DBGuildGve - (*UserAssets)(nil), // 18: UserAssets - (*BattleFormation)(nil), // 19: BattleFormation - (*BattleInfo)(nil), // 20: BattleInfo - (*BattleReport)(nil), // 21: BattleReport - (*DBGuildRouletteRecord)(nil), // 22: DBGuildRouletteRecord + (*GuildGveFriendsRecordReq)(nil), // 17: GuildGveFriendsRecordReq + (*GuildGveFriendsRecordResp)(nil), // 18: GuildGveFriendsRecordResp + (*DBGuildGve)(nil), // 19: DBGuildGve + (*UserAssets)(nil), // 20: UserAssets + (*BattleFormation)(nil), // 21: BattleFormation + (*BattleInfo)(nil), // 22: BattleInfo + (*BattleReport)(nil), // 23: BattleReport + (*DBGuildRouletteRecord)(nil), // 24: DBGuildRouletteRecord + (*DBGveRecord)(nil), // 25: DBGveRecord } var file_guildgve_guildgve_msg_proto_depIdxs = []int32{ - 17, // 0: GuildGveInfoResp.info:type_name -> DBGuildGve + 19, // 0: GuildGveInfoResp.info:type_name -> DBGuildGve 5, // 1: GuildGveRankResp.list:type_name -> GuildGveRankItem - 18, // 2: GuildGveRouletteResp.award:type_name -> UserAssets - 19, // 3: GuildGveChallengeReq.battle:type_name -> BattleFormation - 20, // 4: GuildGveChallengeResp.info:type_name -> BattleInfo - 21, // 5: GuildGveChallengeFinishReq.report:type_name -> BattleReport - 18, // 6: GuildGveChallengeFinishResp.award:type_name -> UserAssets - 17, // 7: GuildGveInfoChangePush.info:type_name -> DBGuildGve - 17, // 8: GuildGveStageChangePush.info:type_name -> DBGuildGve - 17, // 9: GuildGveBoosChangePush.info:type_name -> DBGuildGve - 22, // 10: GuildGveRouletteChangePush.record:type_name -> DBGuildRouletteRecord - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 20, // 2: GuildGveRouletteResp.award:type_name -> UserAssets + 21, // 3: GuildGveChallengeReq.battle:type_name -> BattleFormation + 22, // 4: GuildGveChallengeResp.info:type_name -> BattleInfo + 23, // 5: GuildGveChallengeFinishReq.report:type_name -> BattleReport + 20, // 6: GuildGveChallengeFinishResp.award:type_name -> UserAssets + 19, // 7: GuildGveInfoChangePush.info:type_name -> DBGuildGve + 19, // 8: GuildGveStageChangePush.info:type_name -> DBGuildGve + 19, // 9: GuildGveBoosChangePush.info:type_name -> DBGuildGve + 24, // 10: GuildGveRouletteChangePush.record:type_name -> DBGuildRouletteRecord + 25, // 11: GuildGveFriendsRecordResp.record:type_name -> DBGveRecord + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_guildgve_guildgve_msg_proto_init() } @@ -1340,6 +1466,30 @@ func file_guildgve_guildgve_msg_proto_init() { return nil } } + file_guildgve_guildgve_msg_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GuildGveFriendsRecordReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_guildgve_guildgve_msg_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GuildGveFriendsRecordResp); 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{ @@ -1347,7 +1497,7 @@ func file_guildgve_guildgve_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_guildgve_guildgve_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 17, + NumMessages: 19, NumExtensions: 0, NumServices: 0, }, diff --git a/sys/db/dbmodel.go b/sys/db/dbmodel.go index 38a87f483..fd9b0b11f 100644 --- a/sys/db/dbmodel.go +++ b/sys/db/dbmodel.go @@ -386,6 +386,135 @@ func (this *DBModel) Get(uid string, data interface{}, opt ...DBOption) (err err return } +// 读取全部数据 +func (this *DBModel) GetByUids(uids []string, data interface{}, opt ...DBOption) (onfound []string, err error) { + //defer log.Debug("DBModel GetListObjs", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "ids", Value: ids}, log.Field{Key: "data", Value: data}) + defer func() { //程序异常 收集异常信息传递给前端显示 + if r := recover(); r != nil { + buf := make([]byte, 4096) + l := runtime.Stack(buf, false) + err = fmt.Errorf("%v: %s", r, buf[:l]) + log.Errorf("[DB Gets] TableName:%s ids:%v", this.TableName, uids) + } + }() + var ( + dtype reflect2.Type + dkind reflect.Kind + sType reflect2.Type + sliceType *reflect2.UnsafeSliceType + sliceelemType reflect2.Type + decoder codecore.IDecoderMapJson + encoder codecore.IEncoderMapJson + dptr unsafe.Pointer + elemPtr unsafe.Pointer + n int + ok bool + keys map[string]string = make(map[string]string) + tempdata map[string]string + pipe *pipe.RedisPipe = this.Redis.RedisPipe(context.TODO()) + result []*redis.StringStringMapCmd = make([]*redis.StringStringMapCmd, len(uids)) + c *mongo.Cursor + ) + onfound = make([]string, 0, len(uids)) + dptr = reflect2.PtrOf(data) + dtype = reflect2.TypeOf(data) + dkind = dtype.Kind() + if dkind != reflect.Ptr { + err = fmt.Errorf("MCompModel: GetList(non-pointer %T)", data) + return + } + sType = dtype.(*reflect2.UnsafePtrType).Elem() + if sType.Kind() != reflect.Slice { + err = fmt.Errorf("MCompModel: GetList(data no slice %T)", data) + return + } + sliceType = sType.(*reflect2.UnsafeSliceType) + sliceelemType = sliceType.Elem() + if sliceelemType.Kind() != reflect.Ptr { + err = fmt.Errorf("MCompModel: GetList(sliceelemType non-pointer %T)", data) + return + } + if decoder, ok = codec.DecoderOf(sliceelemType, defconf).(codecore.IDecoderMapJson); !ok { + err = fmt.Errorf("MCompModel: GetList(data not support MarshalMapJson %T)", data) + return + } + sliceelemType = sliceelemType.(*reflect2.UnsafePtrType).Elem() + for i, v := range uids { + result[i] = pipe.HGetAllToMapString(this.ukey(v)) + } + if _, err = pipe.Exec(); err == nil { + for i, v := range result { + if tempdata, err = v.Result(); err == nil && len(tempdata) > 0 { + sliceType.UnsafeGrow(dptr, n+1) + elemPtr = sliceType.UnsafeGetIndex(dptr, n) + if *((*unsafe.Pointer)(elemPtr)) == nil { + newPtr := sliceelemType.UnsafeNew() + if err = decoder.DecodeForMapJson(newPtr, json.GetReader([]byte{}), tempdata); err != nil { + log.Errorf("err:%v", err) + return + } + *((*unsafe.Pointer)(elemPtr)) = newPtr + } else { + decoder.DecodeForMapJson(*((*unsafe.Pointer)(elemPtr)), json.GetReader([]byte{}), tempdata) + } + n++ + } else { + onfound = append(onfound, uids[i]) + } + } + } else { + onfound = uids + } + + if len(onfound) > 0 { + if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": bson.M{"$in": onfound}}); err != nil { + return + } else { + if encoder, ok = codec.EncoderOf(sliceelemType, defconf).(codecore.IEncoderMapJson); !ok { + err = fmt.Errorf("MCompModel: GetList(data not support UnMarshalMapJson %T)", data) + return + } + pipe := this.Redis.RedisPipe(context.TODO()) + for c.Next(context.Background()) { + _id := c.Current.Lookup("_id").StringValue() + sliceType.UnsafeGrow(dptr, n+1) + elemPtr = sliceType.UnsafeGetIndex(dptr, n) + if *((*unsafe.Pointer)(elemPtr)) == nil { + newPtr := sliceelemType.UnsafeNew() + *((*unsafe.Pointer)(elemPtr)) = newPtr + } + elem := sliceType.GetIndex(data, n) + if err = c.Decode(elem); err != nil { + return + } + if tempdata, err = encoder.EncodeToMapJson(*((*unsafe.Pointer)(elemPtr)), json.GetWriter()); err != nil { + return + } + key := this.ukey(_id) + pipe.HMSetForMap(key, tempdata) + keys[_id] = key + n++ + for i, v := range onfound { + if v == _id { + onfound = append(onfound[:i], onfound[i+1:]...) + break + } + } + + } + if len(keys) > 0 { + _, err = pipe.Exec() + } + } + } + if this.Expired > 0 { + for _, v := range uids { + this.conn.UpDateModelExpired(this.ukey(v), nil, this.Expired) + } + } + return +} + // 读取全部数据 func (this *DBModel) GetByID(id string, data interface{}, opt ...DBOption) (err error) { //defer log.Debug("DBModel Get", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})