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
46d29706
Commit
46d29706
authored
Mar 10, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发一个事件
parent
5feda91b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
33 deletions
+78
-33
msg.go
_const/enum/msg_e/msg.go
+19
-19
groupPowerUpgrade.go
domain/event/group_power_ev/groupPowerUpgrade.go
+28
-0
group_grade.go
domain/model/groupPower_m/group_grade.go
+5
-12
event_init.go
domain/service/event_s/event_init.go
+26
-2
No files found.
_const/enum/msg_e/msg.go
View file @
46d29706
...
@@ -131,8 +131,8 @@ const (
...
@@ -131,8 +131,8 @@ const (
NewUserRegisterPush2
=
45
// 邀请朋友来Hilo,最高获得100,000钻石奖励!
NewUserRegisterPush2
=
45
// 邀请朋友来Hilo,最高获得100,000钻石奖励!
NewUserRegisterPush3
=
46
// 举办首个活动,领取10,000钻石和35%奖杯奖励!
NewUserRegisterPush3
=
46
// 举办首个活动,领取10,000钻石和35%奖杯奖励!
ActFruitPutRankAward
=
47
// 水果机投入排行榜提醒领奖
ActFruitPutRankAward
=
47
// 水果机投入排行榜提醒领奖
ActGroupPowerUpgrade
=
48
// 家族升级
GroupPowerUpgrade
=
48
// 家族升级
ActGroupPowerExpireNotice
=
49
// 家族等级即将过期(每月20日)
GroupPowerExpireNotice
=
49
// 家族等级即将过期(每月20日)
)
)
type
MsgSysUserType
=
mysql
.
Type
type
MsgSysUserType
=
mysql
.
Type
...
...
domain/event/group_power_ev/groupPowerUpgrade.go
0 → 100644
View file @
46d29706
package
group_power_ev
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
)
//注册监听
var
groupPowerUpgradeListen
=
new
(
domain
.
EventBase
)
type
GroupPowerUpgradeEvent
struct
{
GroupPowerId
mysql
.
ID
}
//添加领域事件,在每个领域模型中init中添加,因为这是静态业务,非动态的。
func
AddGroupPowerUpgradeSync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventSync
(
groupPowerUpgradeListen
,
callback
)
}
//加入到异步操作中
func
AddGroupPowerUpgradeAsync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventAsync
(
groupPowerUpgradeListen
,
callback
)
}
//领域事件发布
func
PublishGroupPowerUpgrade
(
model
*
domain
.
Model
,
event
interface
{})
error
{
return
domain
.
PublishEvent
(
groupPowerUpgradeListen
,
model
,
event
)
}
domain/model/groupPower_m/group_grade.go
View file @
46d29706
...
@@ -8,8 +8,7 @@ import (
...
@@ -8,8 +8,7 @@ import (
"gorm.io/gorm"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"gorm.io/gorm/clause"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/_const/enum/msg_e"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/msg_m"
"time"
"time"
)
)
...
@@ -125,16 +124,10 @@ func IncrGroupPowerExp(txModel *domain.Model, groupPowerId mysql.ID, exp mysql.N
...
@@ -125,16 +124,10 @@ func IncrGroupPowerExp(txModel *domain.Model, groupPowerId mysql.ID, exp mysql.N
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"group_power_id = ?"
,
latestGrade
.
GroupPowerId
)
.
UpdateColumns
(
updateAttrs
)
.
Error
;
err
!=
nil
{
if
err
=
txModel
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"group_power_id = ?"
,
latestGrade
.
GroupPowerId
)
.
UpdateColumns
(
updateAttrs
)
.
Error
;
err
!=
nil
{
return
err
return
err
}
}
// 升级发消息 // todo 看看需要移出去外面,或者发一个事件?
// 升级发事件
record1
:=
msg_m
.
NewUserRecord
(
txModel
,
4522
,
msg_e
.
ActGroupPowerUpgrade
,
""
,
0
,
""
,
""
,
""
,
""
,
""
)
_
=
group_power_ev
.
PublishGroupPowerUpgrade
(
txModel
,
&
group_power_ev
.
GroupPowerUpgradeEvent
{
_
=
record1
.
Persistent
()
GroupPowerId
:
groupPowerId
,
return
nil
})
// 不加离线推送
//user, err := user_m.GetUser(model, event.UserId)
//if err != nil {
// return err
//}
//return SendEmasMsgAssistant(model, user.ExternalId, user.DeviceType)
}
}
break
break
}
}
...
...
domain/service/event_s/event_init.go
View file @
46d29706
...
@@ -106,7 +106,7 @@ func GroupSupportEvents() {
...
@@ -106,7 +106,7 @@ func GroupSupportEvents() {
}
}
func
GroupPowerEvents
()
{
func
GroupPowerEvents
()
{
//加入势力
//
加入势力
group_power_ev
.
AddGroupPowerJoinAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
group_power_ev
.
AddGroupPowerJoinAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
event
,
ok
:=
e
.
(
*
group_power_ev
.
GroupPowerJoinEvent
)
event
,
ok
:=
e
.
(
*
group_power_ev
.
GroupPowerJoinEvent
)
if
!
ok
{
if
!
ok
{
...
@@ -134,7 +134,7 @@ func GroupPowerEvents() {
...
@@ -134,7 +134,7 @@ func GroupPowerEvents() {
msg_m
.
SendEmasMsgAssistant
(
model
,
mgrUser
.
ExternalId
,
mgrUser
.
DeviceType
)
msg_m
.
SendEmasMsgAssistant
(
model
,
mgrUser
.
ExternalId
,
mgrUser
.
DeviceType
)
return
nil
return
nil
})
})
//离开势力
//
离开势力
group_power_ev
.
AddGroupPowerLeaveAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
group_power_ev
.
AddGroupPowerLeaveAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
event
,
ok
:=
e
.
(
*
group_power_ev
.
GroupPowerLeaveEvent
)
event
,
ok
:=
e
.
(
*
group_power_ev
.
GroupPowerLeaveEvent
)
if
!
ok
{
if
!
ok
{
...
@@ -162,6 +162,30 @@ func GroupPowerEvents() {
...
@@ -162,6 +162,30 @@ func GroupPowerEvents() {
msg_m
.
SendEmasMsgAssistant
(
model
,
mgrUser
.
ExternalId
,
mgrUser
.
DeviceType
)
msg_m
.
SendEmasMsgAssistant
(
model
,
mgrUser
.
ExternalId
,
mgrUser
.
DeviceType
)
return
nil
return
nil
})
})
// 势力升级
group_power_ev
.
AddGroupPowerUpgradeAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
event
,
ok
:=
e
.
(
*
group_power_ev
.
GroupPowerUpgradeEvent
)
if
!
ok
{
model
.
Log
.
Errorf
(
"AddGroupPowerUpgradeAsync event type err"
)
return
nil
}
model
.
Log
.
Infof
(
"msg AddGroupPowerUpgradeAsync GroupPowerId:%v"
,
event
.
GroupPowerId
)
//获取势力主
mgrUserId
,
err
:=
groupPower_m
.
GetGroupPowerMgr
(
model
,
event
.
GroupPowerId
)
if
err
!=
nil
{
return
err
}
mgrUser
,
err
:=
user_m
.
GetUser
(
model
,
mgrUserId
)
if
err
!=
nil
{
return
err
}
if
err
:=
msg_m
.
NewUserRecord
(
model
,
mgrUserId
,
msg_e
.
GroupPowerUpgrade
,
""
,
0
,
""
,
""
,
""
,
""
,
""
)
.
Persistent
();
err
!=
nil
{
model
.
Log
.
Errorf
(
"msg AddGroupPowerLeaveAsync NewUserRecord err:%v"
,
err
)
return
nil
}
msg_m
.
SendEmasMsgAssistant
(
model
,
mgrUser
.
ExternalId
,
mgrUser
.
DeviceType
)
return
nil
})
}
}
func
GroupEvents
()
{
func
GroupEvents
()
{
...
...
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