yangys
2024-03-27 44028c2d1a7f21da831cb07ecb1b4a7873d8627b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.qianwen.core.notify.executor;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.core.notify.notifier.Notifier;
import com.qianwen.core.notify.notifier.NotifierManager;
import com.qianwen.core.tool.metadata.Values;
import com.qianwen.core.tool.utils.Func;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Component;
 
@ConditionalOnBean({NotifierManager.class})
@Component
/* loaded from: blade-starter-notify-9.3.0.0-SNAPSHOT.jar:org/springblade/core/notify/executor/NotifyQueueExecutorProvider.class */
public class NotifyQueueExecutorProvider implements NotifyExecutorProvider {
    private static final Logger log = LoggerFactory.getLogger(NotifyQueueExecutorProvider.class);
    private final NotifierManager notifierManager;
 
    public NotifyQueueExecutorProvider(final NotifierManager notifierManager) {
        this.notifierManager = notifierManager;
    }
 
    @Override // com.qianwen.core.notify.executor.NotifyExecutorProvider
    public String getExecutor() {
        return "notifier";
    }
 
    @Override // com.qianwen.core.notify.executor.NotifyExecutorProvider
    public void executeNotify(NotifyExecutionContext context) {
        RuleNotifierProperties config = context.getConfiguration();
        config.validate();
        Notifier notifier = this.notifierManager.getNotifier(config.getNotifyType(), config.getNotifierId());
        if (Func.isNotEmpty(notifier)) {
            notifier.send(config.getTemplateId(), context.getContextId(), Values.of(context.getData()), context.getNotifiedParty());
        } else {
            log.warn("通知器[{}-{}]不存在", config.getNotifyType(), config.getNotifierId());
        }
    }
}