Commit a4204365 by xuzhenhao

增加了相应的错误返回

1 parent adc0901c
Showing with 10 additions and 10 deletions
...@@ -378,13 +378,13 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -378,13 +378,13 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
} }
} else { } else {
resIndex = "105207" resIndex = "105207"
return return nil, resIndex, err
} }
// 获取当前用户排名 // 获取当前用户排名
rank, err := RedisZRank(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, "ice_gametop:uid:"+uid+":gtid:"+gtid+":gid:"+gid+":toptype:"+toptype+":mykey") rank, err := RedisZRank(redisConn, "sortset:gtid:"+gtid+":gid:"+gid+":toptype:"+toptype, "ice_gametop:uid:"+uid+":gtid:"+gtid+":gid:"+gid+":toptype:"+toptype+":mykey")
if err != nil { if err != nil {
resIndex = "105202" resIndex = "105202"
return return nil, resIndex, err
} }
if rank == nil { if rank == nil {
err = errors.New("用户未提交分数") err = errors.New("用户未提交分数")
...@@ -402,7 +402,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -402,7 +402,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
prerankIndex, err = strconv.Atoi(prerank) prerankIndex, err = strconv.Atoi(prerank)
if err != nil { if err != nil {
resIndex = "105200" resIndex = "105200"
return return nil, resIndex, err
} }
} }
if nextrank == "" { if nextrank == "" {
...@@ -411,7 +411,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -411,7 +411,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
nextrankIndex, err = strconv.Atoi(nextrank) nextrankIndex, err = strconv.Atoi(nextrank)
if err != nil { if err != nil {
resIndex = "105200" resIndex = "105200"
return return nil, resIndex, err
} }
} }
if rankIndex-prerankIndex < 0 { if rankIndex-prerankIndex < 0 {
...@@ -431,11 +431,11 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -431,11 +431,11 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
if err != nil { if err != nil {
resIndex = "105203" resIndex = "105203"
log.Println("RedisSort err") log.Println("RedisSort err")
return return nil, resIndex, err
} else if len(strList) == 0 { } else if len(strList) == 0 {
err = errors.New("rank has no data") err = errors.New("rank has no data")
resIndex = "105204" resIndex = "105204"
return return nil, resIndex, err
} }
igt := make([]IGT, len(strList)/2) igt := make([]IGT, len(strList)/2)
...@@ -448,7 +448,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -448,7 +448,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
if err != nil { if err != nil {
resIndex = "105205" resIndex = "105205"
log.Printf("select db err") log.Printf("select db err")
return return nil, resIndex, err
} }
for i := 0; i < len(strList); i += 2 { for i := 0; i < len(strList); i += 2 {
startIndex := strings.Index(strList[i], "uid:") + 4 startIndex := strings.Index(strList[i], "uid:") + 4
...@@ -470,12 +470,12 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -470,12 +470,12 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
resultstr, err = RedisGetKV(redisConn, "GUID:"+igt[s].UID) resultstr, err = RedisGetKV(redisConn, "GUID:"+igt[s].UID)
if err != nil { if err != nil {
resIndex = "105206" resIndex = "105206"
return return nil, resIndex, err
} }
r, err := regexp.Compile(`\|([^\|])*\|`) r, err := regexp.Compile(`\|([^\|])*\|`)
if err != nil { if err != nil {
resIndex = "105200" resIndex = "105200"
return return nil, resIndex, err
} }
// 使用正则匹配需要的值 // 使用正则匹配需要的值
result := r.FindAllString(resultstr, valuecount) result := r.FindAllString(resultstr, valuecount)
...@@ -498,7 +498,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri ...@@ -498,7 +498,7 @@ func IceGameTopRedisGetSingleUserRangeRankInfo(uid string, gtid string, gid stri
if err != nil { if err != nil {
resIndex = "105205" resIndex = "105205"
log.Printf("select db err:") log.Printf("select db err:")
return return nil, resIndex, err
} }
return &igt, resIndex, nil return &igt, resIndex, nil
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!