4 changed files with 361 additions and 14 deletions
@ -0,0 +1,85 @@ |
|||
# LINGYUN.Abp.Notifications.WeChat.MiniProgram |
|||
|
|||
WeChat Mini Program notification publishing module, providing functionality to send subscription messages to users through WeChat Mini Program. |
|||
|
|||
## Features |
|||
|
|||
* WeChat Mini Program subscription message sending |
|||
* Support for custom message templates |
|||
* Support for multi-language messages |
|||
* Support for different environments (development, trial, release) |
|||
* Integration with ABP notification system |
|||
|
|||
## Module Reference |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsWeChatMiniProgramModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
> Note: This configuration will be removed in the next major WeChat-related version and merged into LINGYUN.Abp.WeChat.MiniProgram.AbpWeChatMiniProgramOptions |
|||
|
|||
```json |
|||
{ |
|||
"Notifications": { |
|||
"WeChat": { |
|||
"MiniProgram": { |
|||
"DefaultMsgPrefix": "", // Default message prefix |
|||
"DefaultTemplateId": "", // Default Mini Program template ID |
|||
"DefaultState": "developer", // Default Mini Program type: developer/trial/formal |
|||
"DefaultLanguage": "zh_CN" // Default Mini Program language |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
### Sending Notifications |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly INotificationPublisher _notificationPublisher; |
|||
|
|||
public YourService(INotificationPublisher notificationPublisher) |
|||
{ |
|||
_notificationPublisher = notificationPublisher; |
|||
} |
|||
|
|||
public async Task SendNotificationAsync() |
|||
{ |
|||
await _notificationPublisher.PublishAsync( |
|||
"WeChatMiniProgram.Notification", // Notification name |
|||
new NotificationData(), // Notification data |
|||
userIds: new[] { "userId" }, // Recipient user IDs |
|||
tenantIds: new[] { "tenantId" } // Tenant IDs |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### Custom Notification Handling |
|||
|
|||
```csharp |
|||
public class YourNotificationHandler : |
|||
INotificationHandler<WeChatMiniProgramNotification> |
|||
{ |
|||
public async Task HandleNotificationAsync( |
|||
WeChatMiniProgramNotification notification) |
|||
{ |
|||
// Handle notification |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Documentation |
|||
|
|||
* [Chinese Documentation](README.md) |
|||
* [WeChat Mini Program Subscribe Message Documentation](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html) |
|||
@ -1,37 +1,85 @@ |
|||
# LINGYUN.Abp.Notifications.WeChat.MiniProgram |
|||
|
|||
通知发布提供程序的微信小程序实现 |
|||
微信小程序通知发布模块,提供通过微信小程序向用户发送订阅消息的功能。 |
|||
|
|||
大部分重写的模块都和官方模块名称保持一致,通过命名空间区分,主要是只改写了一小部分或者增加额外的功能 |
|||
如果大部分模块代码都重写,或者完全就是扩展模块,才会定义自己的名字 |
|||
## 功能特性 |
|||
|
|||
#### 注意 |
|||
* 微信小程序订阅消息发送 |
|||
* 支持自定义消息模板 |
|||
* 支持多语言消息 |
|||
* 支持不同环境(开发版、体验版、正式版) |
|||
* 集成ABP通知系统 |
|||
|
|||
## 配置使用 |
|||
## 模块引用 |
|||
|
|||
* 此配置项将在下一个微信相关大版本移除,合并到 LINGYUN.Abp.WeChat.MiniProgram.AbpWeChatMiniProgramOptions |
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsWeChatMiniProgramModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
```json |
|||
## 配置项 |
|||
|
|||
> 注意:此配置项将在下一个微信相关大版本移除,合并到 LINGYUN.Abp.WeChat.MiniProgram.AbpWeChatMiniProgramOptions |
|||
|
|||
```json |
|||
{ |
|||
"Notifications": { |
|||
"WeChat": { |
|||
"MiniProgram": { |
|||
"DefaultMsgPrefix": "默认消息头部标记", |
|||
"DefaultTemplateId": "默认小程序模板", |
|||
"DefaultState": "默认跳转小程序类型", |
|||
"DefaultLanguage": "默认小程序语言" |
|||
"DefaultMsgPrefix": "", // 默认消息头部标记 |
|||
"DefaultTemplateId": "", // 默认小程序模板ID |
|||
"DefaultState": "developer", // 默认跳转小程序类型:developer(开发版)、trial(体验版)、formal(正式版) |
|||
"DefaultLanguage": "zh_CN" // 默认小程序语言 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 使用方式 |
|||
|
|||
### 发送通知 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly INotificationPublisher _notificationPublisher; |
|||
|
|||
public YourService(INotificationPublisher notificationPublisher) |
|||
{ |
|||
_notificationPublisher = notificationPublisher; |
|||
} |
|||
|
|||
public async Task SendNotificationAsync() |
|||
{ |
|||
await _notificationPublisher.PublishAsync( |
|||
"WeChatMiniProgram.Notification", // 通知名称 |
|||
new NotificationData(), // 通知数据 |
|||
userIds: new[] { "userId" }, // 接收用户ID列表 |
|||
tenantIds: new[] { "tenantId" } // 租户ID列表 |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 自定义通知处理 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsWeChatMiniProgramModule))] |
|||
public class YouProjectModule : AbpModule |
|||
public class YourNotificationHandler : |
|||
INotificationHandler<WeChatMiniProgramNotification> |
|||
{ |
|||
// other |
|||
public async Task HandleNotificationAsync( |
|||
WeChatMiniProgramNotification notification) |
|||
{ |
|||
// 处理通知 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 更多文档 |
|||
|
|||
* [微信小程序通知发布模块文档](README.EN.md) |
|||
* [微信小程序订阅消息开发文档](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html) |
|||
|
|||
@ -0,0 +1,107 @@ |
|||
# LINGYUN.Abp.Notifications.WeChat.Work |
|||
|
|||
WeChat Work notification publishing module, providing functionality to send messages to users through WeChat Work applications. |
|||
|
|||
## Features |
|||
|
|||
* Support for multiple message types |
|||
* Text messages |
|||
* Text card messages |
|||
* Markdown messages |
|||
* Flexible message targeting |
|||
* Send to specific users |
|||
* Send to specific departments |
|||
* Send to specific tags |
|||
* Send to multiple applications |
|||
* Multi-language support |
|||
* Localized message content |
|||
* Multi-language titles and descriptions |
|||
* Feature toggle control |
|||
* Message sending controlled by feature switches |
|||
* Extensibility |
|||
* Custom notification definitions |
|||
* Custom message handling |
|||
|
|||
## Module Reference |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsWeChatWorkModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
### 1. Basic Configuration |
|||
|
|||
Message sending requires configuring applications in the WeChat Work backend and obtaining the corresponding application ID (AgentId). |
|||
|
|||
### 2. Notification Definition Configuration |
|||
|
|||
```csharp |
|||
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationDefinitionContext context) |
|||
{ |
|||
var notification = context.Create( |
|||
name: "App.Notification.Test", |
|||
displayName: L("TestNotification")) |
|||
.WithAgentId("1000001") // Set application ID |
|||
.WithParty("1|2|3") // Set receiving departments |
|||
.WithTag("TagId1|TagId2") // Set receiving tags |
|||
.WithAllAgent(); // Send to all applications |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 3. Sending Notifications |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly INotificationPublisher _notificationPublisher; |
|||
|
|||
public YourService(INotificationPublisher notificationPublisher) |
|||
{ |
|||
_notificationPublisher = notificationPublisher; |
|||
} |
|||
|
|||
public async Task SendNotificationAsync() |
|||
{ |
|||
var notificationData = new NotificationData(); |
|||
|
|||
// Set message content |
|||
notificationData.TrySetData("title", "Message Title"); |
|||
notificationData.TrySetData("message", "Message Content"); |
|||
notificationData.TrySetData("description", "Message Description"); |
|||
|
|||
// Set sending targets |
|||
notificationData.SetAgentId("1000001"); // Set application ID |
|||
notificationData.SetParty("1|2|3"); // Set receiving departments |
|||
notificationData.SetTag("TagId1|TagId2"); // Set receiving tags |
|||
notificationData.WithAllAgent(); // Send to all applications |
|||
|
|||
await _notificationPublisher.PublishAsync( |
|||
"App.Notification.Test", // Notification name |
|||
notificationData, // Notification data |
|||
userIds: new[] { "userId" }, // Recipient user IDs |
|||
tenantIds: new[] { "tenantId" } // Tenant IDs |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
1. Ensure WeChat Work application is properly configured, including application ID and relevant permissions. |
|||
2. Department IDs and tag IDs must match those configured in the WeChat Work backend. |
|||
3. Multiple recipients (departments/tags) are separated by '|', with a maximum of 100. |
|||
4. Using `WithAllAgent()` will send messages to all configured applications. |
|||
5. Message sending depends on WeChat Work API, ensure network connectivity is stable. |
|||
|
|||
## More Documentation |
|||
|
|||
* [Chinese Documentation](README.md) |
|||
* [WeChat Work Application Message Development Documentation](https://developer.work.weixin.qq.com/document/path/90236) |
|||
@ -0,0 +1,107 @@ |
|||
# LINGYUN.Abp.Notifications.WeChat.Work |
|||
|
|||
企业微信通知发布模块,提供通过企业微信应用向用户发送消息的功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 支持多种消息类型 |
|||
* 文本消息 |
|||
* 文本卡片消息 |
|||
* Markdown消息 |
|||
* 灵活的消息发送目标 |
|||
* 支持发送到指定用户 |
|||
* 支持发送到指定部门 |
|||
* 支持发送到指定标签 |
|||
* 支持发送到多个应用 |
|||
* 多语言支持 |
|||
* 支持本地化消息内容 |
|||
* 支持多语言标题和描述 |
|||
* 特性开关控制 |
|||
* 支持通过功能开关控制消息发送 |
|||
* 扩展性 |
|||
* 支持自定义通知定义 |
|||
* 支持自定义消息处理 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpNotificationsWeChatWorkModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置说明 |
|||
|
|||
### 1. 基础配置 |
|||
|
|||
消息发送需要在企业微信后台配置应用,并获取相应的应用ID(AgentId)。 |
|||
|
|||
### 2. 通知定义配置 |
|||
|
|||
```csharp |
|||
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider |
|||
{ |
|||
public override void Define(INotificationDefinitionContext context) |
|||
{ |
|||
var notification = context.Create( |
|||
name: "App.Notification.Test", |
|||
displayName: L("TestNotification")) |
|||
.WithAgentId("1000001") // 设置应用ID |
|||
.WithParty("1|2|3") // 设置接收部门 |
|||
.WithTag("TagId1|TagId2") // 设置接收标签 |
|||
.WithAllAgent(); // 发送到所有应用 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 3. 发送通知 |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly INotificationPublisher _notificationPublisher; |
|||
|
|||
public YourService(INotificationPublisher notificationPublisher) |
|||
{ |
|||
_notificationPublisher = notificationPublisher; |
|||
} |
|||
|
|||
public async Task SendNotificationAsync() |
|||
{ |
|||
var notificationData = new NotificationData(); |
|||
|
|||
// 设置消息内容 |
|||
notificationData.TrySetData("title", "消息标题"); |
|||
notificationData.TrySetData("message", "消息内容"); |
|||
notificationData.TrySetData("description", "消息描述"); |
|||
|
|||
// 设置发送目标 |
|||
notificationData.SetAgentId("1000001"); // 设置应用ID |
|||
notificationData.SetParty("1|2|3"); // 设置接收部门 |
|||
notificationData.SetTag("TagId1|TagId2"); // 设置接收标签 |
|||
notificationData.WithAllAgent(); // 发送到所有应用 |
|||
|
|||
await _notificationPublisher.PublishAsync( |
|||
"App.Notification.Test", // 通知名称 |
|||
notificationData, // 通知数据 |
|||
userIds: new[] { "userId" }, // 接收用户ID列表 |
|||
tenantIds: new[] { "tenantId" } // 租户ID列表 |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 注意事项 |
|||
|
|||
1. 发送消息时需要确保企业微信应用配置正确,包括应用ID和相关权限。 |
|||
2. 部门ID和标签ID需要与企业微信后台配置的一致。 |
|||
3. 多个接收者(部门/标签)使用'|'分隔,最多支持100个。 |
|||
4. 使用 `WithAllAgent()` 时会向所有配置的应用发送消息。 |
|||
5. 消息发送依赖于企业微信API,需要确保网络连接正常。 |
|||
|
|||
## 更多文档 |
|||
|
|||
* [English Documentation](README.EN.md) |
|||
* [企业微信应用消息开发文档](https://developer.work.weixin.qq.com/document/path/90236) |
|||
Loading…
Reference in new issue