S8NotificationService.cs 1.0 KB

123456789101112131415161718192021222324252627
  1. using Admin.NET.Plugin.AiDOP.Entity.S8;
  2. namespace Admin.NET.Plugin.AiDOP.Service.S8;
  3. /// <summary>
  4. /// 通知发送服务。首轮实现:将通知意图序列化为 JSON 写入 <see cref="AdoS8NotificationLog"/>,
  5. /// 不做实际推送。后续接入钉钉/企微/邮件时替换此服务内部实现即可,外部接口不变。
  6. /// </summary>
  7. public class S8NotificationService : ITransient
  8. {
  9. private readonly SqlSugarRepository<AdoS8NotificationLog> _logRep;
  10. public S8NotificationService(SqlSugarRepository<AdoS8NotificationLog> logRep) => _logRep = logRep;
  11. public async Task SendAsync(long tenantId, long factoryId, long? exceptionId, string channel, object payload)
  12. {
  13. await _logRep.InsertAsync(new AdoS8NotificationLog
  14. {
  15. TenantId = tenantId,
  16. FactoryId = factoryId,
  17. ExceptionId = exceptionId,
  18. Channel = channel,
  19. Payload = System.Text.Json.JsonSerializer.Serialize(payload),
  20. CreatedAt = DateTime.Now
  21. });
  22. }
  23. }