- 新增用户通知 outbox 流水线(EfUserNotificationPipeline)与后台投递 worker - 通知中心页面及前端通知服务接入 - 健康指标异常、用药/运动提醒等事件统一产出站内通知 - 健康档案结构化手术史、用药提醒扫描、医生/用户端点等配套调整 - AppDbContext 注册通知相关实体
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
namespace Health.Application.Notifications;
|
|
|
|
public sealed record InAppNotificationDto(
|
|
Guid Id,
|
|
string Type,
|
|
string Title,
|
|
string Message,
|
|
string Severity,
|
|
string? ActionType,
|
|
string? ActionTargetId,
|
|
bool IsRead,
|
|
DateTime CreatedAt);
|
|
|
|
public sealed record NotificationMessage(
|
|
string Type,
|
|
string Title,
|
|
string Message,
|
|
string Severity,
|
|
string? ActionType,
|
|
string? ActionTargetId);
|
|
|
|
public interface IInAppNotificationService
|
|
{
|
|
Task<IReadOnlyList<InAppNotificationDto>> GetPendingAsync(Guid userId, CancellationToken ct);
|
|
Task<IReadOnlyList<InAppNotificationDto>> GetHistoryAsync(Guid userId, CancellationToken ct);
|
|
Task<bool> AcknowledgeAsync(Guid userId, Guid notificationId, CancellationToken ct);
|
|
Task<int> MarkAllReadAsync(Guid userId, CancellationToken ct);
|
|
Task<bool> DeleteAsync(Guid userId, Guid notificationId, CancellationToken ct);
|
|
}
|
|
|
|
public interface IInAppNotificationRepository
|
|
{
|
|
Task<IReadOnlyList<InAppNotificationRecord>> GetPendingAsync(Guid userId, CancellationToken ct);
|
|
Task<IReadOnlyList<InAppNotificationRecord>> GetHistoryAsync(Guid userId, CancellationToken ct);
|
|
Task<bool> AcknowledgeAsync(Guid userId, Guid notificationId, CancellationToken ct);
|
|
Task<int> MarkAllReadAsync(Guid userId, CancellationToken ct);
|
|
Task<bool> DeleteAsync(Guid userId, Guid notificationId, CancellationToken ct);
|
|
}
|
|
|
|
public sealed record InAppNotificationRecord(
|
|
Guid Id,
|
|
string Type,
|
|
string Title,
|
|
string Message,
|
|
string Severity,
|
|
string? ActionType,
|
|
string? ActionTargetId,
|
|
bool IsRead,
|
|
DateTime CreatedAt);
|
|
|
|
public interface IUserNotificationProducer
|
|
{
|
|
Task<bool> EnqueueAsync(Guid userId, Guid sourceId, NotificationMessage message, CancellationToken ct);
|
|
}
|
|
|
|
public interface INotificationOutboxProcessor
|
|
{
|
|
Task RecoverStaleAsync(CancellationToken ct);
|
|
Task<bool> ProcessNextAsync(CancellationToken ct);
|
|
}
|