Commit 00801f79 by xuzhenhao

修复了返回index存在0的问题,增加了返回列表中用户所在的位置

1 parent 79d3bd62
...@@ -173,10 +173,11 @@ func SingleRangeRank(c *gin.Context) { ...@@ -173,10 +173,11 @@ func SingleRangeRank(c *gin.Context) {
nextrank := c.Query("nextrank") nextrank := c.Query("nextrank")
log.Printf("SingleRank uid[%s] gtid[%s] gid[%s] toptype[%s] prerank[%s] nextrank[%s]\n", uid, gtid, gid, toptype, prerank, nextrank) log.Printf("SingleRank uid[%s] gtid[%s] gid[%s] toptype[%s] prerank[%s] nextrank[%s]\n", uid, gtid, gid, toptype, prerank, nextrank)
igt := sdkredis.IceGameTopRedisGetSingleUserRangeRankInfo(uid, gtid, gid, toptype, prerank, nextrank) igt, resIndex := sdkredis.IceGameTopRedisGetSingleUserRangeRankInfo(uid, gtid, gid, toptype, prerank, nextrank)
fmt.Println(igt) fmt.Println(igt)
infoList := make(map[string]interface{}, 0) infoList := make(map[string]interface{}, 0)
infoList["info_list"] = igt infoList["info_list"] = igt
infoList["user_index"] = resIndex
msg := new(Msg) msg := new(Msg)
if igt == nil { if igt == nil {
err := errors.New("gametop name or game name not exist") err := errors.New("gametop name or game name not exist")
......
...@@ -360,11 +360,10 @@ func IceGameTopRedisGetSingleUserRankInfo(uid string, gtid string, gid string, t ...@@ -360,11 +360,10 @@ func IceGameTopRedisGetSingleUserRankInfo(uid string, gtid string, gid string, t
/** /**
* 获取单个用户以及前后用户的排名信息 * 获取单个用户以及前后用户的排名信息
*/ */
func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid string, toptype string, prerank string, nextrank string) (res *[]IGT) { func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid string, toptype string, prerank string, nextrank string) (res *[]IGT, resIndex int) {
// 连接redis // 连接redis
redisConn := RedisClient.GetConn() redisConn := RedisClient.GetConn()
defer RedisClose(redisConn) defer RedisClose(redisConn)
// 获取当前排行榜是正序还是反序/ // 获取当前排行榜是正序还是反序/
var sorceorder string var sorceorder string
...@@ -455,8 +454,11 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -455,8 +454,11 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
} else { } else {
s = i / 2 s = i / 2
} }
if prerankIndex+index-1 == rankIndex {
resIndex = prerankIndex + index
}
igt[s].UID = uid igt[s].UID = uid
igt[s].RankIndex = prerankIndex + index - 1 igt[s].RankIndex = prerankIndex + index
igt[s].MyKey = strList[i+1] igt[s].MyKey = strList[i+1]
//查询储存昵称以及头像url的redis //查询储存昵称以及头像url的redis
var err error var err error
...@@ -489,7 +491,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -489,7 +491,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
if err != nil { if err != nil {
log.Printf("select db err:", err) log.Printf("select db err:", err)
} }
return &igt return &igt, resIndex
} }
func IceGameTopRedisCreateRank(gtid string, gid string, toptype string, gtname string, sorcetype string, sorcesub string, sorceorder string) error { func IceGameTopRedisCreateRank(gtid string, gid string, toptype string, gtname string, sorcetype string, sorcesub string, sorceorder string) error {
// 连接redis // 连接redis
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!