Commit 5c6bb579 by xuzhenhao

修改了获取用户个人信息的算法

1 parent b7d200a2
Showing with 29 additions and 23 deletions
......@@ -291,38 +291,48 @@ func IceGameTopRedisGetSingleUserRankInfo(uid string, gtid string, gid string, t
}
// 排序
var strList []string
var sorterr error
var rankIndex int64
if sorceorder == "0" {
strList, sorterr = RedisSort(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, 0, -1)
} else if sorceorder == "1" {
strList, sorterr = RedisReverseSort(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, 0, -1)
rank, err := GetSingleUserRank(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, "ice_gametop:uid:"+uid+":gtid:"+gtid+":gid:"+gid+":toptype:"+toptype+":mykey")
if err != nil {
log.Println(err, " errno:", rank.(string))
return
}
if sorterr != nil {
log.Println("RedisSort err[%v]", sorterr)
count, err := RedisZCount(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, "-inf", "+inf")
if err != nil {
log.Println(err)
return
} else if len(strList) == 0 {
log.Println("rank has no data")
}
rankIndex = count.(int64) - rank.(int64) - 1
} else if sorceorder == "1" {
rank, err := GetSingleUserRank(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, "ice_gametop:uid:"+uid+":gtid:"+gtid+":gid:"+gid+":toptype:"+toptype+":mykey")
if err != nil {
log.Println(err, " errno:", rank.(string))
return
}
rankIndex = rank.(int64) + 1
}
score, err := RedisZScore(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, "ice_gametop:uid:"+uid+":gtid:"+gtid+":gid:"+gid+":toptype:"+toptype+":mykey")
if err != nil {
resIndex = "105202"
return nil, resIndex, err
}
if score == nil {
err = errors.New("用户未提交分数")
return nil, "105201", err
}
scoreString := string(score.([]uint8))
igt = new(IGT)
index := 1
var resultstr string
var valuecount = 2
_, err = RedisDBSelect(redisConn, 4)
if err != nil {
log.Printf("select db err:", err)
}
for i := 0; i < len(strList); i += 2 {
startIndex := strings.Index(strList[i], "uid:") + 4
endIndex := strings.Index(strList[i], ":gtid")
currUID := common.Substr2(strList[i], startIndex, endIndex)
if currUID == uid {
igt.UID = uid
igt.RankIndex = index
igt.MyKey = strList[i+1]
igt.RankIndex = int(rankIndex)
igt.MyKey = scoreString
//查询储存昵称以及头像url的redis
var err error
resultstr, err = RedisGetKV(redisConn, "GUID:"+igt.UID)
if err != nil {
log.Println("get redis err:", err)
......@@ -345,10 +355,6 @@ func IceGameTopRedisGetSingleUserRankInfo(uid string, gtid string, gid string, t
igt.NickName = result[0] //第一个为昵称
igt.HeadPortraitURL = result[1] //第二个为头像url
}
}
index++
}
_, err = RedisDBSelect(redisConn, 2)
if err != nil {
log.Printf("select db err:", err)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!