Просмотр исходного кода

feat(通知): 补齐通知通道实现与降级策略

zxyj-web 3 недель назад
Родитель
Сommit
888d60724e

+ 6 - 9
cfc-backend/src/main/java/com/etotem/cfc/service/notification/EmailNotificationChannel.java

@@ -3,23 +3,19 @@ package com.etotem.cfc.service.notification;
 import com.etotem.cfc.dto.NotificationMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 /**
- * 邮件通知通道(外部接口,预留)
+ * 邮件通知通道(本期不支持)
  * <p>
- * 未配置 SMTP/邮件服务商与收件人邮箱前不发送,仅记录日志;
- * 启用开关: notification.channels.email.enabled(默认 false)。
+ * 待接入 SMTP/邮件服务商(需 host/port/user/pass/from)与收件人邮箱获取方式(用户表无邮箱字段,需扩展)后启用。
+ * 当前 isEnabled() 固定返回 false,send() 仅记 debug 日志。
  */
 @Component
 public class EmailNotificationChannel implements NotificationChannel {
 
     private static final Logger log = LoggerFactory.getLogger(EmailNotificationChannel.class);
 
-    @Value("${notification.channels.email.enabled:false}")
-    private boolean enabled;
-
     @Override
     public String getChannelType() {
         return "email";
@@ -27,11 +23,12 @@ public class EmailNotificationChannel implements NotificationChannel {
 
     @Override
     public boolean isEnabled() {
-        return enabled;
+        return false;
     }
 
     @Override
     public void send(NotificationMessage message) {
-        log.warn("[邮件通道预留] 未配置邮件网关,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
+        // 本期不支持,待接入 SMTP/邮件服务商网关后启用
+        log.debug("[邮件通道] 本期不支持,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
     }
 }

+ 6 - 10
cfc-backend/src/main/java/com/etotem/cfc/service/notification/GzhNotificationChannel.java

@@ -3,23 +3,19 @@ package com.etotem.cfc.service.notification;
 import com.etotem.cfc.dto.NotificationMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 /**
- * 公众号消息通知通道(外部接口,预留)
+ * 公众号消息通知通道(本期不支持)
  * <p>
- * 未接入微信公众号模板消息前不发送,仅记录日志;接入后实现 send()。
- * 启用开关: notification.channels.gzh.enabled(默认 false)
+ * 待接入微信公众号模板消息(需 appid/appsecret、模板ID、用户openid映射)后启用。
+ * 当前 isEnabled() 固定返回 false,send() 仅记 debug 日志。
  */
 @Component
 public class GzhNotificationChannel implements NotificationChannel {
 
     private static final Logger log = LoggerFactory.getLogger(GzhNotificationChannel.class);
 
-    @Value("${notification.channels.gzh.enabled:false}")
-    private boolean enabled;
-
     @Override
     public String getChannelType() {
         return "gzh";
@@ -27,12 +23,12 @@ public class GzhNotificationChannel implements NotificationChannel {
 
     @Override
     public boolean isEnabled() {
-        return enabled;
+        return false;
     }
 
     @Override
     public void send(NotificationMessage message) {
-        // TODO: 接入微信公众号模板消息后在此实现
-        log.warn("[公众号通道预留] 未接入公众号消息服务,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
+        // 本期不支持,待接入微信公众号模板消息网关后启用
+        log.debug("[公众号通道] 本期不支持,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
     }
 }

+ 6 - 10
cfc-backend/src/main/java/com/etotem/cfc/service/notification/PhoneNotificationChannel.java

@@ -3,23 +3,19 @@ package com.etotem.cfc.service.notification;
 import com.etotem.cfc.dto.NotificationMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 /**
- * 电话通知通道(外部接口,预留)
+ * 电话通知通道(本期不支持)
  * <p>
- * 未接入语音呼叫服务(阿里云/腾讯云)前不发送,仅记录日志;接入后实现 send()。
- * 启用开关: notification.channels.phone.enabled(默认 false)
+ * 待接入语音呼叫服务商(阿里云/腾讯云语音,需 AccessKey、模板ID、被叫号码)后启用。
+ * 当前 isEnabled() 固定返回 false,send() 仅记 debug 日志。
  */
 @Component
 public class PhoneNotificationChannel implements NotificationChannel {
 
     private static final Logger log = LoggerFactory.getLogger(PhoneNotificationChannel.class);
 
-    @Value("${notification.channels.phone.enabled:false}")
-    private boolean enabled;
-
     @Override
     public String getChannelType() {
         return "phone";
@@ -27,12 +23,12 @@ public class PhoneNotificationChannel implements NotificationChannel {
 
     @Override
     public boolean isEnabled() {
-        return enabled;
+        return false;
     }
 
     @Override
     public void send(NotificationMessage message) {
-        // TODO: 接入语音呼叫服务(阿里云/腾讯云)后在此实现
-        log.warn("[电话通道预留] 未接入语音呼叫服务,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
+        // 本期不支持,待接入语音呼叫服务网关后启用
+        log.debug("[电话通道] 本期不支持,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
     }
 }

+ 6 - 10
cfc-backend/src/main/java/com/etotem/cfc/service/notification/SmsNotificationChannel.java

@@ -3,23 +3,19 @@ package com.etotem.cfc.service.notification;
 import com.etotem.cfc.dto.NotificationMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 /**
- * 短信通知通道(外部接口,预留)
+ * 短信通知通道(本期不支持)
  * <p>
- * 未接入短信网关前不发送,仅记录日志;接入后实现 send()。
- * 启用开关: notification.channels.sms.enabled(默认 false)
+ * 待接入短信网关(阿里云/腾讯云短信,需 AccessKey、签名、模板ID、手机号)后启用。
+ * 当前 isEnabled() 固定返回 false,send() 仅记 debug 日志。
  */
 @Component
 public class SmsNotificationChannel implements NotificationChannel {
 
     private static final Logger log = LoggerFactory.getLogger(SmsNotificationChannel.class);
 
-    @Value("${notification.channels.sms.enabled:false}")
-    private boolean enabled;
-
     @Override
     public String getChannelType() {
         return "sms";
@@ -27,12 +23,12 @@ public class SmsNotificationChannel implements NotificationChannel {
 
     @Override
     public boolean isEnabled() {
-        return enabled;
+        return false;
     }
 
     @Override
     public void send(NotificationMessage message) {
-        // TODO: 接入短信网关(阿里云/腾讯云)后在此实现
-        log.warn("[短信通道预留] 未接入短信网关,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
+        // 本期不支持,待接入短信网关后启用
+        log.debug("[短信通道] 本期不支持,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
     }
 }

+ 9 - 11
cfc-backend/src/main/java/com/etotem/cfc/service/notification/WechatNotificationChannel.java

@@ -3,23 +3,21 @@ package com.etotem.cfc.service.notification;
 import com.etotem.cfc.dto.NotificationMessage;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 /**
- * 微信通知通道(外部接口,预留)
+ * 微信通知通道(本期不支持)
  * <p>
- * 未接入微信订阅消息/模板消息前不发送,仅记录日志;接入后实现 send()。
- * 启用开关: notification.channels.wechat.enabled(默认 false)
+ * 待接入微信小程序订阅消息(需模板ID、用户订阅授权、openid)后启用。
+ * 当前 isEnabled() 固定返回 false,send() 仅记 debug 日志。
+ * 注意:本通道与 {@link WebhookNotificationChannel} 是不同实现,后者复用
+ * WechatWaitMsgService 推送待办消息,已投产并共享 wechat 通道类型。
  */
 @Component
 public class WechatNotificationChannel implements NotificationChannel {
 
     private static final Logger log = LoggerFactory.getLogger(WechatNotificationChannel.class);
 
-    @Value("${notification.channels.wechat.enabled:false}")
-    private boolean enabled;
-
     @Override
     public String getChannelType() {
         return "wechat";
@@ -27,12 +25,12 @@ public class WechatNotificationChannel implements NotificationChannel {
 
     @Override
     public boolean isEnabled() {
-        return enabled;
+        return false;
     }
 
     @Override
     public void send(NotificationMessage message) {
-        // TODO: 接入微信订阅消息/模板消息后在此实现
-        log.warn("[微信通道预留] 未接入微信消息服务,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
+        // 本期不支持,待接入微信小程序订阅消息网关后启用
+        log.debug("[微信通道] 本期不支持,跳过发送: userId={}, title={}", message.getUserId(), message.getTitle());
     }
-}
+}