2024-01-22 11:35:28 +08:00
|
|
|
package init
|
|
|
|
|
|
|
|
|
|
import (
|
2025-04-15 21:42:31 +08:00
|
|
|
"context"
|
2024-01-22 11:35:28 +08:00
|
|
|
"mayfly-go/initialize"
|
2025-04-15 21:42:31 +08:00
|
|
|
"mayfly-go/internal/event"
|
2024-12-16 23:29:18 +08:00
|
|
|
"mayfly-go/internal/msg/api"
|
2024-01-22 11:35:28 +08:00
|
|
|
"mayfly-go/internal/msg/application"
|
2025-04-15 21:42:31 +08:00
|
|
|
"mayfly-go/internal/msg/application/dto"
|
2024-03-02 19:08:19 +08:00
|
|
|
"mayfly-go/internal/msg/infrastructure/persistence"
|
2025-04-15 21:42:31 +08:00
|
|
|
"mayfly-go/pkg/eventbus"
|
|
|
|
|
"mayfly-go/pkg/global"
|
|
|
|
|
"mayfly-go/pkg/ioc"
|
2024-01-22 11:35:28 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func init() {
|
2024-03-02 19:08:19 +08:00
|
|
|
initialize.AddInitIocFunc(func() {
|
|
|
|
|
persistence.InitIoc()
|
|
|
|
|
application.InitIoc()
|
2024-12-16 23:29:18 +08:00
|
|
|
api.InitIoc()
|
2024-03-02 19:08:19 +08:00
|
|
|
})
|
2025-04-15 21:42:31 +08:00
|
|
|
|
|
|
|
|
initialize.AddInitFunc(Init)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Init() {
|
|
|
|
|
msgTmplBizApp := ioc.Get[application.MsgTmplBiz]("MsgTmplBizApp")
|
|
|
|
|
|
2025-05-20 21:04:47 +08:00
|
|
|
global.EventBus.SubscribeAsync(event.EventTopicBizMsgTmplSend, "BizMsgTmplSend", func(ctx context.Context, event *eventbus.Event[any]) error {
|
2025-04-15 21:42:31 +08:00
|
|
|
return msgTmplBizApp.Send(ctx, event.Val.(dto.BizMsgTmplSend))
|
|
|
|
|
}, false)
|
2024-01-22 11:35:28 +08:00
|
|
|
}
|