发送通知时写入数据库
This commit is contained in:
@@ -90,6 +90,7 @@ func NewApplication(configPath string) (*Application, error) {
|
||||
pigSickPigLogRepo := repository.NewGormPigSickLogRepository(storage.GetDB())
|
||||
medicationLogRepo := repository.NewGormMedicationLogRepository(storage.GetDB())
|
||||
rawMaterialRepo := repository.NewGormRawMaterialRepository(storage.GetDB())
|
||||
notificationRepo := repository.NewGormNotificationRepository(storage.GetDB())
|
||||
|
||||
// 初始化事务管理器
|
||||
unitOfWork := repository.NewGormUnitOfWork(storage.GetDB(), logger)
|
||||
@@ -123,7 +124,7 @@ func NewApplication(configPath string) (*Application, error) {
|
||||
auditService := audit.NewService(userActionLogRepo, logger)
|
||||
|
||||
// 初始化通知服务
|
||||
notifyService, err := initNotifyService(cfg.Notify, logger, userRepo)
|
||||
notifyService, err := initNotifyService(cfg.Notify, logger, userRepo, notificationRepo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("初始化通知服务失败: %w", err)
|
||||
}
|
||||
@@ -220,6 +221,7 @@ func initNotifyService(
|
||||
cfg config.NotifyConfig,
|
||||
log *logs.Logger,
|
||||
userRepo repository.UserRepository,
|
||||
notificationRepo repository.NotificationRepository,
|
||||
) (domain_notify.Service, error) {
|
||||
var availableNotifiers []notify.Notifier
|
||||
|
||||
@@ -278,13 +280,14 @@ func initNotifyService(
|
||||
log.Warnf("配置的首选渠道 '%s' 未启用或未指定,已自动降级使用 '%s' 作为首选渠道。", cfg.Primary, primaryNotifier.Type())
|
||||
}
|
||||
|
||||
// 4. 使用创建的 Notifier 列表来组装领域服务
|
||||
// 4. 使用创建的 Notifier 列表和 notificationRepo 来组装领域服务
|
||||
notifyService, err := domain_notify.NewFailoverService(
|
||||
log,
|
||||
userRepo,
|
||||
availableNotifiers,
|
||||
primaryNotifier.Type(),
|
||||
cfg.FailureThreshold,
|
||||
notificationRepo,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("创建故障转移通知服务失败: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user