Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
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-group
Commits
6a817fba
Commit
6a817fba
authored
Mar 23, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分批获取所有家族成员
parent
16b757e5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
24 deletions
+42
-24
group_info.go
domain/model/groupPower_m/group_info.go
+13
-8
event_init.go
domain/service/event_s/event_init.go
+28
-15
group_power_test.go
test/group_power_test.go
+1
-1
No files found.
domain/model/groupPower_m/group_info.go
View file @
6a817fba
...
@@ -4,7 +4,6 @@ import (
...
@@ -4,7 +4,6 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/utils"
"git.hilo.cn/hilo-common/utils"
"hilo-group/_const/enum/groupPower_e"
)
)
type
GroupPowerInfo
struct
{
type
GroupPowerInfo
struct
{
...
@@ -59,13 +58,19 @@ func GetGroupPowerUser(model *domain.Model, groupPowerId mysql.ID) ([]*GroupPowe
...
@@ -59,13 +58,19 @@ func GetGroupPowerUser(model *domain.Model, groupPowerId mysql.ID) ([]*GroupPowe
return
m
[
groupPowerId
],
nil
return
m
[
groupPowerId
],
nil
}
}
// 获取所有家族的主
// 分批获取所有家族成员
func
GetAllGroupPowerOwners
(
model
*
domain
.
Model
)
([]
mysql
.
ID
,
error
)
{
func
BatchGetAllGroupPowerUsers
(
model
*
domain
.
Model
,
lastId
mysql
.
ID
,
limit
int
)
([]
mysql
.
ID
,
mysql
.
ID
,
error
)
{
var
res
[]
GroupPowerUser
var
userIds
[]
mysql
.
ID
var
userIds
[]
mysql
.
ID
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerUser
{})
.
Select
(
"user_id"
)
.
var
nextLastId
mysql
.
ID
Where
(
"role = ?"
,
groupPower_e
.
GroupPowerUserRoleMgr
)
.
Find
(
&
userIds
)
.
Error
;
err
!=
nil
{
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerUser
{})
.
model
.
Log
.
Errorf
(
"GetAllGroupPowerOwners fail:%v"
,
err
)
Where
(
"id > ?"
,
lastId
)
.
Order
(
"id asc"
)
.
Limit
(
limit
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
return
userIds
,
err
model
.
Log
.
Errorf
(
"BatchGetAllGroupPowerUsers fail:%v"
,
err
)
return
userIds
,
0
,
err
}
}
return
userIds
,
nil
for
_
,
v
:=
range
res
{
userIds
=
append
(
userIds
,
v
.
UserId
)
nextLastId
=
v
.
ID
}
return
userIds
,
nextLastId
,
nil
}
}
domain/service/event_s/event_init.go
View file @
6a817fba
...
@@ -195,13 +195,19 @@ func GroupPowerEvents() {
...
@@ -195,13 +195,19 @@ func GroupPowerEvents() {
// 势力等级即将过期
// 势力等级即将过期
group_power_ev
.
AddGroupPowerExpireNoticeAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
group_power_ev
.
AddGroupPowerExpireNoticeAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
model
.
Log
.
Infof
(
"msg AddGroupPowerExpireNoticeAsync"
)
start
:=
time
.
Now
()
powerOwners
,
err
:=
groupPower_m
.
GetAllGroupPowerOwners
(
model
)
model
.
Log
.
Infof
(
"msg AddGroupPowerExpireNoticeAsync,start:%v"
,
start
)
lastId
:=
mysql
.
ID
(
0
)
for
{
powerUsers
,
nextLastId
,
err
:=
groupPower_m
.
BatchGetAllGroupPowerUsers
(
model
,
lastId
,
500
)
if
err
!=
nil
{
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"AddGroupPowerExpireNoticeAsync fail:%v"
,
err
)
model
.
Log
.
Errorf
(
"AddGroupPowerExpireNoticeAsync fail:%v"
,
err
)
return
err
return
err
}
}
userMaps
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
powerOwners
)
if
len
(
powerUsers
)
<=
0
{
break
}
userMaps
,
err
:=
user_m
.
GetUserMapByIds
(
model
,
powerUsers
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -210,8 +216,15 @@ func GroupPowerEvents() {
...
@@ -210,8 +216,15 @@ func GroupPowerEvents() {
model
.
Log
.
Errorf
(
"msg AddGroupPowerExpireNoticeAsync NewUserRecord err:%v"
,
err
)
model
.
Log
.
Errorf
(
"msg AddGroupPowerExpireNoticeAsync NewUserRecord err:%v"
,
err
)
return
nil
return
nil
}
}
msg_m
.
SendEmasMsgAssistant
(
model
,
u
.
ExternalId
,
u
.
DeviceType
)
_
=
msg_m
.
SendEmasMsgAssistant
(
model
,
u
.
ExternalId
,
u
.
DeviceType
)
}
if
nextLastId
<=
0
{
break
}
lastId
=
nextLastId
time
.
Sleep
(
time
.
Second
)
// 停顿一秒
}
}
model
.
Log
.
Infof
(
"msg AddGroupPowerExpireNoticeAsync,end:%v"
,
time
.
Now
()
.
Sub
(
start
)
.
Seconds
())
return
nil
return
nil
})
})
}
}
...
...
test/group_power_test.go
View file @
6a817fba
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
)
)
func
TestGetAllGroupPowerOwner
(
t
*
testing
.
T
)
{
func
TestGetAllGroupPowerOwner
(
t
*
testing
.
T
)
{
owners
,
err
:=
groupPower_m
.
GetAllGroupPowerOwn
ers
(
domain
.
CreateModelNil
())
owners
,
err
:=
groupPower_m
.
BatchGetAllGroupPowerUs
ers
(
domain
.
CreateModelNil
())
println
(
owners
,
err
)
println
(
owners
,
err
)
}
}
...
...
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