mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-29 04:20:25 +08:00
refactor: 消息模块重构,infra包路径简写等
This commit is contained in:
@@ -3,11 +3,12 @@ package init
|
||||
import (
|
||||
"context"
|
||||
"mayfly-go/initialize"
|
||||
"mayfly-go/internal/event"
|
||||
"mayfly-go/internal/msg/api"
|
||||
"mayfly-go/internal/msg/application"
|
||||
"mayfly-go/internal/msg/application/dto"
|
||||
"mayfly-go/internal/msg/infrastructure/persistence"
|
||||
"mayfly-go/internal/msg/infra/persistence"
|
||||
"mayfly-go/internal/msg/msgx"
|
||||
"mayfly-go/internal/pkg/event"
|
||||
"mayfly-go/pkg/eventbus"
|
||||
"mayfly-go/pkg/global"
|
||||
"mayfly-go/pkg/ioc"
|
||||
@@ -24,9 +25,24 @@ func init() {
|
||||
}
|
||||
|
||||
func Init() {
|
||||
// 注册站内消息发送器
|
||||
msgx.RegisterMsgSender(msgx.ChannelTypeSiteMsg, application.GetMsgApp())
|
||||
|
||||
msgTmplBizApp := ioc.Get[application.MsgTmplBiz]("MsgTmplBizApp")
|
||||
|
||||
global.EventBus.SubscribeAsync(event.EventTopicBizMsgTmplSend, "BizMsgTmplSend", func(ctx context.Context, event *eventbus.Event[any]) error {
|
||||
return msgTmplBizApp.Send(ctx, event.Val.(dto.BizMsgTmplSend))
|
||||
}, false)
|
||||
|
||||
msgTmplApp := ioc.Get[application.MsgTmpl]("MsgTmplApp")
|
||||
|
||||
global.EventBus.SubscribeAsync(event.EventTopicMsgTmplSend, "MsgTmplSend", func(ctx context.Context, event *eventbus.Event[any]) error {
|
||||
eventVal := event.Val.(*dto.MsgTmplSendEvent)
|
||||
return msgTmplApp.SendMsg(ctx, &dto.MsgTmplSend{
|
||||
Tmpl: eventVal.TmplChannel.Tmpl,
|
||||
Channels: eventVal.TmplChannel.Channels,
|
||||
Params: eventVal.Params,
|
||||
ReceiverIds: eventVal.ReceiverIds,
|
||||
})
|
||||
}, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user