- 新增用户通知 outbox 流水线(EfUserNotificationPipeline)与后台投递 worker - 通知中心页面及前端通知服务接入 - 健康指标异常、用药/运动提醒等事件统一产出站内通知 - 健康档案结构化手术史、用药提醒扫描、医生/用户端点等配套调整 - AppDbContext 注册通知相关实体
32 lines
1.4 KiB
C#
32 lines
1.4 KiB
C#
namespace Health.Application.Notifications;
|
|
|
|
public sealed class InAppNotificationService(IInAppNotificationRepository notifications) : IInAppNotificationService
|
|
{
|
|
private readonly IInAppNotificationRepository _notifications = notifications;
|
|
|
|
public async Task<IReadOnlyList<InAppNotificationDto>> GetPendingAsync(Guid userId, CancellationToken ct)
|
|
{
|
|
var records = await _notifications.GetPendingAsync(userId, ct);
|
|
return records.Select(ToDto).ToList();
|
|
}
|
|
|
|
public async Task<IReadOnlyList<InAppNotificationDto>> GetHistoryAsync(Guid userId, CancellationToken ct)
|
|
{
|
|
var records = await _notifications.GetHistoryAsync(userId, ct);
|
|
return records.Select(ToDto).ToList();
|
|
}
|
|
|
|
public Task<bool> AcknowledgeAsync(Guid userId, Guid notificationId, CancellationToken ct) =>
|
|
_notifications.AcknowledgeAsync(userId, notificationId, ct);
|
|
|
|
public Task<int> MarkAllReadAsync(Guid userId, CancellationToken ct) =>
|
|
_notifications.MarkAllReadAsync(userId, ct);
|
|
|
|
public Task<bool> DeleteAsync(Guid userId, Guid notificationId, CancellationToken ct) =>
|
|
_notifications.DeleteAsync(userId, notificationId, ct);
|
|
|
|
private static InAppNotificationDto ToDto(InAppNotificationRecord record) => new(
|
|
record.Id, record.Type, record.Title, record.Message, record.Severity,
|
|
record.ActionType, record.ActionTargetId, record.IsRead, record.CreatedAt);
|
|
}
|