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
Commits
4a3e1b79
Commit
4a3e1b79
authored
Oct 30, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:等级中处理分区用户
parent
1e30a039
Changes
3
Show 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 @
4a3e1b79
...
@@ -309,11 +309,18 @@ func (s *server) Levelcast(ctx context.Context, in *userCenter.LevelMessage) (*u
...
@@ -309,11 +309,18 @@ func (s *server) Levelcast(ctx context.Context, in *userCenter.LevelMessage) (*u
uids
=
append
(
uids
,
uid
)
uids
=
append
(
uids
,
uid
)
}
}
}
}
// 处理等级用户
levelUserIds
,
userIds
:=
userManager
.
GetLevelUsers
(
uids
,
in
.
Level
)
if
len
(
levelUserIds
)
<=
0
{
return
&
userCenter
.
LevelMessageRsp
{
FailedUids
:
failed
},
nil
}
if
in
.
Area
>
0
{
// 处理分区用户
// 处理分区用户
levelUserIds
:=
userManager
.
GetLevelUsers
(
uids
,
in
.
Level
)
levelUserIds
=
userManager
.
GetAreaUsers
(
userIds
,
int8
(
in
.
Area
)
)
if
len
(
levelUserIds
)
<=
0
{
if
len
(
levelUserIds
)
<=
0
{
return
&
userCenter
.
LevelMessageRsp
{
FailedUids
:
failed
},
nil
return
&
userCenter
.
LevelMessageRsp
{
FailedUids
:
failed
},
nil
}
}
}
m
:=
make
(
map
[
string
][]
uint64
,
0
)
m
:=
make
(
map
[
string
][]
uint64
,
0
)
for
uid
:=
range
levelUserIds
{
for
uid
:=
range
levelUserIds
{
ok
:=
false
ok
:=
false
...
...
manager/userManager.go
View file @
4a3e1b79
...
@@ -138,8 +138,9 @@ func (m *UserManager) GetAreaUsers(userIds []uint64, area int8) map[uint64]UserT
...
@@ -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
)
res
:=
make
(
map
[
uint64
]
UserTinyArea
)
var
resIds
[]
uint64
// 从db中读,暂时不缓存(几千个)
// 从db中读,暂时不缓存(几千个)
var
users
[]
UserTinyArea
var
users
[]
UserTinyArea
if
err
:=
m
.
MysqlDB
.
Table
(
"user"
)
.
Joins
(
"JOIN match_wealth_user_score ON match_wealth_user_score.user_id = user.id"
)
.
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
...
@@ -148,7 +149,7 @@ func (m *UserManager) GetLevelUsers(userIds []uint64, wealthLevel int32) map[uin
Where
(
"match_wealth_user_score.grade > ?"
,
wealthLevel
)
.
Where
(
"match_wealth_user_score.grade > ?"
,
wealthLevel
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
Find
(
&
users
)
.
Error
;
err
!=
nil
{
mylogrus
.
MyLog
.
Errorf
(
"GetLevelUsers fail:%v"
,
err
)
mylogrus
.
MyLog
.
Errorf
(
"GetLevelUsers fail:%v"
,
err
)
return
res
return
res
,
resIds
}
}
for
_
,
u
:=
range
users
{
for
_
,
u
:=
range
users
{
a
:=
m
.
GetArea
(
u
.
Country
)
a
:=
m
.
GetArea
(
u
.
Country
)
...
@@ -161,6 +162,7 @@ func (m *UserManager) GetLevelUsers(userIds []uint64, wealthLevel int32) map[uin
...
@@ -161,6 +162,7 @@ func (m *UserManager) GetLevelUsers(userIds []uint64, wealthLevel int32) map[uin
Area
:
a
,
Area
:
a
,
Avatar
:
u
.
Avatar
,
Avatar
:
u
.
Avatar
,
}
}
resIds
=
append
(
resIds
,
u
.
ID
)
}
}
return
res
return
res
,
resIds
}
}
protocol/userCenter.proto
View file @
4a3e1b79
...
@@ -136,6 +136,7 @@ message LevelMessage {
...
@@ -136,6 +136,7 @@ message LevelMessage {
int32
level
=
1
;
int32
level
=
1
;
uint32
msgType
=
2
;
uint32
msgType
=
2
;
bytes
payLoad
=
3
;
bytes
payLoad
=
3
;
int32
area
=
4
;
}
}
message
LevelMessageRsp
{
message
LevelMessageRsp
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment