Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-userCenter
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-userCenter
Compare Revisions
master...feature/fruit-up
Source
feature/fruit-up
Select Git revision
...
Target
master
Select Git revision
Compare
Commits (1)
feat:等级中处理分区用户
· ef0417d6
hujiebin
authored
Oct 30, 2023
ef0417d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
5 deletions
+15
-5
main.go
main.go
+9
-2
userManager.go
manager/userManager.go
+5
-3
userCenter.proto
protocol/userCenter.proto
+1
-0
No files found.
main.go
View file @
ef0417d6
...
...
@@ -309,11 +309,18 @@ func (s *server) Levelcast(ctx context.Context, in *userCenter.LevelMessage) (*u
uids
=
append
(
uids
,
uid
)
}
}
// 处理
分区
用户
levelUserIds
:=
userManager
.
GetLevelUsers
(
uids
,
in
.
Level
)
// 处理
等级
用户
levelUserIds
,
userIds
:=
userManager
.
GetLevelUsers
(
uids
,
in
.
Level
)
if
len
(
levelUserIds
)
<=
0
{
return
&
userCenter
.
LevelMessageRsp
{
FailedUids
:
failed
},
nil
}
if
in
.
Area
>
0
{
// 处理分区用户
levelUserIds
=
userManager
.
GetAreaUsers
(
userIds
,
int8
(
in
.
Area
))
if
len
(
levelUserIds
)
<=
0
{
return
&
userCenter
.
LevelMessageRsp
{
FailedUids
:
failed
},
nil
}
}
m
:=
make
(
map
[
string
][]
uint64
,
0
)
for
uid
:=
range
levelUserIds
{
ok
:=
false
...
...
manager/userManager.go
View file @
ef0417d6
...
...
@@ -138,8 +138,9 @@ func (m *UserManager) GetAreaUsers(userIds []uint64, area int8) map[uint64]UserT
// 获取财富等级大于某等级的用户
// 开区间
func
(
m
*
UserManager
)
GetLevelUsers
(
userIds
[]
uint64
,
wealthLevel
int32
)
map
[
uint64
]
UserTinyArea
{
func
(
m
*
UserManager
)
GetLevelUsers
(
userIds
[]
uint64
,
wealthLevel
int32
)
(
map
[
uint64
]
UserTinyArea
,
[]
uint64
)
{
res
:=
make
(
map
[
uint64
]
UserTinyArea
)
var
resIds
[]
uint64
// 从db中读,暂时不缓存(几千个)
var
users
[]
UserTinyArea
if
err
:=
m
.
MysqlDB
.
Table
(
"user"
)
.
Joins
(
"JOIN match_wealth_user_score ON match_wealth_user_score.user_id = user.id"
)
.
...
...
@@ -148,7 +149,7 @@ func (m *UserManager) GetLevelUsers(userIds []uint64, wealthLevel int32) map[uin
Where
(
"match_wealth_user_score.grade > ?"
,
wealthLevel
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"GetLevelUsers fail:%v"
,
err
)
return
res
return
res
,
resIds
}
for
_
,
u
:=
range
users
{
a
:=
m
.
GetArea
(
u
.
Country
)
...
...
@@ -161,6 +162,7 @@ func (m *UserManager) GetLevelUsers(userIds []uint64, wealthLevel int32) map[uin
Area
:
a
,
Avatar
:
u
.
Avatar
,
}
resIds
=
append
(
resIds
,
u
.
ID
)
}
return
res
return
res
,
resIds
}
protocol/userCenter.proto
View file @
ef0417d6
...
...
@@ -136,6 +136,7 @@ message LevelMessage {
int32
level
=
1
;
uint32
msgType
=
2
;
bytes
payLoad
=
3
;
int32
area
=
4
;
}
message
LevelMessageRsp
{
...
...