Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
xuzhenhao
/
rlw-dev
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 5c6bb579
authored
Jan 02, 2018
by
xuzhenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了获取用户个人信息的算法
1 parent
b7d200a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
45 deletions
sdkredis/ice_gametopREDIS.go
sdkredis/ice_gametopREDIS.go
View file @
5c6bb57
...
...
@@ -291,63 +291,69 @@ 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
)
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
}
count
,
err
:=
RedisZCount
(
redisConn
,
"sortset:gtid:"
+
gtid
+
":gid:"
+
gid
+
":toptype:"
+
toptype
,
"-inf"
,
"+inf"
)
if
err
!=
nil
{
log
.
Println
(
err
)
return
}
rankIndex
=
count
.
(
int64
)
-
rank
.
(
int64
)
-
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
}
rankIndex
=
rank
.
(
int64
)
+
1
}
if
sorterr
!=
nil
{
log
.
Println
(
"RedisSort err[%v]"
,
sorterr
)
return
}
else
if
len
(
strList
)
==
0
{
log
.
Println
(
"rank has no data"
)
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
]
//查询储存昵称以及头像url的redis
var
err
error
resultstr
,
err
=
RedisGetKV
(
redisConn
,
"GUID:"
+
igt
.
UID
)
if
err
!=
nil
{
log
.
Println
(
"get redis err:"
,
err
)
}
r
,
err
:=
regexp
.
Compile
(
`\|([^\|])*\|`
)
if
err
!=
nil
{
log
.
Println
(
"err:"
,
err
)
}
// 使用正则匹配需要的值
result
:=
r
.
FindAllString
(
resultstr
,
valuecount
)
//去除用来匹配的特殊字符“|“
if
result
!=
nil
{
for
key
,
value
:=
range
result
{
value
=
value
[
1
:
len
(
value
)
-
1
]
log
.
Println
(
value
)
result
[
key
]
=
value
}
//result 为切片,储存了所有匹配到的特定值
igt
.
NickName
=
result
[
0
]
//第一个为昵称
igt
.
HeadPortraitURL
=
result
[
1
]
//第二个为头像url
}
}
igt
.
UID
=
uid
igt
.
RankIndex
=
int
(
rankIndex
)
igt
.
MyKey
=
scoreString
//查询储存昵称以及头像url的redis
resultstr
,
err
=
RedisGetKV
(
redisConn
,
"GUID:"
+
igt
.
UID
)
if
err
!=
nil
{
log
.
Println
(
"get redis err:"
,
err
)
}
r
,
err
:=
regexp
.
Compile
(
`\|([^\|])*\|`
)
if
err
!=
nil
{
log
.
Println
(
"err:"
,
err
)
}
// 使用正则匹配需要的值
result
:=
r
.
FindAllString
(
resultstr
,
valuecount
)
index
++
//去除用来匹配的特殊字符“|“
if
result
!=
nil
{
for
key
,
value
:=
range
result
{
value
=
value
[
1
:
len
(
value
)
-
1
]
log
.
Println
(
value
)
result
[
key
]
=
value
}
//result 为切片,储存了所有匹配到的特定值
igt
.
NickName
=
result
[
0
]
//第一个为昵称
igt
.
HeadPortraitURL
=
result
[
1
]
//第二个为头像url
}
_
,
err
=
RedisDBSelect
(
redisConn
,
2
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment