From a839bbcd3c28c2042cc92c0377f8935e620a1e9b Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Sun, 15 Jan 2023 10:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/ui/views/sociaty_boss.go | 16 +- modules/sociaty/api_cross_bossmain.go | 16 ++ modules/sociaty/api_cross_bossrank.go | 4 +- modules/sociaty/model_sociatyboss.go | 143 +++++++++++----- pb/sociaty_msg.pb.go | 229 +++++++++++++++----------- sys/db/init_test.go | 35 ++-- 6 files changed, 289 insertions(+), 154 deletions(-) diff --git a/cmd/v2/ui/views/sociaty_boss.go b/cmd/v2/ui/views/sociaty_boss.go index 79d972b2b..8b681dbda 100644 --- a/cmd/v2/ui/views/sociaty_boss.go +++ b/cmd/v2/ui/views/sociaty_boss.go @@ -81,7 +81,11 @@ func (s *SociatyBossView) CreateView(t *model.TestCase) fyne.CanvasObject { bottomLabels := container.NewHBox( s.ticketLabel, s.settleTimeLabel, s.endTimeLabel, ) - c := container.NewBorder(btns, bottomLabels, nil, nil) + leftLabels := container.NewHBox( + s.personRankingLabel, + s.sociatyRankingLabel, + ) + c := container.NewBorder(btns, bottomLabels, leftLabels, nil) s.listenTeams() s.listenBossmain() @@ -150,6 +154,16 @@ func (s *SociatyBossView) listenBossmain() { fmt.Sprintf("挑战券:%d", rsp.Ticket), ) s.ticketLabel.Refresh() + + s.sociatyRankingLabel.SetText( + fmt.Sprintf("公会排名:%d", rsp.SociatyRanking), + ) + s.sociatyRankingLabel.Refresh() + + s.personRankingLabel.SetText( + fmt.Sprintf("个人排名:%d", rsp.PersonalRanking), + ) + s.personRankingLabel.Refresh() }, }) s.bossFlag = true diff --git a/modules/sociaty/api_cross_bossmain.go b/modules/sociaty/api_cross_bossmain.go index c1d8fae20..0c37a76c6 100644 --- a/modules/sociaty/api_cross_bossmain.go +++ b/modules/sociaty/api_cross_bossmain.go @@ -1,6 +1,7 @@ package sociaty import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" @@ -64,6 +65,21 @@ func (this *apiComp) Bossmain(session comm.IUserSession, req *pb.SociatyBMainReq rsp.EndTime = dbs.EndTime rsp.SettlementTime = dbs.SettlementTime + // 个人积分 + dbr := this.module.modelSociatyBoss.getChallengeRecord(uid) + if dbr != nil { + rsp.Total = dbr.Total + rsp.HighIntegrals = dbr.Integrals + } + + //个人排名 + rsp.PersonalRanking = this.module.modelSociatyBoss.getRankingByUid( + fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_PERSONAL_RANK), uid) + + // 公会排名 + rsp.SociatyRanking = this.module.modelSociatyBoss.getRankingByUid( + fmt.Sprintf("%s:%s", this.module.modelSociatyBoss.TableName, BOSS_SOCIATY_RANK), uid) + if sm := this.module.modelSociaty.getMemberInfo(sociaty, uid); sm != nil { rsp.Teams = sm.Teams } diff --git a/modules/sociaty/api_cross_bossrank.go b/modules/sociaty/api_cross_bossrank.go index 820414264..380b61df5 100644 --- a/modules/sociaty/api_cross_bossrank.go +++ b/modules/sociaty/api_cross_bossrank.go @@ -20,13 +20,13 @@ func (this *apiComp) Brank(session comm.IUserSession, req *pb.SociatyBRankReq) ( } uid := session.GetUserId() sociaty := this.module.modelSociaty.getUserSociaty(uid) - if sociaty == nil { + if sociaty == nil { code = pb.ErrorCode_SociatyNoFound this.module.Error("当前玩家所在的公会未找到", log.Field{Key: "uid", Value: uid}) return } - sri := this.module.modelSociatyBoss.rank(sociaty.Name, req.RankType) + sri := this.module.modelSociatyBoss.bossRank(sociaty, req.RankType) rsp := &pb.SociatyBRankResp{ Rank: sri, diff --git a/modules/sociaty/model_sociatyboss.go b/modules/sociaty/model_sociatyboss.go index 6501b2c0e..953d92de1 100644 --- a/modules/sociaty/model_sociatyboss.go +++ b/modules/sociaty/model_sociatyboss.go @@ -21,9 +21,10 @@ import ( ) var ( - BOSS_SPORTS = "sports" - BOSS_RANK = "rank" - SPORTS_HOUR = 3 * 24 //赛季周期 + BOSS_SPORTS = "sports" + BOSS_PERSONAL_RANK = "personalrank" //个人排行key + BOSS_SOCIATY_RANK = "sociatyrank" //公会排名 + SPORTS_HOUR = 3 * 24 //赛季周期 ) type ModelSociatyBoss struct { @@ -293,14 +294,14 @@ func (s *ModelSociatyBoss) updateChallengeRecord(uid, sociatyId string, record * return nil } -// 记入排行 -func (s *ModelSociatyBoss) addRank(uid string, integral int64) error { +// 记入个人排行 +func (s *ModelSociatyBoss) addPersonalRank(uid string, integral int64) error { var ( pipe *pipe.RedisPipe = s.Redis.RedisPipe(context.TODO()) m *redis.Z ) m = &redis.Z{Score: float64(integral), Member: uid} - if cmd := pipe.ZAdd(fmt.Sprintf("%s:%s", s.TableName, BOSS_RANK), m); cmd != nil { + if cmd := pipe.ZAdd(fmt.Sprintf("%s:%s", s.TableName, BOSS_PERSONAL_RANK), m); cmd != nil { _, err := cmd.Result() if err != nil { return err @@ -312,17 +313,40 @@ func (s *ModelSociatyBoss) addRank(uid string, integral int64) error { return nil } +// 记入公会排行 +func (s *ModelSociatyBoss) addSociatyRank(uid string, integral int64) error { + dbr := s.getChallengeRecord(uid) + if dbr == nil { + return errors.New("没有挑战记录") + } + + if dbr.SociatyId != "" { + var pipe *pipe.RedisPipe = s.Redis.RedisPipe(context.TODO()) + if cmd := pipe.ZIncrBy(fmt.Sprintf("%s:%s", s.TableName, BOSS_SOCIATY_RANK), float64(integral), dbr.SociatyId); cmd != nil { + _, err := cmd.Result() + if err != nil { + return err + } + } + if _, err := pipe.Exec(); err != nil { + return err + } + } + + return nil +} + // 伤害转换积分 func (s *ModelSociatyBoss) transIntegral(harm int32) int64 { return int64(harm) } // 查询排行榜 -func (this *ModelSociatyBoss) queryRankUid(count int64) (ranks []string, err error) { +func (s *ModelSociatyBoss) queryRankUid(count int64) (ranks []string, err error) { var ( result []string ) - if result, err = this.DBModel.Redis.ZRevRange(this.TableName, 0, count).Result(); err != nil { + if result, err = s.DBModel.Redis.ZRevRange(s.TableName, 0, count).Result(); err != nil { return } ranks = make([]string, 0) @@ -333,8 +357,8 @@ func (this *ModelSociatyBoss) queryRankUid(count int64) (ranks []string, err err } // 取积分 -func (this *ModelSociatyBoss) getScoreByUid(uid string) int64 { - result, err := this.DBModel.Redis.ZScore(this.TableName, uid) +func (s *ModelSociatyBoss) getScoreByUid(key, member string) int64 { + result, err := s.DBModel.Redis.ZScore(key, member) if err != nil { return 0 } @@ -342,8 +366,8 @@ func (this *ModelSociatyBoss) getScoreByUid(uid string) int64 { } // 取排名 -func (this *ModelSociatyBoss) getRankingByUid(uid string) int64 { - result, err := this.DBModel.Redis.ZRevRank(this.TableName, uid) +func (s *ModelSociatyBoss) getRankingByUid(key, member string) int64 { + result, err := s.DBModel.Redis.ZRevRank(key, member) if err != nil { return 0 } @@ -351,40 +375,71 @@ func (this *ModelSociatyBoss) getRankingByUid(uid string) int64 { } // 排行榜 -func (s *ModelSociatyBoss) rank(sociatyName string, rankType int32) (res []*pb.SociatyRankInfo) { - var rankCount int64 - switch rankType { - case 1: //个人 - rankCount = 1000 - case 2: //成员 - rankCount = 50 - case 3: //公会 - rankCount = 50 - } - // 所有排行记录 - rankUids, err := s.queryRankUid(rankCount) - if err != nil { - return nil - } - for _, uid := range rankUids { - imodule, err := s.service.GetModule(comm.ModuleUser) +func (s *ModelSociatyBoss) bossRank(sociaty *pb.DBSociaty, rankType int32) (res []*pb.SociatyRankInfo) { + var ( + rankCount int64 + key string + ) + + rank := func() []*pb.SociatyRankInfo { + // 所有排行记录 + rankUids, err := s.queryRankUid(rankCount) if err != nil { return nil } - if iuser, ok := imodule.(comm.IUser); ok { - if user := iuser.GetUser(uid); user != nil && user.Uid != "" { - res = append(res, &pb.SociatyRankInfo{ - SociatyName: sociatyName, - Name: user.Name, - Head: user.Avatar, - Lv: user.Lv, - Ranking: s.getRankingByUid(user.Uid), - Integral: s.getScoreByUid(user.Uid), - }) + for _, uid := range rankUids { + imodule, err := s.service.GetModule(comm.ModuleUser) + if err != nil { + return nil + } + if iuser, ok := imodule.(comm.IUser); ok { + if user := iuser.GetUser(uid); user != nil && user.Uid != "" { + res = append(res, &pb.SociatyRankInfo{ + SociatyName: sociaty.Name, + Name: user.Name, + Head: user.Avatar, + Lv: user.Lv, + Ranking: s.getRankingByUid(key, user.Uid), + Integral: s.getScoreByUid(key, user.Uid), + }) + } } - } + return res } + switch rankType { + case 1: //个人 + rankCount = 1000 + key = fmt.Sprintf("%s:%s", s.TableName, BOSS_PERSONAL_RANK) + rank() + case 2: //公会 + rankCount = 50 + key = fmt.Sprintf("%s:%s", s.TableName, BOSS_SOCIATY_RANK) + rank() + case 3: //公会成员 + for _, m := range sociaty.Members { + imodule, err := s.service.GetModule(comm.ModuleUser) + if err != nil { + return nil + } + if iuser, ok := imodule.(comm.IUser); ok { + if user := iuser.GetUser(m.Uid); user != nil && user.Uid != "" { + res = append(res, &pb.SociatyRankInfo{ + SociatyName: sociaty.Name, + Name: user.Name, + Head: user.Avatar, + Lv: user.Lv, + Ranking: s.getRankingByUid(key, user.Uid), + Integral: s.getScoreByUid(key, user.Uid), + }) + } + } + } + sort.SliceStable(res, func(i, j int) bool { + return res[i].Integral > res[j].Integral + }) + } + return nil } @@ -409,7 +464,7 @@ func (s *ModelSociatyBoss) reset() error { } } // 清理排行榜 - if err := s.Del(BOSS_RANK); err != nil { + if err := s.Del(BOSS_PERSONAL_RANK); err != nil { s.moduleSociaty.Error("清理排行榜", log.Field{Key: "err", Value: err.Error()}) } return nil @@ -465,8 +520,10 @@ func (s *ModelSociatyBoss) settlement() error { continue } - //将玩家积分加入排行榜 - s.addRank(uid, total) + // 将玩家积分加入排行榜 + s.addPersonalRank(uid, total) + // 将玩家积分加入公会排行榜 + s.addSociatyRank(uid, total) s.moduleSociaty.Debug("结算:", log.Field{Key: "uid", Value: uid}) } diff --git a/pb/sociaty_msg.pb.go b/pb/sociaty_msg.pb.go index 59004c1b0..a86f13d97 100644 --- a/pb/sociaty_msg.pb.go +++ b/pb/sociaty_msg.pb.go @@ -2778,10 +2778,14 @@ type SociatyBMainResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Teams map[int32]*ChallengeTeam `protobuf:"bytes,1,rep,name=teams,proto3" json:"teams" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //公会BOSS 队伍 - Ticket int32 `protobuf:"varint,2,opt,name=ticket,proto3" json:"ticket"` // 挑战券数量 - EndTime int64 `protobuf:"varint,3,opt,name=endTime,proto3" json:"endTime"` //赛季结束时间 - SettlementTime int64 `protobuf:"varint,4,opt,name=settlementTime,proto3" json:"settlementTime"` //赛季结算时间 + Teams map[int32]*ChallengeTeam `protobuf:"bytes,1,rep,name=teams,proto3" json:"teams" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` //公会BOSS 队伍 + Ticket int32 `protobuf:"varint,2,opt,name=ticket,proto3" json:"ticket"` // 挑战券数量 + EndTime int64 `protobuf:"varint,3,opt,name=endTime,proto3" json:"endTime"` //赛季结束时间 + SettlementTime int64 `protobuf:"varint,4,opt,name=settlementTime,proto3" json:"settlementTime"` //赛季结算时间 + Total int64 `protobuf:"varint,5,opt,name=total,proto3" json:"total"` //总积分 + HighIntegrals []int64 `protobuf:"varint,6,rep,packed,name=highIntegrals,proto3" json:"highIntegrals"` //最高的积分 + PersonalRanking int64 `protobuf:"varint,7,opt,name=personalRanking,proto3" json:"personalRanking"` //个人排名 + SociatyRanking int64 `protobuf:"varint,8,opt,name=sociatyRanking,proto3" json:"sociatyRanking"` //公会排名 } func (x *SociatyBMainResp) Reset() { @@ -2844,6 +2848,34 @@ func (x *SociatyBMainResp) GetSettlementTime() int64 { return 0 } +func (x *SociatyBMainResp) GetTotal() int64 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *SociatyBMainResp) GetHighIntegrals() []int64 { + if x != nil { + return x.HighIntegrals + } + return nil +} + +func (x *SociatyBMainResp) GetPersonalRanking() int64 { + if x != nil { + return x.PersonalRanking + } + return 0 +} + +func (x *SociatyBMainResp) GetSociatyRanking() int64 { + if x != nil { + return x.SociatyRanking + } + return 0 +} + // 公会BOSS 布阵 type SociatyBFormationReq struct { state protoimpl.MessageState @@ -3855,7 +3887,7 @@ var file_sociaty_sociaty_msg_proto_rawDesc = []byte{ 0x03, 0x75, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x4d, 0x61, - 0x69, 0x6e, 0x52, 0x65, 0x71, 0x22, 0xea, 0x01, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, + 0x69, 0x6e, 0x52, 0x65, 0x71, 0x22, 0xf8, 0x02, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x4d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x32, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x4d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x54, 0x65, 0x61, @@ -3865,98 +3897,107 @@ var file_sociaty_sociaty_msg_proto_rawDesc = []byte{ 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x73, 0x65, 0x74, 0x74, 0x6c, 0x65, - 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, - 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x22, 0xb6, 0x01, 0x0a, 0x14, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, - 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x73, + 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, + 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x24, + 0x0a, 0x0d, 0x68, 0x69, 0x67, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x73, 0x18, + 0x06, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0d, 0x68, 0x69, 0x67, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x67, + 0x72, 0x61, 0x6c, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, + 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x70, + 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x12, 0x26, + 0x0a, 0x0e, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, + 0x61, 0x6e, 0x6b, 0x69, 0x6e, 0x67, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, + 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0xb6, 0x01, 0x0a, 0x14, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, + 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, + 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x2e, 0x54, 0x65, + 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x1a, + 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, + 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x47, 0x0a, 0x15, 0x53, 0x6f, 0x63, + 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, + 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, + 0x69, 0x64, 0x22, 0x39, 0x0a, 0x19, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, 0x68, + 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x12, + 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x22, 0x4c, 0x0a, + 0x1a, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, + 0x67, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x05, 0x74, 0x65, 0x61, - 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x2e, - 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, - 0x73, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x47, 0x0a, 0x15, 0x53, - 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 0x64, 0x0a, 0x1a, 0x53, + 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, + 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x70, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x54, + 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, + 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x74, + 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, + 0x74, 0x22, 0x39, 0x0a, 0x1b, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, 0x68, 0x61, + 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, + 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, 0x2e, 0x0a, 0x18, + 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x61, 0x74, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x61, 0x74, 0x65, 0x22, 0xa2, 0x01, 0x0a, + 0x19, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3b, 0x0a, 0x05, 0x74, 0x65, + 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x53, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x63, + 0x6f, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, 0x6d, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, + 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x4a, 0x0a, 0x12, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x65, 0x63, + 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x4b, 0x0a, + 0x13, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, - 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x69, 0x64, 0x22, 0x39, 0x0a, 0x19, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, - 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x22, - 0x4c, 0x0a, 0x1a, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, 0x68, 0x61, 0x6c, 0x6c, - 0x65, 0x6e, 0x67, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, - 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x22, 0x64, 0x0a, - 0x1a, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, - 0x67, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x70, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x50, 0x6c, 0x61, - 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x70, 0x74, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x06, - 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x42, - 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x06, 0x72, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x22, 0x39, 0x0a, 0x1b, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x43, - 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, - 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, 0x2e, - 0x0a, 0x18, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x61, - 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x61, 0x74, 0x65, 0x22, 0xa2, - 0x01, 0x0a, 0x19, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3b, 0x0a, 0x05, - 0x74, 0x65, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x53, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x63, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x05, 0x74, 0x65, 0x61, 0x6d, 0x73, 0x1a, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x61, - 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x43, 0x68, 0x61, 0x6c, 0x6c, - 0x65, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x22, 0x4a, 0x0a, 0x12, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, - 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, - 0x4b, 0x0a, 0x13, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, - 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x0f, - 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x12, - 0x1a, 0x0a, 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x22, 0xa1, 0x01, 0x0a, 0x0f, - 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x65, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x68, 0x65, 0x61, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x6f, 0x63, 0x69, 0x61, - 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x6f, - 0x63, 0x69, 0x61, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x61, 0x6e, - 0x6b, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x61, 0x6e, 0x6b, - 0x69, 0x6e, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, - 0x38, 0x0a, 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x24, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x10, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x49, - 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x22, 0x46, 0x0a, 0x0d, 0x53, 0x6f, 0x63, - 0x69, 0x61, 0x74, 0x79, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, 0x12, 0x1d, 0x0a, 0x03, 0x61, 0x74, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, - 0x73, 0x65, 0x74, 0x73, 0x52, 0x03, 0x61, 0x74, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x79, - 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, - 0x6d, 0x22, 0x22, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x75, 0x79, 0x52, - 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x75, 0x69, 0x64, 0x2a, 0x42, 0x0a, 0x11, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, - 0x4c, 0x69, 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, - 0x4c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x4e, 0x4f, 0x41, 0x50, 0x50, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x41, - 0x50, 0x50, 0x4c, 0x59, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x49, 0x64, 0x22, 0x2d, 0x0a, 0x0f, 0x53, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, + 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x08, 0x72, 0x61, 0x6e, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x22, 0xa1, 0x01, 0x0a, 0x0f, 0x53, 0x6f, + 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x65, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x68, 0x65, 0x61, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x02, 0x6c, 0x76, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x6f, 0x63, 0x69, + 0x61, 0x74, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x61, 0x6e, 0x6b, 0x69, + 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x61, 0x6e, 0x6b, 0x69, 0x6e, + 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x22, 0x38, 0x0a, + 0x10, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x52, 0x61, 0x6e, 0x6b, 0x52, 0x65, 0x73, + 0x70, 0x12, 0x24, 0x0a, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x52, 0x61, 0x6e, 0x6b, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x04, 0x72, 0x61, 0x6e, 0x6b, 0x22, 0x46, 0x0a, 0x0d, 0x53, 0x6f, 0x63, 0x69, 0x61, + 0x74, 0x79, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, 0x12, 0x1d, 0x0a, 0x03, 0x61, 0x74, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, + 0x74, 0x73, 0x52, 0x03, 0x61, 0x74, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, + 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x22, + 0x22, 0x0a, 0x0e, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x42, 0x75, 0x79, 0x52, 0x65, 0x73, + 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x75, 0x69, 0x64, 0x2a, 0x42, 0x0a, 0x11, 0x53, 0x6f, 0x63, 0x69, 0x61, 0x74, 0x79, 0x4c, 0x69, + 0x73, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4c, 0x4c, 0x10, + 0x00, 0x12, 0x09, 0x0a, 0x05, 0x43, 0x4f, 0x4e, 0x44, 0x49, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, + 0x4e, 0x4f, 0x41, 0x50, 0x50, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x41, 0x50, 0x50, + 0x4c, 0x59, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/sys/db/init_test.go b/sys/db/init_test.go index 5882205fe..154a946e9 100644 --- a/sys/db/init_test.go +++ b/sys/db/init_test.go @@ -6,12 +6,14 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/mgo" - "go_dreamfactory/lego/sys/redis" + r "go_dreamfactory/lego/sys/redis" "go_dreamfactory/pb" "math/rand" "sync" "testing" + "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" @@ -86,11 +88,11 @@ func Test_2D(t *testing.T) { //测试api_getlist func Test_Json_RTask(t *testing.T) { - if sys, err := redis.NewSys( - redis.SetRedisType(redis.Redis_Single), - redis.SetRedis_Single_Addr("10.0.0.9:10011"), - redis.SetRedis_Single_Password("li13451234"), - redis.SetRedis_Single_DB(3), + if sys, err := r.NewSys( + r.SetRedisType(r.Redis_Single), + r.SetRedis_Single_Addr("10.0.0.9:10011"), + r.SetRedis_Single_Password("li13451234"), + r.SetRedis_Single_DB(3), ); err != nil { fmt.Printf("err:%v", err) return @@ -127,24 +129,29 @@ func Test_Json_RTask(t *testing.T) { } func TestRa(t *testing.T) { - if sys, err := redis.NewSys( - redis.SetRedisType(redis.Redis_Single), - redis.SetRedis_Single_Addr("10.0.0.9:10011"), - redis.SetRedis_Single_Password("li13451234"), - redis.SetRedis_Single_DB(15), + if sys, err := r.NewSys( + r.SetRedisType(r.Redis_Single), + r.SetRedis_Single_Addr("10.0.0.9:10011"), + r.SetRedis_Single_Password("li13451234"), + r.SetRedis_Single_DB(15), ); err != nil { fmt.Printf("err:%v", err) return } else { - s, err2 := sys.ZRevRange("sociatybsoss", 0, 10).Result() + s, err2 := sys.ZRevRange("sociatyrank", 0, 10).Result() if err2 != nil { t.Fatal(err2) } + m := &redis.Z{Score: float64(1), Member: "dd"} + sys.ZAdd("sociatyrank", m) + + sys.ZIncrBy("sociatyrank", 10, "a100aa") + sys.ZIncrBy("sociatyrank", 10, "a100ab") for _, v := range s { fmt.Println(v) - score, _ := sys.ZScore("sociatybsoss", v) - ranking, _ := sys.ZRevRank("sociatybsoss", v) + score, _ := sys.ZScore("sociatyrank", v) + ranking, _ := sys.ZRevRank("sociatyrank", v) fmt.Printf("%d %v - %d \n", (ranking + 1), v, int64(score)) }