24 changed files with 1888 additions and 0 deletions
@ -0,0 +1,79 @@ |
|||
# LINGYUN.Abp.Notifications.Application.Contracts |
|||
|
|||
The application layer contracts module of the notification system, providing application service interface definitions and data transfer objects. |
|||
|
|||
## Features |
|||
|
|||
* Notification application service interface definitions |
|||
* Notification subscription application service interface definitions |
|||
* Notification data transfer object (DTO) definitions |
|||
* Notification permission definitions |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsApplicationContractsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Application Service Interfaces |
|||
|
|||
### INotificationAppService |
|||
|
|||
* GetAsync - Get notification details |
|||
* GetListAsync - Get notification list |
|||
* DeleteAsync - Delete notification |
|||
* MarkReadAsync - Mark notification as read |
|||
* MarkAllReadAsync - Mark all notifications as read |
|||
|
|||
### INotificationSubscriptionAppService |
|||
|
|||
* SubscribeAsync - Subscribe to notification |
|||
* UnSubscribeAsync - Unsubscribe from notification |
|||
* GetAssignableSubscribersAsync - Get list of assignable subscribers |
|||
* GetSubscribedListAsync - Get list of subscribed notifications |
|||
|
|||
## Data Transfer Objects |
|||
|
|||
### NotificationInfo |
|||
|
|||
* Id - Unique identifier for the notification |
|||
* NotificationName - Notification name |
|||
* Data - Notification data |
|||
* CreationTime - Creation time |
|||
* Type - Notification type |
|||
* Severity - Notification severity |
|||
|
|||
### NotificationSubscriptionInfo |
|||
|
|||
* NotificationName - Notification name |
|||
* DisplayName - Display name |
|||
* Description - Description |
|||
* IsSubscribed - Subscription status |
|||
|
|||
## Permission Definitions |
|||
|
|||
* Notifications - Notification management |
|||
* Notifications.Manage - Manage notifications |
|||
* Notifications.Delete - Delete notifications |
|||
* Notifications.Subscribe - Subscribe to notifications |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Implement notification application service |
|||
```csharp |
|||
public class NotificationAppService : ApplicationService, INotificationAppService |
|||
{ |
|||
public async Task<NotificationInfo> GetAsync(Guid id) |
|||
{ |
|||
// Implement logic to get notification details |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
@ -0,0 +1,79 @@ |
|||
# LINGYUN.Abp.Notifications.Application.Contracts |
|||
|
|||
通知系统的应用层契约模块,提供了通知系统的应用服务接口定义和数据传输对象。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知应用服务接口定义 |
|||
* 通知订阅应用服务接口定义 |
|||
* 通知数据传输对象(DTO)定义 |
|||
* 通知权限定义 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsApplicationContractsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 应用服务接口 |
|||
|
|||
### INotificationAppService |
|||
|
|||
* GetAsync - 获取通知详情 |
|||
* GetListAsync - 获取通知列表 |
|||
* DeleteAsync - 删除通知 |
|||
* MarkReadAsync - 标记通知为已读 |
|||
* MarkAllReadAsync - 标记所有通知为已读 |
|||
|
|||
### INotificationSubscriptionAppService |
|||
|
|||
* SubscribeAsync - 订阅通知 |
|||
* UnSubscribeAsync - 取消订阅通知 |
|||
* GetAssignableSubscribersAsync - 获取可分配的订阅者列表 |
|||
* GetSubscribedListAsync - 获取已订阅的通知列表 |
|||
|
|||
## 数据传输对象 |
|||
|
|||
### NotificationInfo |
|||
|
|||
* Id - 通知唯一标识 |
|||
* NotificationName - 通知名称 |
|||
* Data - 通知数据 |
|||
* CreationTime - 创建时间 |
|||
* Type - 通知类型 |
|||
* Severity - 通知严重程度 |
|||
|
|||
### NotificationSubscriptionInfo |
|||
|
|||
* NotificationName - 通知名称 |
|||
* DisplayName - 显示名称 |
|||
* Description - 描述 |
|||
* IsSubscribed - 是否已订阅 |
|||
|
|||
## 权限定义 |
|||
|
|||
* Notifications - 通知管理 |
|||
* Notifications.Manage - 管理通知 |
|||
* Notifications.Delete - 删除通知 |
|||
* Notifications.Subscribe - 订阅通知 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 实现通知应用服务 |
|||
```csharp |
|||
public class NotificationAppService : ApplicationService, INotificationAppService |
|||
{ |
|||
public async Task<NotificationInfo> GetAsync(Guid id) |
|||
{ |
|||
// 实现获取通知详情的逻辑 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
@ -0,0 +1,58 @@ |
|||
# LINGYUN.Abp.Notifications.Application |
|||
|
|||
The application layer module of the notification system, providing application service implementations for the notification system. |
|||
|
|||
## Features |
|||
|
|||
* Notification management service |
|||
* Notification subscription service |
|||
* Notification publishing service |
|||
* Notification query service |
|||
* Notification status management service |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsApplicationModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Application Services |
|||
|
|||
### INotificationAppService |
|||
|
|||
* GetAsync - Get notification details |
|||
* GetListAsync - Get notification list |
|||
* DeleteAsync - Delete notification |
|||
* MarkReadAsync - Mark notification as read |
|||
* MarkAllReadAsync - Mark all notifications as read |
|||
|
|||
### INotificationSubscriptionAppService |
|||
|
|||
* SubscribeAsync - Subscribe to notification |
|||
* UnSubscribeAsync - Unsubscribe from notification |
|||
* GetAssignableSubscribersAsync - Get list of assignable subscribers |
|||
* GetSubscribedListAsync - Get list of subscribed notifications |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Send notification |
|||
```csharp |
|||
await NotificationAppService.PublishAsync( |
|||
name: "YourNotification", |
|||
data: new NotificationData(), |
|||
userIds: new[] { CurrentUser.Id }); |
|||
``` |
|||
|
|||
2. Manage notification subscription |
|||
```csharp |
|||
await NotificationSubscriptionAppService.SubscribeAsync( |
|||
notificationName: "YourNotification"); |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
@ -0,0 +1,58 @@ |
|||
# LINGYUN.Abp.Notifications.Application |
|||
|
|||
通知系统的应用层模块,提供了通知系统的应用服务实现。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知管理服务 |
|||
* 通知订阅服务 |
|||
* 通知发布服务 |
|||
* 通知查询服务 |
|||
* 通知状态管理服务 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsApplicationModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 应用服务 |
|||
|
|||
### INotificationAppService |
|||
|
|||
* GetAsync - 获取通知详情 |
|||
* GetListAsync - 获取通知列表 |
|||
* DeleteAsync - 删除通知 |
|||
* MarkReadAsync - 标记通知为已读 |
|||
* MarkAllReadAsync - 标记所有通知为已读 |
|||
|
|||
### INotificationSubscriptionAppService |
|||
|
|||
* SubscribeAsync - 订阅通知 |
|||
* UnSubscribeAsync - 取消订阅通知 |
|||
* GetAssignableSubscribersAsync - 获取可分配的订阅者列表 |
|||
* GetSubscribedListAsync - 获取已订阅的通知列表 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 发送通知 |
|||
```csharp |
|||
await NotificationAppService.PublishAsync( |
|||
name: "YourNotification", |
|||
data: new NotificationData(), |
|||
userIds: new[] { CurrentUser.Id }); |
|||
``` |
|||
|
|||
2. 管理通知订阅 |
|||
```csharp |
|||
await NotificationSubscriptionAppService.SubscribeAsync( |
|||
notificationName: "YourNotification"); |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
@ -0,0 +1,113 @@ |
|||
# LINGYUN.Abp.Notifications.Common |
|||
|
|||
The common module of the notification system, providing basic definitions and shared functionality. |
|||
|
|||
## Features |
|||
|
|||
* Notification Definitions |
|||
* Notification group definitions |
|||
* Notification type definitions |
|||
* Notification level definitions |
|||
* Common Utilities |
|||
* Notification data handling |
|||
* Notification status management |
|||
* Extension Features |
|||
* Notification data extensions |
|||
* Notification provider extensions |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsCommonModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Basic Definitions |
|||
|
|||
### Notification Group |
|||
|
|||
```csharp |
|||
public class NotificationGroupDefinition |
|||
{ |
|||
public string Name { get; } |
|||
public string DisplayName { get; } |
|||
public string Description { get; } |
|||
public bool AllowSubscriptionToClients { get; } |
|||
} |
|||
``` |
|||
|
|||
### Notification Definition |
|||
|
|||
```csharp |
|||
public class NotificationDefinition |
|||
{ |
|||
public string Name { get; } |
|||
public string DisplayName { get; } |
|||
public string Description { get; } |
|||
public NotificationType NotificationType { get; } |
|||
public NotificationLifetime Lifetime { get; } |
|||
public bool AllowSubscriptionToClients { get; } |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Define Notification Group |
|||
```csharp |
|||
public class YourNotificationGroupDefinitionProvider : NotificationGroupDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationGroupDefinitionContext context) |
|||
{ |
|||
context.Add( |
|||
new NotificationGroupDefinition( |
|||
name: "App.Notifications", |
|||
displayName: L("AppNotifications"), |
|||
description: L("AppNotificationsDescription") |
|||
) |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Define Notification |
|||
```csharp |
|||
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationDefinitionContext context) |
|||
{ |
|||
context.Add( |
|||
new NotificationDefinition( |
|||
name: "App.NewMessage", |
|||
displayName: L("NewMessage"), |
|||
description: L("NewMessageDescription"), |
|||
notificationType: NotificationType.Application, |
|||
lifetime: NotificationLifetime.Persistent |
|||
) |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. Use Notification Data Extensions |
|||
```csharp |
|||
public static class NotificationDataExtensions |
|||
{ |
|||
public static void SetTitle(this NotificationData data, string title) |
|||
{ |
|||
data.ExtraProperties["Title"] = title; |
|||
} |
|||
|
|||
public static string GetTitle(this NotificationData data) |
|||
{ |
|||
return data.ExtraProperties.GetOrDefault("Title") as string; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
* [Notifications Documentation](https://docs.abp.io/en/abp/latest/Notifications) |
|||
@ -0,0 +1,113 @@ |
|||
# LINGYUN.Abp.Notifications.Common |
|||
|
|||
通知系统的公共模块,提供了通知系统的基础定义和共享功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知定义 |
|||
* 通知组定义 |
|||
* 通知类型定义 |
|||
* 通知级别定义 |
|||
* 通用工具类 |
|||
* 通知数据处理 |
|||
* 通知状态管理 |
|||
* 扩展功能 |
|||
* 通知数据扩展 |
|||
* 通知提供者扩展 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsCommonModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 基础定义 |
|||
|
|||
### 通知组 |
|||
|
|||
```csharp |
|||
public class NotificationGroupDefinition |
|||
{ |
|||
public string Name { get; } |
|||
public string DisplayName { get; } |
|||
public string Description { get; } |
|||
public bool AllowSubscriptionToClients { get; } |
|||
} |
|||
``` |
|||
|
|||
### 通知定义 |
|||
|
|||
```csharp |
|||
public class NotificationDefinition |
|||
{ |
|||
public string Name { get; } |
|||
public string DisplayName { get; } |
|||
public string Description { get; } |
|||
public NotificationType NotificationType { get; } |
|||
public NotificationLifetime Lifetime { get; } |
|||
public bool AllowSubscriptionToClients { get; } |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 定义通知组 |
|||
```csharp |
|||
public class YourNotificationGroupDefinitionProvider : NotificationGroupDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationGroupDefinitionContext context) |
|||
{ |
|||
context.Add( |
|||
new NotificationGroupDefinition( |
|||
name: "App.Notifications", |
|||
displayName: L("AppNotifications"), |
|||
description: L("AppNotificationsDescription") |
|||
) |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 定义通知 |
|||
```csharp |
|||
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationDefinitionContext context) |
|||
{ |
|||
context.Add( |
|||
new NotificationDefinition( |
|||
name: "App.NewMessage", |
|||
displayName: L("NewMessage"), |
|||
description: L("NewMessageDescription"), |
|||
notificationType: NotificationType.Application, |
|||
lifetime: NotificationLifetime.Persistent |
|||
) |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. 使用通知数据扩展 |
|||
```csharp |
|||
public static class NotificationDataExtensions |
|||
{ |
|||
public static void SetTitle(this NotificationData data, string title) |
|||
{ |
|||
data.ExtraProperties["Title"] = title; |
|||
} |
|||
|
|||
public static string GetTitle(this NotificationData data) |
|||
{ |
|||
return data.ExtraProperties.GetOrDefault("Title") as string; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
* [通知系统文档](https://docs.abp.io/en/abp/latest/Notifications) |
|||
@ -0,0 +1,65 @@ |
|||
# LINGYUN.Abp.Notifications.Core |
|||
|
|||
The core module of the notification system, providing basic functionality and definitions for the notification system. |
|||
|
|||
## Features |
|||
|
|||
* Notification definition management |
|||
* Notification group definition management |
|||
* Extensible notification provider mechanism |
|||
* Support for custom notification definition providers |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Notifications": { |
|||
"DeletedNotifications": [], // List of notification definitions to be deleted |
|||
"DeletedNotificationGroups": [] // List of notification group definitions to be deleted |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Implement custom notification definition provider |
|||
```csharp |
|||
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationDefinitionContext context) |
|||
{ |
|||
// Define notifications |
|||
context.Add( |
|||
new NotificationDefinition( |
|||
name: "YourNotification", |
|||
displayName: L("YourNotification"), |
|||
description: L("YourNotificationDescription"), |
|||
notificationType: NotificationType.Application, |
|||
lifetime: NotificationLifetime.Persistent, |
|||
allowSubscriptionToClients: true) |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Register notification definition provider |
|||
```csharp |
|||
Configure<AbpNotificationsOptions>(options => |
|||
{ |
|||
options.DefinitionProviders.Add<YourNotificationDefinitionProvider>(); |
|||
}); |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
@ -0,0 +1,65 @@ |
|||
# LINGYUN.Abp.Notifications.Core |
|||
|
|||
通知系统的核心模块,提供了通知系统的基础功能和定义。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知定义管理 |
|||
* 通知组定义管理 |
|||
* 可扩展的通知提供者机制 |
|||
* 支持自定义通知定义提供者 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置项 |
|||
|
|||
```json |
|||
{ |
|||
"Notifications": { |
|||
"DeletedNotifications": [], // 需要删除的通知定义列表 |
|||
"DeletedNotificationGroups": [] // 需要删除的通知组定义列表 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 实现自定义通知定义提供者 |
|||
```csharp |
|||
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationDefinitionContext context) |
|||
{ |
|||
// 定义通知 |
|||
context.Add( |
|||
new NotificationDefinition( |
|||
name: "YourNotification", |
|||
displayName: L("YourNotification"), |
|||
description: L("YourNotificationDescription"), |
|||
notificationType: NotificationType.Application, |
|||
lifetime: NotificationLifetime.Persistent, |
|||
allowSubscriptionToClients: true) |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 注册通知定义提供者 |
|||
```csharp |
|||
Configure<AbpNotificationsOptions>(options => |
|||
{ |
|||
options.DefinitionProviders.Add<YourNotificationDefinitionProvider>(); |
|||
}); |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
@ -0,0 +1,58 @@ |
|||
# LINGYUN.Abp.Notifications.Domain.Shared |
|||
|
|||
The shared domain layer module of the notification system, providing shared constants, enums, and other domain objects for the notification system. |
|||
|
|||
## Features |
|||
|
|||
* Notification type definition |
|||
* Notification severity definition |
|||
* Notification status definition |
|||
* Notification lifetime definition |
|||
* Notification constant definition |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsDomainSharedModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Enum Definitions |
|||
|
|||
### NotificationType |
|||
|
|||
* Application - Application notification |
|||
* System - System notification |
|||
* User - User notification |
|||
|
|||
### NotificationSeverity |
|||
|
|||
* Info - Information |
|||
* Success - Success |
|||
* Warn - Warning |
|||
* Error - Error |
|||
* Fatal - Fatal error |
|||
|
|||
### NotificationLifetime |
|||
|
|||
* Persistent - Persistent notification |
|||
* OnlyOne - One-time notification |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Use notification type |
|||
```csharp |
|||
var notificationType = NotificationType.Application; |
|||
``` |
|||
|
|||
2. Use notification severity |
|||
```csharp |
|||
var severity = NotificationSeverity.Info; |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
@ -0,0 +1,58 @@ |
|||
# LINGYUN.Abp.Notifications.Domain.Shared |
|||
|
|||
通知系统的共享领域层模块,提供了通知系统的共享常量、枚举和其他领域对象。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知类型定义 |
|||
* 通知严重程度定义 |
|||
* 通知状态定义 |
|||
* 通知生命周期定义 |
|||
* 通知常量定义 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsDomainSharedModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 枚举定义 |
|||
|
|||
### NotificationType |
|||
|
|||
* Application - 应用程序通知 |
|||
* System - 系统通知 |
|||
* User - 用户通知 |
|||
|
|||
### NotificationSeverity |
|||
|
|||
* Info - 信息 |
|||
* Success - 成功 |
|||
* Warn - 警告 |
|||
* Error - 错误 |
|||
* Fatal - 致命错误 |
|||
|
|||
### NotificationLifetime |
|||
|
|||
* Persistent - 持久化通知 |
|||
* OnlyOne - 一次性通知 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 使用通知类型 |
|||
```csharp |
|||
var notificationType = NotificationType.Application; |
|||
``` |
|||
|
|||
2. 使用通知严重程度 |
|||
```csharp |
|||
var severity = NotificationSeverity.Info; |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
@ -0,0 +1,61 @@ |
|||
# LINGYUN.Abp.Notifications.Domain |
|||
|
|||
The domain layer module of the notification system, providing domain models and business logic for the notification system. |
|||
|
|||
## Features |
|||
|
|||
* Notification entity definition |
|||
* Notification subscription management |
|||
* Notification status management |
|||
* Notification data extension support |
|||
* Support for custom notification data |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsDomainModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Domain Models |
|||
|
|||
### Notification |
|||
|
|||
* Id - Unique identifier for the notification |
|||
* Name - Notification name |
|||
* NotificationData - Notification data |
|||
* CreationTime - Creation time |
|||
* Type - Notification type |
|||
* Severity - Notification severity |
|||
* ExtraProperties - Extension properties |
|||
|
|||
### NotificationSubscription |
|||
|
|||
* UserId - User identifier |
|||
* NotificationName - Notification name |
|||
* CreationTime - Creation time |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Create notification |
|||
```csharp |
|||
var notification = new Notification( |
|||
id: GuidGenerator.Create(), |
|||
name: "YourNotification", |
|||
data: new NotificationData(), |
|||
tenantId: CurrentTenant.Id); |
|||
``` |
|||
|
|||
2. Manage notification subscriptions |
|||
```csharp |
|||
await NotificationSubscriptionManager.SubscribeAsync( |
|||
userId: CurrentUser.Id, |
|||
notificationName: "YourNotification"); |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
@ -0,0 +1,61 @@ |
|||
# LINGYUN.Abp.Notifications.Domain |
|||
|
|||
通知系统的领域层模块,提供了通知系统的领域模型和业务逻辑。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知实体定义 |
|||
* 通知订阅管理 |
|||
* 通知状态管理 |
|||
* 通知数据扩展支持 |
|||
* 支持自定义通知数据 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsDomainModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 领域模型 |
|||
|
|||
### Notification |
|||
|
|||
* Id - 通知唯一标识 |
|||
* Name - 通知名称 |
|||
* NotificationData - 通知数据 |
|||
* CreationTime - 创建时间 |
|||
* Type - 通知类型 |
|||
* Severity - 通知严重程度 |
|||
* ExtraProperties - 扩展属性 |
|||
|
|||
### NotificationSubscription |
|||
|
|||
* UserId - 用户标识 |
|||
* NotificationName - 通知名称 |
|||
* CreationTime - 创建时间 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 创建通知 |
|||
```csharp |
|||
var notification = new Notification( |
|||
id: GuidGenerator.Create(), |
|||
name: "YourNotification", |
|||
data: new NotificationData(), |
|||
tenantId: CurrentTenant.Id); |
|||
``` |
|||
|
|||
2. 管理通知订阅 |
|||
```csharp |
|||
await NotificationSubscriptionManager.SubscribeAsync( |
|||
userId: CurrentUser.Id, |
|||
notificationName: "YourNotification"); |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
@ -0,0 +1,98 @@ |
|||
# LINGYUN.Abp.Notifications.Emailing |
|||
|
|||
The email sending module of the notification system, providing functionality to send notifications via email. |
|||
|
|||
## Features |
|||
|
|||
* Email notification sending |
|||
* Email template support |
|||
* Support for HTML format emails |
|||
* Support for multiple recipients |
|||
* Support for CC and BCC |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsEmailingModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Notifications": { |
|||
"Emailing": { |
|||
"Templates": { |
|||
"Default": { |
|||
"Template": "DefaultTemplate", |
|||
"Culture": "en" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Configure Email Settings |
|||
```csharp |
|||
Configure<AbpEmailingOptions>(options => |
|||
{ |
|||
options.DefaultFromAddress = "noreply@example.com"; |
|||
options.DefaultFromDisplayName = "Notification System"; |
|||
}); |
|||
``` |
|||
|
|||
2. Send Email Notification |
|||
```csharp |
|||
public class YourNotificationHandler : INotificationHandler |
|||
{ |
|||
private readonly IEmailSender _emailSender; |
|||
|
|||
public YourNotificationHandler(IEmailSender emailSender) |
|||
{ |
|||
_emailSender = emailSender; |
|||
} |
|||
|
|||
public async Task HandleAsync(NotificationInfo notification) |
|||
{ |
|||
await _emailSender.SendAsync( |
|||
to: notification.UserEmail, |
|||
subject: notification.Title, |
|||
body: notification.Content, |
|||
isBodyHtml: true |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. Use Email Template |
|||
```csharp |
|||
public async Task SendWithTemplateAsync() |
|||
{ |
|||
var template = await _templateRenderer.RenderAsync( |
|||
"DefaultTemplate", |
|||
new { |
|||
Title = "Notification Title", |
|||
Content = "Notification Content" |
|||
} |
|||
); |
|||
|
|||
await _emailSender.SendAsync( |
|||
to: "user@example.com", |
|||
subject: "Notification", |
|||
body: template, |
|||
isBodyHtml: true |
|||
); |
|||
} |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
* [Emailing Documentation](https://docs.abp.io/en/abp/latest/Emailing) |
|||
@ -0,0 +1,98 @@ |
|||
# LINGYUN.Abp.Notifications.Emailing |
|||
|
|||
通知系统的邮件发送模块,提供了通过邮件发送通知的功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 邮件通知发送 |
|||
* 邮件模板支持 |
|||
* 支持HTML格式邮件 |
|||
* 支持多收件人 |
|||
* 支持抄送和密送 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsEmailingModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置项 |
|||
|
|||
```json |
|||
{ |
|||
"Notifications": { |
|||
"Emailing": { |
|||
"Templates": { |
|||
"Default": { |
|||
"Template": "DefaultTemplate", |
|||
"Culture": "zh-Hans" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 配置邮件设置 |
|||
```csharp |
|||
Configure<AbpEmailingOptions>(options => |
|||
{ |
|||
options.DefaultFromAddress = "noreply@example.com"; |
|||
options.DefaultFromDisplayName = "Notification System"; |
|||
}); |
|||
``` |
|||
|
|||
2. 发送邮件通知 |
|||
```csharp |
|||
public class YourNotificationHandler : INotificationHandler |
|||
{ |
|||
private readonly IEmailSender _emailSender; |
|||
|
|||
public YourNotificationHandler(IEmailSender emailSender) |
|||
{ |
|||
_emailSender = emailSender; |
|||
} |
|||
|
|||
public async Task HandleAsync(NotificationInfo notification) |
|||
{ |
|||
await _emailSender.SendAsync( |
|||
to: notification.UserEmail, |
|||
subject: notification.Title, |
|||
body: notification.Content, |
|||
isBodyHtml: true |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. 使用邮件模板 |
|||
```csharp |
|||
public async Task SendWithTemplateAsync() |
|||
{ |
|||
var template = await _templateRenderer.RenderAsync( |
|||
"DefaultTemplate", |
|||
new { |
|||
Title = "通知标题", |
|||
Content = "通知内容" |
|||
} |
|||
); |
|||
|
|||
await _emailSender.SendAsync( |
|||
to: "user@example.com", |
|||
subject: "通知", |
|||
body: template, |
|||
isBodyHtml: true |
|||
); |
|||
} |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
* [邮件发送文档](https://docs.abp.io/en/abp/latest/Emailing) |
|||
@ -0,0 +1,72 @@ |
|||
# LINGYUN.Abp.Notifications.EntityFrameworkCore |
|||
|
|||
The EntityFrameworkCore module of the notification system, providing data access implementation for the notification system. |
|||
|
|||
## Features |
|||
|
|||
* Notification entity mapping configuration |
|||
* Notification repository implementation |
|||
* Notification subscription repository implementation |
|||
* Support for multiple databases |
|||
* Support for custom repository extensions |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsEntityFrameworkCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Entity Mappings |
|||
|
|||
### NotificationEfCoreEntityTypeConfiguration |
|||
|
|||
* Notification - Notification entity mapping |
|||
* Id - Primary key mapping |
|||
* NotificationName - Notification name mapping |
|||
* Data - Notification data mapping |
|||
* CreationTime - Creation time mapping |
|||
* Type - Notification type mapping |
|||
* Severity - Notification severity mapping |
|||
|
|||
### NotificationSubscriptionEfCoreEntityTypeConfiguration |
|||
|
|||
* NotificationSubscription - Notification subscription entity mapping |
|||
* UserId - User identifier mapping |
|||
* NotificationName - Notification name mapping |
|||
* CreationTime - Creation time mapping |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Configure DbContext |
|||
```csharp |
|||
public class YourDbContext : AbpDbContext<YourDbContext> |
|||
{ |
|||
public DbSet<Notification> Notifications { get; set; } |
|||
public DbSet<NotificationSubscription> NotificationSubscriptions { get; set; } |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureNotifications(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Configure connection string |
|||
```json |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Server=localhost;Database=YourDb;Trusted_Connection=True" |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
* [Entity Framework Core Documentation](https://docs.microsoft.com/ef/core/) |
|||
@ -0,0 +1,72 @@ |
|||
# LINGYUN.Abp.Notifications.EntityFrameworkCore |
|||
|
|||
通知系统的EntityFrameworkCore模块,提供了通知系统的数据访问实现。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知实体映射配置 |
|||
* 通知仓储实现 |
|||
* 通知订阅仓储实现 |
|||
* 支持多数据库 |
|||
* 支持自定义仓储扩展 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsEntityFrameworkCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 实体映射 |
|||
|
|||
### NotificationEfCoreEntityTypeConfiguration |
|||
|
|||
* Notification - 通知实体映射 |
|||
* Id - 主键映射 |
|||
* NotificationName - 通知名称映射 |
|||
* Data - 通知数据映射 |
|||
* CreationTime - 创建时间映射 |
|||
* Type - 通知类型映射 |
|||
* Severity - 通知严重程度映射 |
|||
|
|||
### NotificationSubscriptionEfCoreEntityTypeConfiguration |
|||
|
|||
* NotificationSubscription - 通知订阅实体映射 |
|||
* UserId - 用户标识映射 |
|||
* NotificationName - 通知名称映射 |
|||
* CreationTime - 创建时间映射 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 配置DbContext |
|||
```csharp |
|||
public class YourDbContext : AbpDbContext<YourDbContext> |
|||
{ |
|||
public DbSet<Notification> Notifications { get; set; } |
|||
public DbSet<NotificationSubscription> NotificationSubscriptions { get; set; } |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureNotifications(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 配置连接字符串 |
|||
```json |
|||
{ |
|||
"ConnectionStrings": { |
|||
"Default": "Server=localhost;Database=YourDb;Trusted_Connection=True" |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
* [Entity Framework Core文档](https://docs.microsoft.com/ef/core/) |
|||
@ -0,0 +1,72 @@ |
|||
# LINGYUN.Abp.Notifications.HttpApi |
|||
|
|||
The HTTP API module of the notification system, providing REST API interfaces for the notification system. |
|||
|
|||
## Features |
|||
|
|||
* Notification management API |
|||
* Notification subscription API |
|||
* Notification status management API |
|||
* Support for API versioning |
|||
* Support for Swagger documentation |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsHttpApiModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## API Endpoints |
|||
|
|||
### NotificationController |
|||
|
|||
* GET /api/notifications/{id} - Get notification details |
|||
* GET /api/notifications - Get notification list |
|||
* DELETE /api/notifications/{id} - Delete notification |
|||
* PUT /api/notifications/{id}/read - Mark notification as read |
|||
* PUT /api/notifications/read - Mark all notifications as read |
|||
|
|||
### NotificationSubscriptionController |
|||
|
|||
* POST /api/notifications/subscriptions - Subscribe to notification |
|||
* DELETE /api/notifications/subscriptions - Unsubscribe from notification |
|||
* GET /api/notifications/subscribers - Get list of assignable subscribers |
|||
* GET /api/notifications/subscriptions - Get list of subscribed notifications |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Configure Startup |
|||
```csharp |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<YourHttpApiModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. API Call Examples |
|||
```bash |
|||
# Get notification list |
|||
curl -X GET "https://localhost:44300/api/notifications" |
|||
|
|||
# Subscribe to notification |
|||
curl -X POST "https://localhost:44300/api/notifications/subscriptions" \ |
|||
-H "Content-Type: application/json" \ |
|||
-d '{"notificationName":"YourNotification"}' |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
* [ASP.NET Core Documentation](https://docs.microsoft.com/aspnet/core) |
|||
@ -0,0 +1,72 @@ |
|||
# LINGYUN.Abp.Notifications.HttpApi |
|||
|
|||
通知系统的HTTP API模块,提供了通知系统的REST API接口。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 通知管理API |
|||
* 通知订阅API |
|||
* 通知状态管理API |
|||
* 支持API版本控制 |
|||
* 支持Swagger文档 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsHttpApiModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## API接口 |
|||
|
|||
### NotificationController |
|||
|
|||
* GET /api/notifications/{id} - 获取通知详情 |
|||
* GET /api/notifications - 获取通知列表 |
|||
* DELETE /api/notifications/{id} - 删除通知 |
|||
* PUT /api/notifications/{id}/read - 标记通知为已读 |
|||
* PUT /api/notifications/read - 标记所有通知为已读 |
|||
|
|||
### NotificationSubscriptionController |
|||
|
|||
* POST /api/notifications/subscriptions - 订阅通知 |
|||
* DELETE /api/notifications/subscriptions - 取消订阅通知 |
|||
* GET /api/notifications/subscribers - 获取可分配的订阅者列表 |
|||
* GET /api/notifications/subscriptions - 获取已订阅的通知列表 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 配置Startup |
|||
```csharp |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<YourHttpApiModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 调用API示例 |
|||
```bash |
|||
# 获取通知列表 |
|||
curl -X GET "https://localhost:44300/api/notifications" |
|||
|
|||
# 订阅通知 |
|||
curl -X POST "https://localhost:44300/api/notifications/subscriptions" \ |
|||
-H "Content-Type: application/json" \ |
|||
-d '{"notificationName":"YourNotification"}' |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
* [ASP.NET Core文档](https://docs.microsoft.com/aspnet/core) |
|||
@ -0,0 +1,106 @@ |
|||
# LINGYUN.Abp.Notifications.PushPlus |
|||
|
|||
PushPlus implementation of the notification module |
|||
|
|||
Enables applications to publish real-time notifications through PushPlus |
|||
|
|||
## Features |
|||
|
|||
* Support for multiple message types |
|||
* Text messages |
|||
* HTML messages |
|||
* Markdown messages |
|||
* Image messages |
|||
* Custom template messages |
|||
* Message callback support |
|||
* Custom callback URL support |
|||
* Message sending status callback support |
|||
* Multi-channel push support |
|||
* WeChat Official Account |
|||
* WeChat Work |
|||
* Email |
|||
* SMS |
|||
* WebHook |
|||
* Group message support |
|||
* Group push support |
|||
* Group management support |
|||
|
|||
## Module Reference |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsPushPlusModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```json |
|||
{ |
|||
"PushPlus": { |
|||
"Token": "Your PushPlus Token", |
|||
"DefaultChannel": "wechat", // Default push channel: wechat/webhook/mail/sms |
|||
"DefaultTemplate": "html", // Default message template: html/json/markdown/txt |
|||
"DefaultWebhook": "", // Default Webhook URL |
|||
"DefaultCallbackUrl": "" // Default callback URL |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Configure PushPlus Service |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpNotificationsPushPlusOptions>(options => |
|||
{ |
|||
options.Token = "Your PushPlus Token"; |
|||
options.DefaultChannel = "wechat"; |
|||
options.DefaultTemplate = "html"; |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
2. Send Notification |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly INotificationSender _notificationSender; |
|||
|
|||
public YourService(INotificationSender notificationSender) |
|||
{ |
|||
_notificationSender = notificationSender; |
|||
} |
|||
|
|||
public async Task SendNotificationAsync() |
|||
{ |
|||
var notificationData = new NotificationData(); |
|||
notificationData.TrySetData("title", "Message Title"); |
|||
notificationData.TrySetData("content", "Message Content"); |
|||
notificationData.SetWebhook("https://your-webhook.com"); |
|||
notificationData.SetCallbackUrl("https://your-callback.com"); |
|||
|
|||
await _notificationSender.SendNofiterAsync( |
|||
"YourNotification", |
|||
notificationData, |
|||
userIds: new[] { CurrentUser.Id } |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
1. Registration on the PushPlus platform and obtaining a Token is required before use. |
|||
2. Ensure the configured Token is valid and has sufficient permissions. |
|||
3. Callback URL must be accessible from the public internet. |
|||
4. Different channels may have different message format requirements. |
|||
5. Message sending depends on PushPlus API, ensure network connectivity is stable. |
|||
|
|||
## More Information |
|||
|
|||
* [PushPlus Documentation](http://www.pushplus.plus/doc/) |
|||
* [ABP Documentation](https://docs.abp.io) |
|||
@ -0,0 +1,88 @@ |
|||
# LINGYUN.Abp.Notifications.SignalR |
|||
|
|||
The SignalR module of the notification system, providing real-time notification functionality based on SignalR. |
|||
|
|||
## Features |
|||
|
|||
* Real-time notification push |
|||
* Notification Hub implementation |
|||
* Client connection management |
|||
* Support for group notifications |
|||
* Support for user online status management |
|||
|
|||
## Module References |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsSignalRModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```json |
|||
{ |
|||
"SignalR": { |
|||
"HubUrl": "/signalr-hubs/notifications", |
|||
"UseMessagePack": false |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Hub Definitions |
|||
|
|||
### NotificationHub |
|||
|
|||
* SubscribeToNotifications - Subscribe to notifications |
|||
* UnsubscribeFromNotifications - Unsubscribe from notifications |
|||
* GetNotifications - Get notification list |
|||
* MarkNotificationAsRead - Mark notification as read |
|||
* MarkAllNotificationsAsRead - Mark all notifications as read |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Server Configuration |
|||
```csharp |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddSignalR() |
|||
.AddMessagePackProtocol(); // Optional, use MessagePack protocol |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.UseEndpoints(endpoints => |
|||
{ |
|||
endpoints.MapHub<NotificationHub>("/signalr-hubs/notifications"); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Client Usage |
|||
```javascript |
|||
// Connect to notification hub |
|||
const connection = new signalR.HubConnectionBuilder() |
|||
.withUrl("/signalr-hubs/notifications") |
|||
.build(); |
|||
|
|||
// Listen for notifications |
|||
connection.on("ReceiveNotification", (notification) => { |
|||
console.log("Received new notification:", notification); |
|||
}); |
|||
|
|||
// Start connection |
|||
await connection.start(); |
|||
|
|||
// Subscribe to notifications |
|||
await connection.invoke("SubscribeToNotifications"); |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
* [SignalR Documentation](https://docs.microsoft.com/aspnet/core/signalr) |
|||
@ -0,0 +1,88 @@ |
|||
# LINGYUN.Abp.Notifications.SignalR |
|||
|
|||
通知系统的SignalR模块,提供了基于SignalR的实时通知功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 实时通知推送 |
|||
* 通知Hub实现 |
|||
* 客户端连接管理 |
|||
* 支持分组通知 |
|||
* 支持用户在线状态管理 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsSignalRModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置项 |
|||
|
|||
```json |
|||
{ |
|||
"SignalR": { |
|||
"HubUrl": "/signalr-hubs/notifications", |
|||
"UseMessagePack": false |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Hub定义 |
|||
|
|||
### NotificationHub |
|||
|
|||
* SubscribeToNotifications - 订阅通知 |
|||
* UnsubscribeFromNotifications - 取消订阅通知 |
|||
* GetNotifications - 获取通知列表 |
|||
* MarkNotificationAsRead - 标记通知为已读 |
|||
* MarkAllNotificationsAsRead - 标记所有通知为已读 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 服务端配置 |
|||
```csharp |
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddSignalR() |
|||
.AddMessagePackProtocol(); // 可选,使用MessagePack协议 |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.UseEndpoints(endpoints => |
|||
{ |
|||
endpoints.MapHub<NotificationHub>("/signalr-hubs/notifications"); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 客户端使用 |
|||
```javascript |
|||
// 连接到通知Hub |
|||
const connection = new signalR.HubConnectionBuilder() |
|||
.withUrl("/signalr-hubs/notifications") |
|||
.build(); |
|||
|
|||
// 监听通知 |
|||
connection.on("ReceiveNotification", (notification) => { |
|||
console.log("收到新通知:", notification); |
|||
}); |
|||
|
|||
// 启动连接 |
|||
await connection.start(); |
|||
|
|||
// 订阅通知 |
|||
await connection.invoke("SubscribeToNotifications"); |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [ABP文档](https://docs.abp.io) |
|||
* [SignalR文档](https://docs.microsoft.com/aspnet/core/signalr) |
|||
@ -0,0 +1,98 @@ |
|||
# LINGYUN.Abp.Notifications.Sms |
|||
|
|||
SMS implementation of notification publishing provider |
|||
|
|||
Most rewritten modules maintain the same name as the official modules and are distinguished by namespace, mainly because only a small part was rewritten or additional functionality was added. |
|||
If most of the module code is rewritten, or if it's a completely extended module, then it will have its own name. |
|||
|
|||
#### Note |
|||
|
|||
Custom sending methods can be implemented by implementing the ##ISmsNotificationSender## interface or overriding ##SmsNotificationSender## |
|||
|
|||
## Features |
|||
|
|||
* SMS notification sending |
|||
* SMS template support |
|||
* Support for multiple SMS service providers |
|||
* Support for SMS variable replacement |
|||
* Support for batch sending |
|||
|
|||
## Configuration |
|||
|
|||
* This configuration item will be removed in the next major SMS-related version |
|||
|
|||
```json |
|||
{ |
|||
"Notifications": { |
|||
"Sms": { |
|||
"TemplateParamsPrefix": "SMS template variable prefix" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsSmsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Implement SMS sending interface |
|||
```csharp |
|||
public class YourSmsNotificationSender : SmsNotificationSender |
|||
{ |
|||
public override async Task SendAsync(NotificationInfo notification) |
|||
{ |
|||
var templateParams = GetTemplateParams(notification); |
|||
await SmsService.SendAsync( |
|||
notification.UserPhoneNumber, |
|||
notification.Title, |
|||
templateParams |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Register SMS sending service |
|||
```csharp |
|||
Configure<AbpNotificationsSmsOptions>(options => |
|||
{ |
|||
options.TemplateParamsPrefix = "sms_"; // SMS template variable prefix |
|||
}); |
|||
``` |
|||
|
|||
3. Send SMS notification |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly INotificationSender _notificationSender; |
|||
|
|||
public YourService(INotificationSender notificationSender) |
|||
{ |
|||
_notificationSender = notificationSender; |
|||
} |
|||
|
|||
public async Task SendSmsNotificationAsync() |
|||
{ |
|||
await _notificationSender.SendNofiterAsync( |
|||
"YourNotification", |
|||
new NotificationData |
|||
{ |
|||
// SMS template parameters |
|||
["sms_code"] = "123456", |
|||
["sms_time"] = "5" |
|||
}, |
|||
userIds: new[] { CurrentUser.Id } |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [ABP Documentation](https://docs.abp.io) |
|||
* [SMS Service Documentation](https://docs.abp.io/en/abp/latest/SMS-Sending) |
|||
Loading…
Reference in new issue