committed by
GitHub
735 changed files with 79920 additions and 16136 deletions
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,61 @@ |
|||
# LINGYUN.Abp.AuditLogging.Elasticsearch |
|||
|
|||
[简体中文](./README.md) | English |
|||
|
|||
Elasticsearch implementation for the audit logging module. |
|||
|
|||
## Features |
|||
|
|||
* ElasticsearchAuditLogManager - Implements IAuditLogManager, managing audit logs with Elasticsearch |
|||
* ElasticsearchSecurityLogManager - Implements ISecurityLogManager, managing security logs with Elasticsearch |
|||
|
|||
## Module Dependencies |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuditLoggingElasticsearchModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
* AbpAuditLoggingElasticsearchOptions.IndexPrefix - Index prefix, default is 'auditlogging' |
|||
* AbpAuditLoggingElasticsearchOptions.IndexSettings - Elasticsearch index settings |
|||
|
|||
## Multi-tenancy Support |
|||
|
|||
When integrated with the tenant module, the index will switch based on the tenant: |
|||
- For tenant-specific data: `{prefix}-{index}-{tenantId}` |
|||
- For host data: `{prefix}-{index}` |
|||
|
|||
## appsettings.json |
|||
|
|||
```json |
|||
{ |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "auditlogging" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Features |
|||
|
|||
1. Audit Log Management |
|||
- Store and retrieve audit logs in Elasticsearch |
|||
- Support for entity change tracking |
|||
- Flexible querying with various filters |
|||
- Support for extra properties |
|||
|
|||
2. Security Log Management |
|||
- Store and retrieve security logs in Elasticsearch |
|||
- Support for security-related events tracking |
|||
- Comprehensive querying capabilities |
|||
|
|||
3. Index Management |
|||
- Automatic index initialization |
|||
- Support for custom index settings |
|||
- Multi-tenant index isolation |
|||
@ -0,0 +1,48 @@ |
|||
# LINGYUN.Abp.AuditLogging.EntityFrameworkCore |
|||
|
|||
[简体中文](./README.md) | English |
|||
|
|||
EntityFrameworkCore implementation for the audit logging module. This module serves as a bridge, with the actual implementation delegated to the official ABP modules. |
|||
|
|||
## Features |
|||
|
|||
* AuditLogManager - Implements IAuditLogManager, audit logs are managed by the Volo.Abp.AuditLogging module |
|||
* SecurityLogManager - Implements ISecurityLogManager, security logs are managed by the Volo.Abp.Identity module |
|||
|
|||
## Module Dependencies |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuditLoggingEntityFrameworkCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
Please follow the configuration guidelines in the Volo.Abp.AuditLogging and Volo.Abp.Identity modules. |
|||
|
|||
## Database Configuration |
|||
|
|||
Configure the connection strings in your appsettings.json: |
|||
|
|||
```json |
|||
{ |
|||
"ConnectionStrings": { |
|||
"AbpIdentity": "Server=127.0.0.1;Database=Identity;User Id=root;Password=*", |
|||
"AbpAuditLogging": "Server=127.0.0.1;Database=AuditLogging;User Id=root;Password=*", |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Features |
|||
|
|||
1. Audit Log Management |
|||
- Store and retrieve audit logs using EntityFrameworkCore |
|||
- Support for entity change tracking |
|||
- Integration with ABP's identity system for security logs |
|||
|
|||
2. Auto Mapping |
|||
- Automatic mapping configuration for audit log entities |
|||
- Supports custom mapping profiles through AbpAutoMapperOptions |
|||
@ -0,0 +1,59 @@ |
|||
# LINGYUN.Abp.AuditLogging |
|||
|
|||
Audit logging core module, providing basic functionality and interface definitions for audit logging. |
|||
|
|||
[简体中文](./README.md) |
|||
|
|||
## Features |
|||
|
|||
* Audit logging infrastructure |
|||
* Audit log repository interface definitions |
|||
* Audit log manager interface definitions |
|||
* Support for ignoring specific types in audit logging |
|||
|
|||
## Module Dependencies |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuditLoggingModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Auditing": { |
|||
"IsEnabled": true, // Enable or disable audit logging |
|||
"HideErrors": true, // Hide error information in audit logs |
|||
"IsEnabledForAnonymousUsers": true, // Enable audit logging for anonymous users |
|||
"IsEnabledForGetRequests": false, // Enable audit logging for GET requests |
|||
"ApplicationName": null // Application name |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Reference the module |
|||
2. Configure audit logging options |
|||
3. Implement an audit log storage provider (e.g., EntityFrameworkCore or Elasticsearch) |
|||
|
|||
## Advanced Features |
|||
|
|||
### Ignoring Specific Types |
|||
|
|||
By default, the module ignores audit logs for the following types: |
|||
* CancellationToken |
|||
* CancellationTokenSource |
|||
|
|||
You can add more types to ignore through configuration: |
|||
|
|||
```csharp |
|||
Configure<AbpAuditingOptions>(options => |
|||
{ |
|||
options.IgnoredTypes.AddIfNotContains(typeof(YourType)); |
|||
}); |
|||
``` |
|||
@ -0,0 +1,59 @@ |
|||
# LINGYUN.Abp.AuditLogging |
|||
|
|||
审计日志核心模块,提供审计日志的基础功能和接口定义。 |
|||
|
|||
[English](./README.EN.md) |
|||
|
|||
## 功能特性 |
|||
|
|||
* 审计日志基础设施 |
|||
* 审计日志仓储接口定义 |
|||
* 审计日志管理器接口定义 |
|||
* 支持忽略特定类型的审计日志记录 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuditLoggingModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置项 |
|||
|
|||
```json |
|||
{ |
|||
"Auditing": { |
|||
"IsEnabled": true, // 是否启用审计日志 |
|||
"HideErrors": true, // 是否隐藏错误信息 |
|||
"IsEnabledForAnonymousUsers": true, // 是否为匿名用户启用审计日志 |
|||
"IsEnabledForGetRequests": false, // 是否为GET请求启用审计日志 |
|||
"ApplicationName": null // 应用程序名称 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 引用模块 |
|||
2. 配置审计日志选项 |
|||
3. 实现审计日志存储提供者(例如:EntityFrameworkCore或Elasticsearch) |
|||
|
|||
## 高级功能 |
|||
|
|||
### 忽略特定类型 |
|||
|
|||
默认情况下,模块会忽略以下类型的审计日志: |
|||
* CancellationToken |
|||
* CancellationTokenSource |
|||
|
|||
你可以通过配置添加更多需要忽略的类型: |
|||
|
|||
```csharp |
|||
Configure<AbpAuditingOptions>(options => |
|||
{ |
|||
options.IgnoredTypes.AddIfNotContains(typeof(YourType)); |
|||
}); |
|||
``` |
|||
@ -0,0 +1,113 @@ |
|||
# LINGYUN.Abp 审计模块 |
|||
|
|||
## 模块概述 |
|||
|
|||
审计模块提供了全面的日志记录和审计功能,支持多种存储方式和高度可配置的审计选项。 |
|||
|
|||
## 功能特性 |
|||
|
|||
### 核心功能 |
|||
|
|||
- 审计日志基础设施 |
|||
- 审计日志仓储接口定义 |
|||
- 审计日志管理器接口定义 |
|||
- 支持忽略特定类型的审计日志记录 |
|||
|
|||
### 存储支持 |
|||
|
|||
- EntityFrameworkCore 实现 |
|||
- Elasticsearch 实现 |
|||
|
|||
## 模块引用 |
|||
|
|||
### 核心模块 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuditLoggingModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
### EntityFrameworkCore 模块 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuditLoggingEntityFrameworkCoreModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
### Elasticsearch 模块 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuditLoggingElasticsearchModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置选项 |
|||
|
|||
### 审计日志配置 |
|||
|
|||
```json |
|||
{ |
|||
"Auditing": { |
|||
"IsEnabled": true, // 是否启用审计日志 |
|||
"HideErrors": true, // 是否隐藏错误信息 |
|||
"IsEnabledForAnonymousUsers": true, // 是否为匿名用户启用审计日志 |
|||
"IsEnabledForGetRequests": false, // 是否为GET请求启用审计日志 |
|||
"ApplicationName": null // 应用程序名称 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### Elasticsearch 配置 |
|||
|
|||
```json |
|||
{ |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "auditlogging" // 索引前缀 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 数据库连接配置 |
|||
|
|||
```json |
|||
{ |
|||
"ConnectionStrings": { |
|||
"AbpIdentity": "Server=127.0.0.1;Database=Identity;User Id=root;Password=*", |
|||
"AbpAuditLogging": "Server=127.0.0.1;Database=AuditLogging;User Id=root;Password=*" |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 高级功能 |
|||
|
|||
### 忽略特定类型 |
|||
|
|||
默认情况下,模块会忽略以下类型的审计日志: |
|||
|
|||
- CancellationToken |
|||
- CancellationTokenSource |
|||
|
|||
你可以通过配置添加更多需要忽略的类型: |
|||
|
|||
```csharp |
|||
Configure<AbpAuditingOptions>(options => |
|||
{ |
|||
options.IgnoredTypes.AddIfNotContains(typeof(YourType)); |
|||
}); |
|||
``` |
|||
|
|||
## 特殊说明 |
|||
|
|||
- Elasticsearch 实现支持跨租户,将根据租户自动切换索引 |
|||
- EntityFrameworkCore 实现主要作为桥梁,具体实现交由 Abp 官方模块管理 |
|||
@ -0,0 +1,64 @@ |
|||
# LINGYUN.Abp.Authentication.QQ |
|||
|
|||
QQ Connect authentication module, integrating QQ login functionality into ABP applications. |
|||
|
|||
## Features |
|||
|
|||
* QQ OAuth2.0 authentication |
|||
* Support for both mobile and PC login |
|||
* Retrieve basic QQ user information (nickname, gender, avatar, etc.) |
|||
* Integration with ABP identity system |
|||
|
|||
## Module Dependencies |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuthenticationQQModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Authentication": { |
|||
"QQ": { |
|||
"AppId": "Your QQ Connect AppId", |
|||
"AppKey": "Your QQ Connect AppKey", |
|||
"IsMobile": false, // Enable mobile login page |
|||
"ClaimsIssuer": "connect.qq.com", // Optional, defaults to connect.qq.com |
|||
"CallbackPath": "/signin-qq", // Optional, defaults to /signin-qq |
|||
"Scope": ["get_user_info"] // Optional, defaults to get_user_info |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Configure QQ Connect Parameters |
|||
* Apply for an application on QQ Connect platform to get AppId and AppKey |
|||
* Configure AppId and AppKey in appsettings.json |
|||
|
|||
2. Add QQ Login |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAuthentication() |
|||
.AddQQConnect(); // Add QQ login support |
|||
} |
|||
``` |
|||
|
|||
## Retrieved User Information |
|||
|
|||
* OpenId - Unique QQ user identifier |
|||
* NickName - User's nickname |
|||
* Gender - User's gender |
|||
* AvatarUrl - User's avatar URL |
|||
|
|||
## More Information |
|||
|
|||
* [QQ Connect Documentation](https://wiki.connect.qq.com/) |
|||
* [ABP Authentication Documentation](https://docs.abp.io/en/abp/latest/Authentication) |
|||
@ -0,0 +1,64 @@ |
|||
# LINGYUN.Abp.Authentication.QQ |
|||
|
|||
QQ互联认证模块,集成QQ登录功能到ABP应用程序。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* QQ OAuth2.0认证 |
|||
* 支持移动端和PC端登录 |
|||
* 获取QQ用户基本信息(昵称、性别、头像等) |
|||
* 支持与ABP身份系统集成 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuthenticationQQModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置项 |
|||
|
|||
```json |
|||
{ |
|||
"Authentication": { |
|||
"QQ": { |
|||
"AppId": "你的QQ互联AppId", |
|||
"AppKey": "你的QQ互联AppKey", |
|||
"IsMobile": false, // 是否启用移动端登录页面 |
|||
"ClaimsIssuer": "connect.qq.com", // 可选,默认为 connect.qq.com |
|||
"CallbackPath": "/signin-qq", // 可选,默认为 /signin-qq |
|||
"Scope": ["get_user_info"] // 可选,默认为 get_user_info |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 配置QQ互联参数 |
|||
* 在QQ互联平台申请应用,获取AppId和AppKey |
|||
* 在appsettings.json中配置AppId和AppKey |
|||
|
|||
2. 添加QQ登录 |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAuthentication() |
|||
.AddQQConnect(); // 添加QQ登录支持 |
|||
} |
|||
``` |
|||
|
|||
## 获取的用户信息 |
|||
|
|||
* OpenId - QQ用户唯一标识 |
|||
* NickName - 用户昵称 |
|||
* Gender - 用户性别 |
|||
* AvatarUrl - 用户头像URL |
|||
|
|||
## 更多信息 |
|||
|
|||
* [QQ互联文档](https://wiki.connect.qq.com/) |
|||
* [ABP认证文档](https://docs.abp.io/en/abp/latest/Authentication) |
|||
@ -0,0 +1,81 @@ |
|||
# LINGYUN.Abp.Authentication.WeChat |
|||
|
|||
WeChat Official Account authentication module, integrating WeChat Official Account login functionality into ABP applications. |
|||
|
|||
## Features |
|||
|
|||
* WeChat Official Account OAuth2.0 authentication |
|||
* Retrieve WeChat user information (nickname, gender, region, avatar, etc.) |
|||
* Support for UnionId mechanism, connecting Official Account and Mini Program account systems |
|||
* Support for WeChat server message verification |
|||
* Integration with ABP identity system |
|||
|
|||
## Module Dependencies |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuthenticationWeChatModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Authentication": { |
|||
"WeChat": { |
|||
"AppId": "Your WeChat Official Account AppId", |
|||
"AppSecret": "Your WeChat Official Account AppSecret", |
|||
"ClaimsIssuer": "WeChat", // Optional, defaults to WeChat |
|||
"CallbackPath": "/signin-wechat", // Optional, defaults to /signin-wechat |
|||
"Scope": ["snsapi_login", "snsapi_userinfo"], // Optional, defaults to snsapi_login and snsapi_userinfo |
|||
"QrConnect": { |
|||
"Enabled": false, // Enable PC-side QR code login |
|||
"Endpoint": "https://open.weixin.qq.com/connect/qrconnect" // PC-side QR code login endpoint |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Configure WeChat Official Account Parameters |
|||
* Register an Official Account on WeChat Official Account Platform to get AppId and AppSecret |
|||
* Configure AppId and AppSecret in appsettings.json |
|||
|
|||
2. Add WeChat Login |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAuthentication() |
|||
.AddWeChat(); // Add WeChat login support |
|||
} |
|||
``` |
|||
|
|||
3. Enable WeChat Server Message Verification (Optional) |
|||
```csharp |
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.UseWeChatSignature(); // Enable WeChat server message verification middleware |
|||
} |
|||
``` |
|||
|
|||
## Retrieved User Information |
|||
|
|||
* OpenId - Unique WeChat user identifier |
|||
* UnionId - WeChat Open Platform unique identifier (requires binding to Open Platform) |
|||
* NickName - User's nickname |
|||
* Sex - User's gender |
|||
* Country - User's country |
|||
* Province - User's province |
|||
* City - User's city |
|||
* AvatarUrl - User's avatar URL |
|||
* Privilege - User's privilege information |
|||
|
|||
## More Information |
|||
|
|||
* [WeChat Official Account Platform Documentation](https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html) |
|||
* [ABP Authentication Documentation](https://docs.abp.io/en/abp/latest/Authentication) |
|||
@ -0,0 +1,81 @@ |
|||
# LINGYUN.Abp.Authentication.WeChat |
|||
|
|||
微信公众号认证模块,集成微信公众号登录功能到ABP应用程序。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 微信公众号OAuth2.0认证 |
|||
* 支持获取微信用户基本信息(昵称、性别、地区、头像等) |
|||
* 支持UnionId机制,打通公众号与小程序账号体系 |
|||
* 支持微信服务器消息验证 |
|||
* 支持与ABP身份系统集成 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuthenticationWeChatModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 配置项 |
|||
|
|||
```json |
|||
{ |
|||
"Authentication": { |
|||
"WeChat": { |
|||
"AppId": "你的微信公众号AppId", |
|||
"AppSecret": "你的微信公众号AppSecret", |
|||
"ClaimsIssuer": "WeChat", // 可选,默认为 WeChat |
|||
"CallbackPath": "/signin-wechat", // 可选,默认为 /signin-wechat |
|||
"Scope": ["snsapi_login", "snsapi_userinfo"], // 可选,默认包含 snsapi_login 和 snsapi_userinfo |
|||
"QrConnect": { |
|||
"Enabled": false, // 是否启用PC端扫码登录 |
|||
"Endpoint": "https://open.weixin.qq.com/connect/qrconnect" // PC端扫码登录地址 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 配置微信公众号参数 |
|||
* 在微信公众平台申请公众号,获取AppId和AppSecret |
|||
* 在appsettings.json中配置AppId和AppSecret |
|||
|
|||
2. 添加微信登录 |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAuthentication() |
|||
.AddWeChat(); // 添加微信登录支持 |
|||
} |
|||
``` |
|||
|
|||
3. 启用微信服务器消息验证(可选) |
|||
```csharp |
|||
public void Configure(IApplicationBuilder app) |
|||
{ |
|||
app.UseWeChatSignature(); // 启用微信服务器消息验证中间件 |
|||
} |
|||
``` |
|||
|
|||
## 获取的用户信息 |
|||
|
|||
* OpenId - 微信用户唯一标识 |
|||
* UnionId - 微信开放平台唯一标识(需要绑定开放平台) |
|||
* NickName - 用户昵称 |
|||
* Sex - 用户性别 |
|||
* Country - 国家 |
|||
* Province - 省份 |
|||
* City - 城市 |
|||
* AvatarUrl - 用户头像URL |
|||
* Privilege - 用户特权信息 |
|||
|
|||
## 更多信息 |
|||
|
|||
* [微信公众平台开发文档](https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html) |
|||
* [ABP认证文档](https://docs.abp.io/en/abp/latest/Authentication) |
|||
@ -0,0 +1,99 @@ |
|||
# LINGYUN.Abp.Authentication 认证模块 |
|||
|
|||
本模块提供第三方社交登录认证功能,目前支持 QQ 和微信公众号登录,并与 ABP 身份系统深度集成。 |
|||
|
|||
## 模块概述 |
|||
|
|||
认证模块包含两个主要子模块: |
|||
|
|||
1. **QQ 互联认证模块** |
|||
|
|||
- 支持 QQ OAuth2.0 认证 |
|||
- 适用于移动端和 PC 端登录 |
|||
- 获取用户基本信息(昵称、性别、头像等) |
|||
|
|||
2. **微信公众号认证模块** |
|||
- 支持微信公众号 OAuth2.0 认证 |
|||
- 获取用户详细信息(昵称、性别、地区、头像等) |
|||
- 支持 UnionId 机制,打通公众号与小程序账号体系 |
|||
|
|||
## 功能特性 |
|||
|
|||
- 第三方社交账号登录 |
|||
- 获取用户基本信息 |
|||
- 与 ABP 身份系统无缝集成 |
|||
- 灵活的配置选项 |
|||
- 支持多种登录场景(移动端、PC 端) |
|||
|
|||
## 快速开始 |
|||
|
|||
### 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn( |
|||
typeof(AbpAuthenticationQQModule), |
|||
typeof(AbpAuthenticationWeChatModule) |
|||
)] |
|||
public class YourProjectModule : AbpModule |
|||
{ |
|||
// 其他配置 |
|||
} |
|||
``` |
|||
|
|||
### 配置示例 |
|||
|
|||
在 `appsettings.json` 中配置第三方登录参数: |
|||
|
|||
```json |
|||
{ |
|||
"Authentication": { |
|||
"QQ": { |
|||
"AppId": "你的QQ互联AppId", |
|||
"AppKey": "你的QQ互联AppKey" |
|||
}, |
|||
"WeChat": { |
|||
"AppId": "你的微信公众号AppId", |
|||
"AppSecret": "你的微信公众号AppSecret" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 添加登录支持 |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAuthentication() |
|||
.AddQQConnect() // 添加QQ登录 |
|||
.AddWeChat(); // 添加微信登录 |
|||
} |
|||
``` |
|||
|
|||
## 支持的用户信息 |
|||
|
|||
### QQ 登录获取信息 |
|||
|
|||
- OpenId - QQ 用户唯一标识 |
|||
- NickName - 用户昵称 |
|||
- Gender - 用户性别 |
|||
- AvatarUrl - 用户头像 URL |
|||
|
|||
### 微信登录获取信息 |
|||
|
|||
- OpenId - 微信用户唯一标识 |
|||
- UnionId - 微信开放平台唯一标识 |
|||
- NickName - 用户昵称 |
|||
- Sex - 用户性别 |
|||
- Country, Province, City - 地理信息 |
|||
- AvatarUrl - 用户头像 URL |
|||
|
|||
## 参考文档 |
|||
|
|||
- [QQ 互联文档](https://wiki.connect.qq.com/) |
|||
- [微信公众平台开发文档](https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html) |
|||
- [ABP 认证文档](https://docs.abp.io/en/abp/latest/Authentication) |
|||
|
|||
## 许可证 |
|||
|
|||
遵循项目的开源许可证 |
|||
@ -0,0 +1,73 @@ |
|||
# LINGYUN.Abp.Authorization.OrganizationUnits |
|||
|
|||
Organization Unit Authorization Module, providing organization unit-based permission validation functionality. |
|||
|
|||
## Features |
|||
|
|||
* Support for organization unit-based permission validation |
|||
* Provides Organization Unit Permission Value Provider (OrganizationUnitPermissionValueProvider) |
|||
* Support for multiple organization unit permission validation |
|||
* Integration with ABP permission system |
|||
* Organization Unit Claim type extensions |
|||
* Current user organization unit query extensions |
|||
|
|||
## Module Reference |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuthorizationOrganizationUnitsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Configure Permission Provider |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpPermissionOptions>(options => |
|||
{ |
|||
options.ValueProviders.Add<OrganizationUnitPermissionValueProvider>(); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
2. Get Current User's Organization Units |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ICurrentUser _currentUser; |
|||
|
|||
public YourService(ICurrentUser currentUser) |
|||
{ |
|||
_currentUser = currentUser; |
|||
} |
|||
|
|||
public void YourMethod() |
|||
{ |
|||
var organizationUnits = _currentUser.FindOrganizationUnits(); |
|||
// Process business logic with organization units |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. Get Organization Units from ClaimsPrincipal |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
public void YourMethod(ClaimsPrincipal principal) |
|||
{ |
|||
var organizationUnits = principal.FindOrganizationUnits(); |
|||
// Process business logic with organization units |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Resources |
|||
|
|||
* [GitHub Repository](https://github.com/colinin/abp-next-admin) |
|||
* [Sample Application](https://github.com/colinin/abp-next-admin/tree/master/aspnet-core/services/LY.MicroService.Applications.Single) |
|||
|
|||
[简体中文](./README.md) |
|||
@ -0,0 +1,73 @@ |
|||
# LINGYUN.Abp.Authorization.OrganizationUnits |
|||
|
|||
组织单元权限验证模块,提供基于组织单元的权限验证功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 支持基于组织单元的权限验证 |
|||
* 提供组织单元权限值提供者(OrganizationUnitPermissionValueProvider) |
|||
* 支持多组织单元权限验证 |
|||
* 集成ABP权限系统 |
|||
* 提供组织单元Claim类型扩展 |
|||
* 支持当前用户组织单元查询扩展 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAuthorizationOrganizationUnitsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 配置权限提供者 |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpPermissionOptions>(options => |
|||
{ |
|||
options.ValueProviders.Add<OrganizationUnitPermissionValueProvider>(); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
2. 获取当前用户的组织单元 |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ICurrentUser _currentUser; |
|||
|
|||
public YourService(ICurrentUser currentUser) |
|||
{ |
|||
_currentUser = currentUser; |
|||
} |
|||
|
|||
public void YourMethod() |
|||
{ |
|||
var organizationUnits = _currentUser.FindOrganizationUnits(); |
|||
// 使用组织单元进行业务处理 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. 从ClaimsPrincipal获取组织单元 |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
public void YourMethod(ClaimsPrincipal principal) |
|||
{ |
|||
var organizationUnits = principal.FindOrganizationUnits(); |
|||
// 使用组织单元进行业务处理 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 更多资源 |
|||
|
|||
* [GitHub仓库](https://github.com/colinin/abp-next-admin) |
|||
* [示例应用程序](https://github.com/colinin/abp-next-admin/tree/master/aspnet-core/services/LY.MicroService.Applications.Single) |
|||
|
|||
[English](./README.EN.md) |
|||
@ -0,0 +1,50 @@ |
|||
# 基于ABP CLI的扩展工具集 |
|||
|
|||
提供快速创建模板项目、生成JavaScript库命令等更多功能。 |
|||
|
|||
## 开始使用 |
|||
|
|||
```shell |
|||
dotnet tool install --global LINGYUN.Abp.Cli |
|||
``` |
|||
|
|||
## 使用方法 |
|||
|
|||
```shell |
|||
使用方法: |
|||
|
|||
labp <command> <target> [options] |
|||
|
|||
命令列表: |
|||
|
|||
> help: 显示命令行帮助。使用 ` labp help <command> ` 获取详细帮助 |
|||
> create: 基于自定义的ABP启动模板生成新的解决方案 |
|||
> generate-proxy: 生成客户端服务代理和DTO以消费HTTP API |
|||
> generate-view: 从HTTP API代理生成视图代码 |
|||
|
|||
获取命令的详细帮助: |
|||
|
|||
labp help <command> |
|||
``` |
|||
|
|||
## 功能特性 |
|||
|
|||
* 支持生成TypeScript客户端代理代码 |
|||
- Axios HTTP客户端 |
|||
- Vben Admin集成 |
|||
- UniApp集成 |
|||
* 支持生成Flutter客户端代理代码 |
|||
- Dio HTTP客户端 |
|||
- REST服务集成 |
|||
* 支持生成视图代码 |
|||
- Vben Admin视图模板 |
|||
- Flutter GetX视图模板 |
|||
* 自定义ABP启动模板 |
|||
|
|||
## 反馈 |
|||
|
|||
有问题需要反馈? |
|||
|
|||
- [Github问题](https://github.com/colinin/abp-next-admin/issues) |
|||
|
|||
[English](./README.md) |
|||
@ -0,0 +1,37 @@ |
|||
# LINGYUN.Abp.Aliyun.Features |
|||
|
|||
Alibaba Cloud service feature management module. |
|||
|
|||
## Features |
|||
|
|||
* Provides feature definitions and management for Alibaba Cloud services |
|||
* Supports enabling/disabling Alibaba Cloud service features |
|||
* Integration with ABP feature management system |
|||
|
|||
## Module Reference |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAliyunFeaturesModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Feature Items |
|||
|
|||
* **Features:AlibabaCloud** - Alibaba Cloud service feature group |
|||
* **Features:AlibabaCloud:IsEnabled** - Enable/Disable Alibaba Cloud services |
|||
* Default value: false |
|||
* Description: Enable to give the application Alibaba Cloud service capabilities |
|||
|
|||
## Configuration Items |
|||
|
|||
This module is mainly used for feature definition and does not contain configuration items. |
|||
|
|||
## Notes |
|||
|
|||
* This module needs to be used in conjunction with the LINGYUN.Abp.Aliyun module |
|||
* After enabling Alibaba Cloud service features, you still need to configure the corresponding service parameters in the LINGYUN.Abp.Aliyun module |
|||
|
|||
[查看中文文档](README.md) |
|||
@ -0,0 +1,37 @@ |
|||
# LINGYUN.Abp.Aliyun.Features |
|||
|
|||
阿里云服务功能管理模块。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 提供阿里云服务的功能定义和管理 |
|||
* 支持启用/禁用阿里云服务功能 |
|||
* 与ABP功能管理系统集成 |
|||
|
|||
## 模块引用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAliyunFeaturesModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## 功能项 |
|||
|
|||
* **Features:AlibabaCloud** - 阿里云服务功能组 |
|||
* **Features:AlibabaCloud:IsEnabled** - 是否启用阿里云服务 |
|||
* 默认值:false |
|||
* 描述:启用使应用程序拥有阿里云服务的能力 |
|||
|
|||
## 配置项 |
|||
|
|||
此模块主要用于功能定义,不包含配置项。 |
|||
|
|||
## 注意 |
|||
|
|||
* 此模块需要与LINGYUN.Abp.Aliyun模块配合使用 |
|||
* 启用阿里云服务功能后,还需要在LINGYUN.Abp.Aliyun模块中配置相应的服务参数 |
|||
|
|||
[点击查看英文文档](README.EN.md) |
|||
@ -0,0 +1,23 @@ |
|||
# LINGYUN.Abp.Aliyun.SettingManagement |
|||
|
|||
Alibaba Cloud configuration management module. By referencing this module, you can manage Alibaba Cloud-related configurations and access the API interfaces published through the gateway aggregation. |
|||
|
|||
API endpoint: api/setting-management/aliyun |
|||
|
|||
## Module Reference |
|||
|
|||
The module should be referenced as needed. It is recommended to reference this module in the configuration management hosting service. |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAliyunSettingManagementModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Note |
|||
|
|||
Since the background management module is responsible for managing all configurations, this module only provides query interfaces. |
|||
|
|||
[查看中文文档](README.md) |
|||
@ -0,0 +1,144 @@ |
|||
# LINGYUN.Abp.Aliyun |
|||
|
|||
Alibaba Cloud SDK integration module. |
|||
|
|||
Reference: [Alibaba Cloud API Documentation](https://help.aliyun.com/document_detail/28763.html) |
|||
|
|||
## Features |
|||
|
|||
- Provides basic SDK integration for Alibaba Cloud services |
|||
- Supports Alibaba Cloud RAM (Resource Access Management) authentication |
|||
- Supports STS Token access |
|||
- Supports Alibaba Cloud SMS service |
|||
- Supports Alibaba Cloud Object Storage Service (OSS) |
|||
- Provides distributed cache support for optimizing high concurrency scenarios |
|||
|
|||
## Module Reference |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpAliyunModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration Items |
|||
|
|||
### Authentication Configuration |
|||
|
|||
- **AliyunSettingNames.Authorization.RegionId** |
|||
|
|||
- Description: Alibaba Cloud service region |
|||
- Type: Optional |
|||
- Default value: default |
|||
- Example: oss-cn-hangzhou |
|||
|
|||
- **AliyunSettingNames.Authorization.AccessKeyId** |
|||
|
|||
- Description: AccessKey ID of Alibaba Cloud RAM account |
|||
- Type: Required |
|||
- How to get: Access Alibaba Cloud Console - Access Control |
|||
|
|||
- **AliyunSettingNames.Authorization.AccessKeySecret** |
|||
- Description: AccessKey Secret of RAM account |
|||
- Type: Required |
|||
- How to get: Access Alibaba Cloud Console - Access Control |
|||
|
|||
### STS Token Configuration |
|||
|
|||
- **AliyunSettingNames.Authorization.UseSecurityTokenService** |
|||
|
|||
- Description: Whether to use STS Token access |
|||
- Type: Optional |
|||
- Default value: false |
|||
- Recommendation: Recommended to enable for improved security |
|||
|
|||
- **AliyunSettingNames.Authorization.RamRoleArn** |
|||
|
|||
- Description: Alibaba Cloud RAM role ARN |
|||
- Type: Required when STS Token is enabled |
|||
- Format: acs:ram::$accountID:role/$roleName |
|||
|
|||
- **AliyunSettingNames.Authorization.RoleSessionName** |
|||
|
|||
- Description: Custom token name |
|||
- Type: Optional |
|||
- Usage: For access auditing |
|||
|
|||
- **AliyunSettingNames.Authorization.DurationSeconds** |
|||
|
|||
- Description: Token expiration time |
|||
- Type: Optional |
|||
- Default value: 3000 |
|||
- Unit: Seconds |
|||
|
|||
- **AliyunSettingNames.Authorization.Policy** |
|||
- Description: Permission policy |
|||
- Type: Optional |
|||
- Format: JSON string |
|||
|
|||
### SMS Service Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.Aliyun.Sms": { |
|||
"Domain": "dysmsapi.aliyuncs.com", // API endpoint, default is dysmsapi.aliyuncs.com |
|||
"Version": "2017-05-25", // API version, default is 2017-05-25 |
|||
"ActionName": "SendSms", // API method name, default is SendSms |
|||
"DefaultSignName": "", // Default SMS signature |
|||
"DefaultTemplateCode": "", // Default SMS template code |
|||
"DefaultPhoneNumber": "", // Default phone number for receiving SMS |
|||
"VisableErrorToClient": "false" // Whether to show error messages to client |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Available Regions |
|||
|
|||
The module supports the following Alibaba Cloud regions: |
|||
|
|||
- China Regions |
|||
|
|||
- North China 1 (Qingdao) - cn-qingdao |
|||
- North China 2 (Beijing) - cn-beijing |
|||
- North China 3 (Zhangjiakou) - cn-zhangjiakou |
|||
- North China 5 (Hohhot) - cn-huhehaote |
|||
- East China 1 (Hangzhou) - cn-hangzhou |
|||
- East China 2 (Shanghai) - cn-shanghai |
|||
- South China 1 (Shenzhen) - cn-shenzhen |
|||
- South China 2 (Heyuan) - cn-heyuan |
|||
- South China 3 (Guangzhou) - cn-guangzhou |
|||
- Southwest 1 (Chengdu) - cn-chengdu |
|||
|
|||
- Hong Kong and International Regions |
|||
- Hong Kong - cn-hongkong |
|||
- US (Silicon Valley) - us-west-1 |
|||
- US (Virginia) - us-east-1 |
|||
- Japan (Tokyo) - ap-northeast-1 |
|||
- South Korea (Seoul) - ap-northeast-2 |
|||
- Singapore - ap-southeast-1 |
|||
- Australia (Sydney) - ap-southeast-2 |
|||
- Malaysia (Kuala Lumpur) - ap-southeast-3 |
|||
- Indonesia (Jakarta) - ap-southeast-5 |
|||
- Philippines (Manila) - ap-southeast-6 |
|||
- Thailand (Bangkok) - ap-southeast-7 |
|||
- India (Mumbai) - ap-south-1 |
|||
- Germany (Frankfurt) - eu-central-1 |
|||
- UK (London) - eu-west-1 |
|||
- UAE (Dubai) - me-east-1 |
|||
|
|||
## Performance Optimization |
|||
|
|||
- In high concurrency scenarios, it is recommended to enable distributed caching to improve performance |
|||
- When using STS Token, the token will be automatically cached until expiration |
|||
- It is recommended to set DurationSeconds reasonably to avoid frequent token refreshes |
|||
|
|||
## Related Modules |
|||
|
|||
- [LINGYUN.Abp.Aliyun.SettingManagement](../LINGYUN.Abp.Aliyun.SettingManagement/README.md) - Provides configuration management functionality |
|||
- [LINGYUN.Abp.Aliyun.Features](../LINGYUN.Abp.Aliyun.Features/README.md) - Provides feature management functionality |
|||
|
|||
[查看中文文档](README.md) |
|||
@ -0,0 +1,137 @@ |
|||
# LINGYUN.Abp.BlobStoring.Tencent |
|||
|
|||
Tencent Cloud Object Storage (COS) Module, integrating Tencent Cloud Object Storage service into ABP BlobStoring system. |
|||
|
|||
## Features |
|||
|
|||
* Support for Tencent Cloud Object Storage service |
|||
* Multi-tenant configuration support |
|||
* Automatic bucket creation support |
|||
* Bucket referer configuration support |
|||
* Multi-region configuration support |
|||
* File size limit support |
|||
* Tenant-isolated storage support |
|||
|
|||
## Configuration Items |
|||
|
|||
### Basic Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "Your Tencent Cloud SecretId", // Get from Tencent Cloud Console |
|||
"SecretKey": "Your Tencent Cloud SecretKey", // Get from Tencent Cloud Console |
|||
"DurationSecond": "600" // Session duration in seconds |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### Object Storage Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Tencent": { |
|||
"OSS": { |
|||
"AppId": "", // Tencent Cloud AppId |
|||
"Region": "", // Bucket region |
|||
"BucketName": "", // Bucket name |
|||
"CreateBucketIfNotExists": false, // Create bucket if not exists |
|||
"CreateBucketReferer": [] // Referer settings when creating bucket |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### Bucket Naming Rules |
|||
|
|||
* Only lowercase letters and numbers are supported, i.e., [a-z, 0-9], hyphen "-" and their combinations |
|||
* Cannot start or end with a hyphen (-) |
|||
* The maximum allowed characters for bucket names are affected by the region abbreviation and APPID, with a total limit of 60 characters for the complete request domain |
|||
* For more rules, refer to [Tencent Cloud Bucket Naming Rules](https://cloud.tencent.com/document/product/436/13312) |
|||
|
|||
### Object Naming Rules |
|||
|
|||
* Cannot start with forward slash / or backslash \\ |
|||
* ASCII control characters are not supported in object keys: up arrow (↑), down arrow (↓), right arrow (→), left arrow (←) |
|||
* For more rules, refer to [Tencent Cloud Object Naming Rules](https://cloud.tencent.com/document/product/436/13324) |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Add module dependency |
|||
```csharp |
|||
[DependsOn(typeof(AbpBlobStoringTencentCloudModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Configure Tencent Cloud Object Storage |
|||
```csharp |
|||
Configure<AbpBlobStoringOptions>(options => |
|||
{ |
|||
options.Containers.Configure<YourContainer>(container => |
|||
{ |
|||
container.UseTencentCloud(tencent => |
|||
{ |
|||
tencent.AppId = "Your Tencent Cloud AppId"; |
|||
tencent.Region = "ap-guangzhou"; |
|||
tencent.BucketName = "your-bucket-name"; |
|||
tencent.CreateBucketIfNotExists = true; |
|||
tencent.CreateBucketReferer = new List<string> |
|||
{ |
|||
"*.example.com", |
|||
"example.com" |
|||
}; |
|||
}); |
|||
}); |
|||
}); |
|||
``` |
|||
|
|||
3. Use BLOB storage |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly IBlobContainer<YourContainer> _blobContainer; |
|||
|
|||
public YourService(IBlobContainer<YourContainer> blobContainer) |
|||
{ |
|||
_blobContainer = blobContainer; |
|||
} |
|||
|
|||
public async Task SaveBlobAsync(string name, Stream stream) |
|||
{ |
|||
await _blobContainer.SaveAsync(name, stream); |
|||
} |
|||
|
|||
public async Task<Stream> GetBlobAsync(string name) |
|||
{ |
|||
return await _blobContainer.GetAsync(name); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Advanced Features |
|||
|
|||
### Multi-tenant Support |
|||
|
|||
The module supports tenant-isolated storage with the following path format: |
|||
* Host: `host/{blobName}` |
|||
* Tenant: `tenants/{tenantId}/{blobName}` |
|||
|
|||
### Feature Management |
|||
|
|||
The module provides the following feature switches: |
|||
|
|||
* TencentBlobStoring - Controls enabling/disabling of Tencent Cloud Object Storage service |
|||
* TencentBlobStoringMaximumStreamSize - Controls the maximum file size limit (MB) for uploads |
|||
|
|||
## More Documentation |
|||
|
|||
* [Tencent Cloud Object Storage](https://cloud.tencent.com/document/product/436) |
|||
* [Tencent Cloud COS Console](https://console.cloud.tencent.com/cos) |
|||
* [ABP BlobStoring System](https://docs.abp.io/en/abp/latest/Blob-Storing) |
|||
|
|||
[简体中文](./README.md) |
|||
@ -0,0 +1,137 @@ |
|||
# LINGYUN.Abp.BlobStoring.Tencent |
|||
|
|||
腾讯云对象存储(COS)模块,集成腾讯云对象存储服务到ABP BlobStoring系统。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 支持腾讯云对象存储服务 |
|||
* 支持多租户配置 |
|||
* 支持自动创建存储桶(Bucket) |
|||
* 支持存储桶防盗链配置 |
|||
* 支持多区域配置 |
|||
* 支持文件大小限制 |
|||
* 支持按租户隔离存储 |
|||
|
|||
## 配置项说明 |
|||
|
|||
### 基础配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "您的腾讯云SecretId", // 从腾讯云控制台获取 |
|||
"SecretKey": "您的腾讯云SecretKey", // 从腾讯云控制台获取 |
|||
"DurationSecond": "600" // 会话持续时长,单位秒 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 对象存储配置 |
|||
|
|||
```json |
|||
{ |
|||
"Tencent": { |
|||
"OSS": { |
|||
"AppId": "", // 腾讯云AppId |
|||
"Region": "", // 存储桶所在地域 |
|||
"BucketName": "", // 存储桶名称 |
|||
"CreateBucketIfNotExists": false, // 存储桶不存在时是否创建 |
|||
"CreateBucketReferer": [] // 创建存储桶时的防盗链设置 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 存储桶命名规范 |
|||
|
|||
* 仅支持小写英文字母和数字,即[a-z,0-9]、中划线"-"及其组合 |
|||
* 不能以短划线(-)开头或结尾 |
|||
* 存储桶名称的最大允许字符受到地域简称和APPID的字符数影响,组成的完整请求域名字符数总计最多60个字符 |
|||
* 更多规范请参考[腾讯云存储桶命名规范](https://cloud.tencent.com/document/product/436/13312) |
|||
|
|||
### 对象命名规范 |
|||
|
|||
* 不允许以正斜线/或者反斜线\\开头 |
|||
* 对象键中不支持ASCII控制字符中的字符上(↑),字符下(↓),字符右(→),字符左(←) |
|||
* 更多规范请参考[腾讯云对象命名规范](https://cloud.tencent.com/document/product/436/13324) |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 添加模块依赖 |
|||
```csharp |
|||
[DependsOn(typeof(AbpBlobStoringTencentCloudModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 配置腾讯云对象存储 |
|||
```csharp |
|||
Configure<AbpBlobStoringOptions>(options => |
|||
{ |
|||
options.Containers.Configure<YourContainer>(container => |
|||
{ |
|||
container.UseTencentCloud(tencent => |
|||
{ |
|||
tencent.AppId = "您的腾讯云AppId"; |
|||
tencent.Region = "ap-guangzhou"; |
|||
tencent.BucketName = "your-bucket-name"; |
|||
tencent.CreateBucketIfNotExists = true; |
|||
tencent.CreateBucketReferer = new List<string> |
|||
{ |
|||
"*.example.com", |
|||
"example.com" |
|||
}; |
|||
}); |
|||
}); |
|||
}); |
|||
``` |
|||
|
|||
3. 使用BLOB存储 |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly IBlobContainer<YourContainer> _blobContainer; |
|||
|
|||
public YourService(IBlobContainer<YourContainer> blobContainer) |
|||
{ |
|||
_blobContainer = blobContainer; |
|||
} |
|||
|
|||
public async Task SaveBlobAsync(string name, Stream stream) |
|||
{ |
|||
await _blobContainer.SaveAsync(name, stream); |
|||
} |
|||
|
|||
public async Task<Stream> GetBlobAsync(string name) |
|||
{ |
|||
return await _blobContainer.GetAsync(name); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 高级特性 |
|||
|
|||
### 多租户支持 |
|||
|
|||
模块支持按租户隔离存储,存储路径格式如下: |
|||
* 宿主:`host/{blobName}` |
|||
* 租户:`tenants/{tenantId}/{blobName}` |
|||
|
|||
### 特性管理 |
|||
|
|||
模块提供以下特性开关: |
|||
|
|||
* TencentBlobStoring - 控制腾讯云对象存储服务的启用/禁用 |
|||
* TencentBlobStoringMaximumStreamSize - 控制上传文件的最大大小限制(MB) |
|||
|
|||
## 更多文档 |
|||
|
|||
* [腾讯云对象存储](https://cloud.tencent.com/document/product/436) |
|||
* [腾讯云COS控制台](https://console.cloud.tencent.com/cos) |
|||
* [ABP BlobStoring系统](https://docs.abp.io/en/abp/latest/Blob-Storing) |
|||
|
|||
[English](./README.EN.md) |
|||
@ -0,0 +1,128 @@ |
|||
# LINGYUN.Abp.Sms.Tencent |
|||
|
|||
Tencent Cloud SMS Service Module, integrating Tencent Cloud SMS service into ABP applications. |
|||
|
|||
## Features |
|||
|
|||
* Support for Tencent Cloud SMS sending functionality |
|||
* Multi-tenant configuration support |
|||
* Default signature and template configuration support |
|||
* Support for batch sending to multiple phone numbers |
|||
* SMS template parameter support |
|||
* Built-in error handling and logging |
|||
|
|||
## Configuration Items |
|||
|
|||
### Basic Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "Your Tencent Cloud SecretId", // Get from Tencent Cloud Console |
|||
"SecretKey": "Your Tencent Cloud SecretKey", // Get from Tencent Cloud Console |
|||
"DurationSecond": "600" // Session duration in seconds |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### SMS Service Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.Sms": { |
|||
"AppId": "", // SMS application ID, generated after adding application in SMS console |
|||
"DefaultSignName": "", // Default SMS signature |
|||
"DefaultTemplateId": "" // Default SMS template ID |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Add module dependency |
|||
```csharp |
|||
[DependsOn(typeof(AbpSmsTencentModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Configure Tencent Cloud SMS service |
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "Your Tencent Cloud SecretId", |
|||
"SecretKey": "Your Tencent Cloud SecretKey", |
|||
"DurationSecond": "600" |
|||
}, |
|||
"Abp.TencentCloud.Sms": { |
|||
"AppId": "Your SMS Application ID", |
|||
"DefaultSignName": "Your SMS Signature", |
|||
"DefaultTemplateId": "Your Default Template ID" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. SMS sending examples |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ISmsSender _smsSender; |
|||
|
|||
public YourService(ISmsSender smsSender) |
|||
{ |
|||
_smsSender = smsSender; |
|||
} |
|||
|
|||
// Send using default signature and template |
|||
public async Task SendSmsAsync(string phoneNumber, Dictionary<string, object> templateParams) |
|||
{ |
|||
await _smsSender.SendAsync( |
|||
phoneNumber, |
|||
nameof(TencentCloudSmsSender), |
|||
templateParams); |
|||
} |
|||
|
|||
// Send using specified signature and template |
|||
public async Task SendSmsAsync( |
|||
string signName, |
|||
string templateCode, |
|||
string phoneNumber, |
|||
Dictionary<string, object> templateParams) |
|||
{ |
|||
await _smsSender.SendAsync( |
|||
signName, |
|||
templateCode, |
|||
phoneNumber, |
|||
templateParams); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Advanced Features |
|||
|
|||
### Feature Switches |
|||
|
|||
The module provides the following feature switches: |
|||
|
|||
* TencentSms - Controls enabling/disabling of Tencent Cloud SMS service |
|||
|
|||
### Error Handling |
|||
|
|||
* Throws exception when all SMS sending fails |
|||
* Logs warning when partial SMS sending fails |
|||
* Supports viewing detailed failure information, including serial number, phone number, error code, and error message |
|||
|
|||
## More Documentation |
|||
|
|||
* [Tencent Cloud SMS Service](https://cloud.tencent.com/document/product/382) |
|||
* [SMS Console](https://console.cloud.tencent.com/smsv2) |
|||
|
|||
[简体中文](./README.md) |
|||
@ -0,0 +1,127 @@ |
|||
# LINGYUN.Abp.Sms.Tencent |
|||
|
|||
腾讯云短信服务模块,集成腾讯云短信服务到ABP应用程序。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 支持腾讯云短信服务的发送功能 |
|||
* 支持多租户配置 |
|||
* 支持默认签名和模板配置 |
|||
* 支持多手机号批量发送 |
|||
* 支持短信模板参数传递 |
|||
* 内置错误处理和日志记录 |
|||
|
|||
## 配置项说明 |
|||
|
|||
### 基础配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "您的腾讯云SecretId", // 从腾讯云控制台获取 |
|||
"SecretKey": "您的腾讯云SecretKey", // 从腾讯云控制台获取 |
|||
"DurationSecond": "600" // 会话持续时长,单位秒 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 短信服务配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.Sms": { |
|||
"AppId": "", // 短信应用ID,在短信控制台添加应用后生成 |
|||
"DefaultSignName": "", // 默认短信签名 |
|||
"DefaultTemplateId": "" // 默认短信模板ID |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 添加模块依赖 |
|||
```csharp |
|||
[DependsOn(typeof(AbpSmsTencentModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 配置腾讯云短信服务 |
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "您的腾讯云SecretId", |
|||
"SecretKey": "您的腾讯云SecretKey" |
|||
}, |
|||
"Abp.TencentCloud.Sms": { |
|||
"AppId": "您的短信应用ID", |
|||
"DefaultSignName": "您的短信签名", |
|||
"DefaultTemplateId": "您的默认模板ID" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. 发送短信示例 |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ISmsSender _smsSender; |
|||
|
|||
public YourService(ISmsSender smsSender) |
|||
{ |
|||
_smsSender = smsSender; |
|||
} |
|||
|
|||
// 使用默认签名和模板发送 |
|||
public async Task SendSmsAsync(string phoneNumber, Dictionary<string, object> templateParams) |
|||
{ |
|||
await _smsSender.SendAsync( |
|||
phoneNumber, |
|||
nameof(TencentCloudSmsSender), |
|||
templateParams); |
|||
} |
|||
|
|||
// 使用指定签名和模板发送 |
|||
public async Task SendSmsAsync( |
|||
string signName, |
|||
string templateCode, |
|||
string phoneNumber, |
|||
Dictionary<string, object> templateParams) |
|||
{ |
|||
await _smsSender.SendAsync( |
|||
signName, |
|||
templateCode, |
|||
phoneNumber, |
|||
templateParams); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 高级特性 |
|||
|
|||
### 特性开关 |
|||
|
|||
模块提供以下特性开关: |
|||
|
|||
* TencentSms - 控制腾讯云短信服务的启用/禁用 |
|||
|
|||
### 错误处理 |
|||
|
|||
* 当所有短信发送失败时,会抛出异常 |
|||
* 当部分短信发送失败时,会记录警告日志 |
|||
* 支持查看发送失败的详细信息,包括流水号、手机号、错误代码和错误信息 |
|||
|
|||
## 更多文档 |
|||
|
|||
* [腾讯云短信服务](https://cloud.tencent.com/document/product/382) |
|||
* [短信控制台](https://console.cloud.tencent.com/smsv2) |
|||
|
|||
[English](./README.EN.md) |
|||
@ -0,0 +1,81 @@ |
|||
# LINGYUN.Abp.Tencent.QQ |
|||
|
|||
Tencent QQ Connect module, integrating QQ Connect service into ABP applications. |
|||
|
|||
## Features |
|||
|
|||
* Support for QQ Connect quick login |
|||
* Multi-tenant configuration support |
|||
* Provides QQ Connect client factory for dynamic client creation |
|||
|
|||
## Configuration Items |
|||
|
|||
### Basic Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "Your Tencent Cloud SecretId", // Get from Tencent Cloud Console |
|||
"SecretKey": "Your Tencent Cloud SecretKey", // Get from Tencent Cloud Console |
|||
"DurationSecond": "600" // Session duration in seconds |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### QQ Connect Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.QQConnect": { |
|||
"AppId": "", // QQ Connect AppId, get from QQ Connect Management Center |
|||
"AppKey": "", // QQ Connect AppKey, get from QQ Connect Management Center |
|||
"IsMobile": "false" // Whether to use mobile style, default is PC style |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Add module dependency |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentQQModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Configure QQ Connect service |
|||
|
|||
Refer to the configuration items description above for the corresponding configuration. |
|||
|
|||
3. QQ Connect service usage example |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly TencentQQClientFactory _qqClientFactory; |
|||
|
|||
public YourService(TencentQQClientFactory qqClientFactory) |
|||
{ |
|||
_qqClientFactory = qqClientFactory; |
|||
} |
|||
|
|||
public async Task QQConnectAsync() |
|||
{ |
|||
var qqClient = await _qqClientFactory.CreateAsync(); |
|||
// Use qqClient to call QQ Connect service APIs |
|||
// For detailed API usage, please refer to QQ Connect development documentation |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Documentation |
|||
|
|||
* [QQ Connect Open Platform](https://connect.qq.com/) |
|||
* [QQ Connect Development Documentation](https://wiki.connect.qq.com/) |
|||
|
|||
[简体中文](./README.md) |
|||
@ -0,0 +1,81 @@ |
|||
# LINGYUN.Abp.Tencent.QQ |
|||
|
|||
腾讯QQ互联模块,集成腾讯QQ互联服务到ABP应用程序。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 支持QQ互联快速登录 |
|||
* 支持多租户配置 |
|||
* 提供QQ互联客户端工厂,支持动态创建客户端 |
|||
|
|||
## 配置项说明 |
|||
|
|||
### 基础配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "您的腾讯云SecretId", // 从腾讯云控制台获取 |
|||
"SecretKey": "您的腾讯云SecretKey", // 从腾讯云控制台获取 |
|||
"DurationSecond": "600" // 会话持续时间(秒) |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### QQ互联配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.QQConnect": { |
|||
"AppId": "", // QQ互联应用ID,从QQ互联管理中心获取 |
|||
"AppKey": "", // QQ互联应用密钥,从QQ互联管理中心获取 |
|||
"IsMobile": "false" // 是否使用移动端样式,默认为PC端样式 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 添加模块依赖 |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentQQModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 配置QQ互联服务 |
|||
|
|||
参考上述配置项说明进行相应配置。 |
|||
|
|||
3. QQ互联服务使用示例 |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly TencentQQClientFactory _qqClientFactory; |
|||
|
|||
public YourService(TencentQQClientFactory qqClientFactory) |
|||
{ |
|||
_qqClientFactory = qqClientFactory; |
|||
} |
|||
|
|||
public async Task QQConnectAsync() |
|||
{ |
|||
var qqClient = await _qqClientFactory.CreateAsync(); |
|||
// 使用qqClient调用QQ互联服务API |
|||
// 详细API使用方法请参考QQ互联开发文档 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 更多文档 |
|||
|
|||
* [QQ互联开放平台](https://connect.qq.com/) |
|||
* [QQ互联开发文档](https://wiki.connect.qq.com/) |
|||
|
|||
[English](./README.EN.md) |
|||
@ -0,0 +1,156 @@ |
|||
# LINGYUN.Abp.Tencent.SettingManagement |
|||
|
|||
Tencent Cloud Service Setting Management Module, providing configuration management interface and API for Tencent Cloud services. |
|||
|
|||
## Features |
|||
|
|||
* Provides configuration management interface for Tencent Cloud services |
|||
* Supports global and tenant-level configuration management |
|||
* Supports configuration for the following Tencent Cloud services: |
|||
* Basic configuration (keys, regions, etc.) |
|||
* Connection configuration (HTTP method, timeout, proxy, etc.) |
|||
* SMS service configuration (application ID, default signature, default template, etc.) |
|||
* QQ Connect configuration (application ID, application key, etc.) |
|||
* Built-in permission management |
|||
* Multi-language localization support |
|||
* Support for all Tencent Cloud available regions |
|||
|
|||
## Permissions |
|||
|
|||
* `TencentCloud` - Tencent Cloud service permission group |
|||
* `TencentCloud.Settings` - Configure Tencent Cloud service permission |
|||
|
|||
## API Endpoints |
|||
|
|||
### Get Global Configuration |
|||
|
|||
```http |
|||
GET /api/setting-management/tencent/by-global |
|||
``` |
|||
|
|||
### Get Current Tenant Configuration |
|||
|
|||
```http |
|||
GET /api/setting-management/tencent/by-current-tenant |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Add module dependency |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentCloudSettingManagementModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Configure authorization |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpPermissionOptions>(options => |
|||
{ |
|||
options.GrantByDefault(TencentCloudSettingPermissionNames.Settings); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
## Configuration Items |
|||
|
|||
### Basic Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"EndPoint": "ap-guangzhou", // Resource region, default is Guangzhou |
|||
"SecretId": "Your Tencent Cloud SecretId", // Get from Tencent Cloud Console |
|||
"SecretKey": "Your Tencent Cloud SecretKey", // Get from Tencent Cloud Console |
|||
"DurationSecond": "600" // Session duration in seconds |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### Connection Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.Connection": { |
|||
"HttpMethod": "POST", // Request method, default is POST |
|||
"Timeout": "60", // Connection timeout in seconds |
|||
"WebProxy": "", // Proxy server address, optional |
|||
"EndPoint": "" // Specific service domain, required for financial zone services |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### SMS Service Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.Sms": { |
|||
"AppId": "", // SMS application ID, generated after adding application in SMS console |
|||
"DefaultSignName": "", // Default SMS signature |
|||
"DefaultTemplateId": "" // Default SMS template ID |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### QQ Connect Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.QQConnect": { |
|||
"AppId": "", // QQ Connect application ID, get from QQ Connect Management Center |
|||
"AppKey": "", // QQ Connect application key, get from QQ Connect Management Center |
|||
"IsMobile": "false" // Whether to use mobile style, default is PC style |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Available Regions |
|||
|
|||
The module supports the following Tencent Cloud regions: |
|||
|
|||
* China Regions |
|||
* North China (Beijing) - ap-beijing |
|||
* Southwest China (Chengdu) - ap-chengdu |
|||
* Southwest China (Chongqing) - ap-chongqing |
|||
* South China (Guangzhou) - ap-guangzhou |
|||
* Hong Kong/Macao/Taiwan (Hong Kong, China) - ap-hongkong |
|||
* East China (Nanjing) - ap-nanjing |
|||
* East China (Shanghai) - ap-shanghai |
|||
* East China (Shanghai Financial) - ap-shanghai-fsi |
|||
* South China (Shenzhen Financial) - ap-shenzhen-fsi |
|||
|
|||
* Asia Pacific |
|||
* Bangkok - ap-bangkok |
|||
* Jakarta - ap-jakarta |
|||
* Mumbai - ap-mumbai |
|||
* Seoul - ap-seoul |
|||
* Singapore - ap-singapore |
|||
* Tokyo - ap-tokyo |
|||
|
|||
* Europe |
|||
* Frankfurt - eu-frankfurt |
|||
* Moscow - eu-moscow |
|||
|
|||
* North America |
|||
* Virginia - na-ashburn |
|||
* Silicon Valley - na-siliconvalley |
|||
* Toronto - na-toronto |
|||
|
|||
## More Documentation |
|||
|
|||
* [Tencent Cloud API Key Management](https://console.cloud.tencent.com/cam/capi) |
|||
* [Tencent Cloud Regions and Availability Zones](https://cloud.tencent.com/document/product/213/6091) |
|||
|
|||
[简体中文](./README.md) |
|||
@ -0,0 +1,156 @@ |
|||
# LINGYUN.Abp.Tencent.SettingManagement |
|||
|
|||
腾讯云服务设置管理模块,提供腾讯云服务的配置管理界面和API。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 提供腾讯云服务的配置管理界面 |
|||
* 支持全局和租户级别的配置管理 |
|||
* 支持以下腾讯云服务的配置: |
|||
* 基础配置(密钥、地域等) |
|||
* 连接配置(HTTP方法、超时时间、代理等) |
|||
* 短信服务配置(应用ID、默认签名、默认模板等) |
|||
* QQ互联配置(应用ID、应用密钥等) |
|||
* 内置权限管理 |
|||
* 支持多语言本地化 |
|||
* 支持所有腾讯云可用区域的配置 |
|||
|
|||
## 权限 |
|||
|
|||
* `TencentCloud` - 腾讯云服务权限组 |
|||
* `TencentCloud.Settings` - 配置腾讯云服务权限 |
|||
|
|||
## API接口 |
|||
|
|||
### 获取全局配置 |
|||
|
|||
```http |
|||
GET /api/setting-management/tencent/by-global |
|||
``` |
|||
|
|||
### 获取当前租户配置 |
|||
|
|||
```http |
|||
GET /api/setting-management/tencent/by-current-tenant |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 添加模块依赖 |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentCloudSettingManagementModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 授权配置 |
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpPermissionOptions>(options => |
|||
{ |
|||
options.GrantByDefault(TencentCloudSettingPermissionNames.Settings); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
## 配置项说明 |
|||
|
|||
### 基础配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"EndPoint": "ap-guangzhou", // 资源所在地域,默认为广州 |
|||
"SecretId": "您的腾讯云SecretId", // 从腾讯云控制台获取 |
|||
"SecretKey": "您的腾讯云SecretKey", // 从腾讯云控制台获取 |
|||
"DurationSecond": "600" // 会话持续时长,单位秒 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 连接配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.Connection": { |
|||
"HttpMethod": "POST", // 请求方法,默认POST |
|||
"Timeout": "60", // 连接超时时间,单位秒 |
|||
"WebProxy": "", // 代理服务器地址,可选 |
|||
"EndPoint": "" // 特定服务的域名,如金融区服务需要指定 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 短信服务配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.Sms": { |
|||
"AppId": "", // 短信应用ID,在短信控制台添加应用后生成 |
|||
"DefaultSignName": "", // 默认短信签名 |
|||
"DefaultTemplateId": "" // 默认短信模板ID |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### QQ互联配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.QQConnect": { |
|||
"AppId": "", // QQ互联应用ID,从QQ互联管理中心获取 |
|||
"AppKey": "", // QQ互联应用密钥,从QQ互联管理中心获取 |
|||
"IsMobile": "false" // 是否使用移动端样式,默认为PC端样式 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 可用区域 |
|||
|
|||
模块支持以下腾讯云区域: |
|||
|
|||
* 中国区域 |
|||
* 华北地区(北京)- ap-beijing |
|||
* 西南地区(成都)- ap-chengdu |
|||
* 西南地区(重庆)- ap-chongqing |
|||
* 华南地区(广州)- ap-guangzhou |
|||
* 港澳台地区(中国香港)- ap-hongkong |
|||
* 华东地区(南京)- ap-nanjing |
|||
* 华东地区(上海)- ap-shanghai |
|||
* 华东地区(上海金融)- ap-shanghai-fsi |
|||
* 华南地区(深圳金融)- ap-shenzhen-fsi |
|||
|
|||
* 亚太地区 |
|||
* 曼谷 - ap-bangkok |
|||
* 雅加达 - ap-jakarta |
|||
* 孟买 - ap-mumbai |
|||
* 首尔 - ap-seoul |
|||
* 新加坡 - ap-singapore |
|||
* 东京 - ap-tokyo |
|||
|
|||
* 欧洲地区 |
|||
* 法兰克福 - eu-frankfurt |
|||
* 莫斯科 - eu-moscow |
|||
|
|||
* 北美地区 |
|||
* 弗吉尼亚 - na-ashburn |
|||
* 硅谷 - na-siliconvalley |
|||
* 多伦多 - na-toronto |
|||
|
|||
## 更多文档 |
|||
|
|||
* [腾讯云API密钥管理](https://console.cloud.tencent.com/cam/capi) |
|||
* [腾讯云地域和可用区](https://cloud.tencent.com/document/product/213/6091) |
|||
|
|||
[English](./README.EN.md) |
|||
@ -0,0 +1,93 @@ |
|||
# LINGYUN.Abp.Tencent.TTS |
|||
|
|||
Tencent Cloud Text-to-Speech (TTS) Service Module, integrating Tencent Cloud TTS service into ABP applications. |
|||
|
|||
## Features |
|||
|
|||
* Support for Tencent Cloud Text-to-Speech (TTS) service |
|||
* Multi-tenant configuration support |
|||
* Based on Tencent Cloud TTS SDK V20190823 |
|||
* Provides TTS client factory for dynamic TTS client creation |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Add module dependency |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentTTSModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Configure Tencent Cloud service |
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent": { |
|||
"SecretId": "Your Tencent Cloud SecretId", |
|||
"SecretKey": "Your Tencent Cloud SecretKey" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. TTS service usage example |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly TencentCloudTTSClientFactory _ttsClientFactory; |
|||
|
|||
public YourService(TencentCloudTTSClientFactory ttsClientFactory) |
|||
{ |
|||
_ttsClientFactory = ttsClientFactory; |
|||
} |
|||
|
|||
public async Task TextToSpeechAsync(string text) |
|||
{ |
|||
var ttsClient = await _ttsClientFactory.CreateAsync(); |
|||
// Use ttsClient to call Tencent Cloud TTS service APIs |
|||
// For detailed API usage, please refer to Tencent Cloud TTS SDK documentation |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Configuration Items |
|||
|
|||
### Basic Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "Your Tencent Cloud SecretId", // Get from Tencent Cloud Console |
|||
"SecretKey": "Your Tencent Cloud SecretKey", // Get from Tencent Cloud Console |
|||
"DurationSecond": "600" // Session duration in seconds |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### TTS Service Configuration |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.TTS": { |
|||
"AppId": "", // TTS application ID |
|||
"VoiceType": "", // Voice type, default is "0" |
|||
"Language": "1", // Language, 1-Chinese, 2-English |
|||
"Speed": "0", // Speech speed, range: -2~2 |
|||
"Volume": "0", // Volume, range: 0~10 |
|||
"ProjectId": "0" // Project ID |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## More Documentation |
|||
|
|||
* [Tencent Cloud TTS Service](https://cloud.tencent.com/document/product/1073) |
|||
* [Tencent Cloud TTS SDK Documentation](https://cloud.tencent.com/document/product/1073/37927) |
|||
|
|||
[简体中文](./README.md) |
|||
@ -0,0 +1,93 @@ |
|||
# LINGYUN.Abp.Tencent.TTS |
|||
|
|||
腾讯云语音合成服务模块,集成腾讯云语音合成服务到ABP应用程序。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 支持腾讯云语音合成服务(TTS) |
|||
* 支持多租户配置 |
|||
* 基于腾讯云TTS SDK V20190823 |
|||
* 提供TTS客户端工厂,支持动态创建TTS客户端 |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 添加模块依赖 |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentTTSModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 配置腾讯云服务 |
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent": { |
|||
"SecretId": "您的腾讯云SecretId", |
|||
"SecretKey": "您的腾讯云SecretKey" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. 使用TTS服务示例 |
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly TencentCloudTTSClientFactory _ttsClientFactory; |
|||
|
|||
public YourService(TencentCloudTTSClientFactory ttsClientFactory) |
|||
{ |
|||
_ttsClientFactory = ttsClientFactory; |
|||
} |
|||
|
|||
public async Task TextToSpeechAsync(string text) |
|||
{ |
|||
var ttsClient = await _ttsClientFactory.CreateAsync(); |
|||
// 使用ttsClient调用腾讯云TTS服务API |
|||
// 详细API使用方法请参考腾讯云TTS SDK文档 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 配置项说明 |
|||
|
|||
### 基础配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud": { |
|||
"SecretId": "您的腾讯云SecretId", // 从腾讯云控制台获取 |
|||
"SecretKey": "您的腾讯云SecretKey", // 从腾讯云控制台获取 |
|||
"DurationSecond": "600" // 会话持续时间(秒) |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### TTS服务配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"Abp.TencentCloud.TTS": { |
|||
"AppId": "", // TTS应用ID |
|||
"VoiceType": "", // 音色,默认为"0" |
|||
"Language": "1", // 语言,1-中文,2-英文 |
|||
"Speed": "0", // 语速,范围:-2~2 |
|||
"Volume": "0", // 音量,范围:0~10 |
|||
"ProjectId": "0" // 项目ID |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 更多文档 |
|||
|
|||
* [腾讯云语音合成服务](https://cloud.tencent.com/document/product/1073) |
|||
* [腾讯云TTS SDK文档](https://cloud.tencent.com/document/product/1073/37927) |
|||
|
|||
[English](./README.EN.md) |
|||
@ -0,0 +1,87 @@ |
|||
# LINGYUN.Abp.Tencent |
|||
|
|||
Tencent Cloud Service Base Module, providing infrastructure support for other Tencent Cloud service modules. |
|||
|
|||
## Features |
|||
|
|||
* Provides Tencent Cloud SDK client factory, supporting dynamic creation of clients for various Tencent Cloud services |
|||
* Multi-tenant configuration support |
|||
* Built-in localization support (Chinese and English) |
|||
* Unified Tencent Cloud service configuration management |
|||
* Feature management support, enabling/disabling functionalities as needed |
|||
* Region localization display support |
|||
|
|||
## Configuration |
|||
|
|||
### Basic Settings |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent": { |
|||
"EndPoint": "ap-guangzhou", // Resource region, default is Guangzhou |
|||
"SecretId": "Your Tencent Cloud SecretId", // Get from Tencent Cloud Console |
|||
"SecretKey": "Your Tencent Cloud SecretKey", // Get from Tencent Cloud Console |
|||
"DurationSecond": "600" // Session duration in seconds |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### Connection Settings |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent.Connection": { |
|||
"HttpMethod": "POST", // Request method, default is POST |
|||
"Timeout": "60", // Connection timeout in seconds |
|||
"WebProxy": "" // Proxy server address, optional |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
1. Add module dependency |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentCloudModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Configure Tencent Cloud service |
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent": { |
|||
"SecretId": "Your Tencent Cloud SecretId", |
|||
"SecretKey": "Your Tencent Cloud SecretKey" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Advanced Features |
|||
|
|||
### Feature Management |
|||
|
|||
The module provides the following feature switches: |
|||
|
|||
* TencentSms - Tencent Cloud SMS service |
|||
* TencentBlobStoring - Tencent Cloud Object Storage service |
|||
* MaximumStreamSize - Maximum file stream size limit for single upload (MB) |
|||
|
|||
### Multi-tenant Support |
|||
|
|||
All configurations support multi-tenant settings, allowing different Tencent Cloud service parameters for different tenants. |
|||
|
|||
## More Documentation |
|||
|
|||
* [Tencent Cloud API Key Management](https://console.cloud.tencent.com/cam/capi) |
|||
* [Tencent Cloud Regions and Availability Zones](https://cloud.tencent.com/document/product/213/6091) |
|||
|
|||
[简体中文](./README.md) |
|||
@ -0,0 +1,87 @@ |
|||
# LINGYUN.Abp.Tencent |
|||
|
|||
腾讯云服务基础模块,为其他腾讯云服务模块提供基础设施支持。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 提供腾讯云SDK客户端工厂,支持动态创建腾讯云各项服务的客户端 |
|||
* 支持多租户配置 |
|||
* 内置多语言本地化支持(中文和英文) |
|||
* 提供统一的腾讯云服务配置管理 |
|||
* 支持特性(Feature)管理,可按需启用/禁用功能 |
|||
* 支持区域(Region)本地化显示 |
|||
|
|||
## 配置项 |
|||
|
|||
### 基础配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent": { |
|||
"EndPoint": "ap-guangzhou", // 资源所在地域,默认为广州 |
|||
"SecretId": "您的腾讯云SecretId", // 从腾讯云控制台获取 |
|||
"SecretKey": "您的腾讯云SecretKey", // 从腾讯云控制台获取 |
|||
"DurationSecond": "600" // 会话持续时长,单位秒 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 连接配置 |
|||
|
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent.Connection": { |
|||
"HttpMethod": "POST", // 请求方法,默认POST |
|||
"Timeout": "60", // 连接超时时间,单位秒 |
|||
"WebProxy": "" // 代理服务器地址,可选 |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基本用法 |
|||
|
|||
1. 添加模块依赖 |
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentCloudModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 配置腾讯云服务 |
|||
```json |
|||
{ |
|||
"Settings": { |
|||
"LINGYUN.Abp.Tencent": { |
|||
"SecretId": "您的腾讯云SecretId", |
|||
"SecretKey": "您的腾讯云SecretKey" |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 高级特性 |
|||
|
|||
### 特性管理 |
|||
|
|||
模块提供以下特性开关: |
|||
|
|||
* TencentSms - 腾讯云短信服务 |
|||
* TencentBlobStoring - 腾讯云对象存储服务 |
|||
* MaximumStreamSize - 单次上传文件流大小限制(MB) |
|||
|
|||
### 多租户支持 |
|||
|
|||
所有配置均支持多租户配置,可以为不同租户配置不同的腾讯云服务参数。 |
|||
|
|||
## 更多文档 |
|||
|
|||
* [腾讯云API密钥管理](https://console.cloud.tencent.com/cam/capi) |
|||
* [腾讯云地域和可用区](https://cloud.tencent.com/document/product/213/6091) |
|||
|
|||
[English](./README.EN.md) |
|||
@ -0,0 +1,94 @@ |
|||
# LINGYUN.Abp.BackgroundJobs.Hangfire |
|||
|
|||
English | [简体中文](README.md) |
|||
|
|||
## 1. Introduction |
|||
|
|||
`LINGYUN.Abp.BackgroundJobs.Hangfire` is an ABP background job module implemented based on [Hangfire](https://www.hangfire.io/). It provides a reliable background job execution framework that supports immediate, delayed, and recurring task execution. |
|||
|
|||
## 2. Features |
|||
|
|||
* Support for immediate task execution |
|||
* Support for delayed task execution |
|||
* Support for recurring tasks (using Cron expressions) |
|||
* Seamless integration with ABP background job system |
|||
* Job execution status tracking |
|||
* Job retry mechanism |
|||
|
|||
## 3. Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.BackgroundJobs.Hangfire |
|||
``` |
|||
|
|||
## 4. Usage |
|||
|
|||
1. Add `AbpBackgroundJobsHangfireModule` to your module dependencies: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpBackgroundJobsHangfireModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Configure background jobs: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpBackgroundJobOptions>(options => |
|||
{ |
|||
options.IsJobExecutionEnabled = true; // Enable job execution |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
3. Use background jobs: |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly IBackgroundJobManager _backgroundJobManager; |
|||
|
|||
public YourService(IBackgroundJobManager backgroundJobManager) |
|||
{ |
|||
_backgroundJobManager = backgroundJobManager; |
|||
} |
|||
|
|||
public async Task CreateJobAsync() |
|||
{ |
|||
// Create immediate job |
|||
await _backgroundJobManager.EnqueueAsync(new YourArgs()); |
|||
|
|||
// Create delayed job |
|||
await _backgroundJobManager.EnqueueAsync( |
|||
new YourArgs(), |
|||
delay: TimeSpan.FromMinutes(5) |
|||
); |
|||
|
|||
// Create recurring job |
|||
await _backgroundJobManager.EnqueueAsync( |
|||
"0 0 * * *", // Cron expression: Execute at 00:00 every day |
|||
new YourArgs() |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 5. Configuration |
|||
|
|||
### 5.1 Job Configuration |
|||
|
|||
* `AbpBackgroundJobOptions.IsJobExecutionEnabled`: Whether to enable job execution. Default value: `true` |
|||
|
|||
## 6. Dependencies |
|||
|
|||
* Volo.Abp.BackgroundJobs |
|||
* Hangfire.Core |
|||
* Hangfire.AspNetCore |
|||
|
|||
## 7. Documentation and Resources |
|||
|
|||
* [Hangfire Official Documentation](https://docs.hangfire.io/) |
|||
* [ABP Framework Documentation](https://docs.abp.io/) |
|||
@ -0,0 +1,94 @@ |
|||
# LINGYUN.Abp.BackgroundJobs.Hangfire |
|||
|
|||
[English](README.EN.md) | 简体中文 |
|||
|
|||
## 1. 介绍 |
|||
|
|||
`LINGYUN.Abp.BackgroundJobs.Hangfire` 是基于 [Hangfire](https://www.hangfire.io/) 实现的ABP后台作业模块。它提供了一个可靠的后台作业执行框架,支持即时任务、延迟任务和周期性任务的执行。 |
|||
|
|||
## 2. 功能特性 |
|||
|
|||
* 支持即时任务执行 |
|||
* 支持延迟任务执行 |
|||
* 支持周期性任务(使用Cron表达式) |
|||
* 与ABP后台作业系统无缝集成 |
|||
* 支持作业执行状态跟踪 |
|||
* 支持作业重试机制 |
|||
|
|||
## 3. 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.BackgroundJobs.Hangfire |
|||
``` |
|||
|
|||
## 4. 使用方法 |
|||
|
|||
1. 添加 `AbpBackgroundJobsHangfireModule` 到模块依赖中: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpBackgroundJobsHangfireModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 配置后台作业: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpBackgroundJobOptions>(options => |
|||
{ |
|||
options.IsJobExecutionEnabled = true; // 启用作业执行 |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
3. 使用后台作业: |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly IBackgroundJobManager _backgroundJobManager; |
|||
|
|||
public YourService(IBackgroundJobManager backgroundJobManager) |
|||
{ |
|||
_backgroundJobManager = backgroundJobManager; |
|||
} |
|||
|
|||
public async Task CreateJobAsync() |
|||
{ |
|||
// 创建即时任务 |
|||
await _backgroundJobManager.EnqueueAsync(new YourArgs()); |
|||
|
|||
// 创建延迟任务 |
|||
await _backgroundJobManager.EnqueueAsync( |
|||
new YourArgs(), |
|||
delay: TimeSpan.FromMinutes(5) |
|||
); |
|||
|
|||
// 创建周期性任务 |
|||
await _backgroundJobManager.EnqueueAsync( |
|||
"0 0 * * *", // Cron表达式:每天0点执行 |
|||
new YourArgs() |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 5. 配置项 |
|||
|
|||
### 5.1 作业配置 |
|||
|
|||
* `AbpBackgroundJobOptions.IsJobExecutionEnabled`: 是否启用作业执行。默认值: `true` |
|||
|
|||
## 6. 依赖项 |
|||
|
|||
* Volo.Abp.BackgroundJobs |
|||
* Hangfire.Core |
|||
* Hangfire.AspNetCore |
|||
|
|||
## 7. 文档和资源 |
|||
|
|||
* [Hangfire官方文档](https://docs.hangfire.io/) |
|||
* [ABP框架文档](https://docs.abp.io/) |
|||
@ -0,0 +1,82 @@ |
|||
# LINGYUN.Abp.BackgroundWorkers.Hangfire |
|||
|
|||
English | [简体中文](README.md) |
|||
|
|||
## 1. Introduction |
|||
|
|||
`LINGYUN.Abp.BackgroundWorkers.Hangfire` is an ABP background worker module implemented based on Hangfire. It provides a reliable way to manage and execute long-running background tasks, supporting automatic start, stop, and periodic execution features. |
|||
|
|||
## 2. Features |
|||
|
|||
* Support for automatic start and stop of background workers |
|||
* Support for periodically executing background tasks |
|||
* Seamless integration with ABP background worker system |
|||
* Worker status management |
|||
* Dependency injection support |
|||
|
|||
## 3. Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.BackgroundWorkers.Hangfire |
|||
``` |
|||
|
|||
## 4. Usage |
|||
|
|||
1. Add `AbpBackgroundWorkersHangfireModule` to your module dependencies: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpBackgroundWorkersHangfireModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Create background worker: |
|||
|
|||
```csharp |
|||
public class YourBackgroundWorker : AsyncPeriodicBackgroundWorkerBase |
|||
{ |
|||
public YourBackgroundWorker( |
|||
AbpAsyncTimer timer, |
|||
IServiceScopeFactory serviceScopeFactory) |
|||
: base(timer, serviceScopeFactory) |
|||
{ |
|||
Timer.Period = 5000; // Execute every 5 seconds |
|||
} |
|||
|
|||
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) |
|||
{ |
|||
// Implement your background task logic here |
|||
await Task.CompletedTask; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. Register background worker: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddTransient<YourBackgroundWorker>(); |
|||
Configure<AbpBackgroundWorkerOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; // Enable background workers |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
## 5. Configuration |
|||
|
|||
### 5.1 Worker Configuration |
|||
|
|||
* `AbpBackgroundWorkerOptions.IsEnabled`: Whether to enable background workers. Default value: `true` |
|||
|
|||
## 6. Dependencies |
|||
|
|||
* Volo.Abp.BackgroundWorkers |
|||
* LINGYUN.Abp.BackgroundJobs.Hangfire |
|||
|
|||
## 7. Documentation and Resources |
|||
|
|||
* [Hangfire Official Documentation](https://docs.hangfire.io/) |
|||
* [ABP Framework Documentation](https://docs.abp.io/) |
|||
@ -0,0 +1,82 @@ |
|||
# LINGYUN.Abp.BackgroundWorkers.Hangfire |
|||
|
|||
[English](README.EN.md) | 简体中文 |
|||
|
|||
## 1. 介绍 |
|||
|
|||
`LINGYUN.Abp.BackgroundWorkers.Hangfire` 是一个基于Hangfire实现的ABP后台工作者模块。它提供了一种可靠的方式来管理和执行长期运行的后台任务,支持自动启动、停止和定期执行等功能。 |
|||
|
|||
## 2. 功能特性 |
|||
|
|||
* 支持后台工作者的自动启动和停止 |
|||
* 支持定期执行的后台任务 |
|||
* 与ABP后台工作者系统无缝集成 |
|||
* 支持工作者状态管理 |
|||
* 支持依赖注入 |
|||
|
|||
## 3. 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.BackgroundWorkers.Hangfire |
|||
``` |
|||
|
|||
## 4. 使用方法 |
|||
|
|||
1. 添加 `AbpBackgroundWorkersHangfireModule` 到模块依赖中: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpBackgroundWorkersHangfireModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 创建后台工作者: |
|||
|
|||
```csharp |
|||
public class YourBackgroundWorker : AsyncPeriodicBackgroundWorkerBase |
|||
{ |
|||
public YourBackgroundWorker( |
|||
AbpAsyncTimer timer, |
|||
IServiceScopeFactory serviceScopeFactory) |
|||
: base(timer, serviceScopeFactory) |
|||
{ |
|||
Timer.Period = 5000; // 每5秒执行一次 |
|||
} |
|||
|
|||
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) |
|||
{ |
|||
// 在这里实现你的后台任务逻辑 |
|||
await Task.CompletedTask; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. 注册后台工作者: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddTransient<YourBackgroundWorker>(); |
|||
Configure<AbpBackgroundWorkerOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; // 启用后台工作者 |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
## 5. 配置项 |
|||
|
|||
### 5.1 工作者配置 |
|||
|
|||
* `AbpBackgroundWorkerOptions.IsEnabled`: 是否启用后台工作者。默认值: `true` |
|||
|
|||
## 6. 依赖项 |
|||
|
|||
* Volo.Abp.BackgroundWorkers |
|||
* LINGYUN.Abp.BackgroundJobs.Hangfire |
|||
|
|||
## 7. 文档和资源 |
|||
|
|||
* [Hangfire官方文档](https://docs.hangfire.io/) |
|||
* [ABP框架文档](https://docs.abp.io/) |
|||
@ -0,0 +1,85 @@ |
|||
# LINGYUN.Abp.BlobStoring.Aliyun |
|||
|
|||
Aliyun OSS implementation of the ABP framework's object storage provider **IBlobProvider**. |
|||
|
|||
## Features |
|||
|
|||
* Implements ABP's IBlobProvider interface using Aliyun OSS service |
|||
* Supports multi-tenant Blob storage |
|||
* Automatic Bucket creation |
|||
* Configurable Bucket access control |
|||
* STS Token access support |
|||
* Customizable Blob naming strategy |
|||
|
|||
## Module Reference |
|||
|
|||
First, define the **appsettings.json** file: |
|||
|
|||
```json |
|||
{ |
|||
"Aliyun": { |
|||
"OSS": { |
|||
"BucketName": "your-bucket-name", |
|||
"Endpoint": "http://oss-cn-shanghai.aliyuncs.com", |
|||
"CreateBucketIfNotExists": true |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
Then reference the module in your project: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpBlobStoringAliyunModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
### OSS Configuration |
|||
|
|||
* **BucketName** |
|||
* Description: OSS storage space name |
|||
* Type: Optional |
|||
* Default: Container name |
|||
|
|||
* **Endpoint** |
|||
* Description: OSS service access point |
|||
* Type: Required |
|||
* Example: http://oss-cn-shanghai.aliyuncs.com |
|||
|
|||
* **CreateBucketIfNotExists** |
|||
* Description: Whether to automatically create the bucket if it doesn't exist |
|||
* Type: Optional |
|||
* Default: false |
|||
|
|||
* **CreateBucketReferer** |
|||
* Description: Bucket access whitelist |
|||
* Type: Optional |
|||
|
|||
### Blob Naming Rules |
|||
|
|||
* Container (Bucket) naming rules: |
|||
* Length must be between 3-63 characters |
|||
* Can only contain lowercase letters, numbers, and hyphens |
|||
* Must start with a letter or number |
|||
* Cannot start or end with a hyphen |
|||
|
|||
* Blob naming rules: |
|||
* Tenant: `tenants/{tenantId}/{blobName}` |
|||
* Host: `host/{blobName}` |
|||
|
|||
## Performance Optimization |
|||
|
|||
* Uses distributed caching for STS Token storage |
|||
* Supports data redundancy configuration |
|||
* Configurable Bucket access control for enhanced security |
|||
|
|||
## Related Modules |
|||
|
|||
* [LINGYUN.Abp.Aliyun](../../cloud-aliyun/LINGYUN.Abp.Aliyun/README.md) - Provides Aliyun basic integration |
|||
|
|||
[点击查看中文文档](README.md) |
|||
@ -0,0 +1,46 @@ |
|||
# LINGYUN.Abp.Core |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.Core` is a basic core module that provides some common functionalities and extensions. |
|||
|
|||
## Features |
|||
|
|||
* Dynamic Options Provider (`DynamicOptionsProvider<TValue>`) |
|||
* Simplifies the complex steps of calling interfaces before using configuration |
|||
* Supports lazy loading of configuration values |
|||
* Provides one-time running mechanism to ensure configuration is loaded only once |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Core |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Add `[DependsOn(typeof(AbpCommonModule))]` to your module class. |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpCommonModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Use Dynamic Options Provider: |
|||
|
|||
```csharp |
|||
public class YourOptionsProvider : DynamicOptionsProvider<YourOptions> |
|||
{ |
|||
public YourOptionsProvider(IOptions<YourOptions> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,46 @@ |
|||
# LINGYUN.Abp.Core |
|||
|
|||
## 介绍 |
|||
|
|||
`LINGYUN.Abp.Core` 是一个基础核心模块,提供了一些通用的功能和扩展。 |
|||
|
|||
## 功能 |
|||
|
|||
* 动态选项提供者 (`DynamicOptionsProvider<TValue>`) |
|||
* 简化需要在使用配置前自行调用接口的繁复步骤 |
|||
* 支持延迟加载配置值 |
|||
* 提供一次性运行机制,确保配置只被加载一次 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Core |
|||
``` |
|||
|
|||
## 使用 |
|||
|
|||
1. 添加 `[DependsOn(typeof(AbpCommonModule))]` 到你的模块类上。 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpCommonModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 使用动态选项提供者: |
|||
|
|||
```csharp |
|||
public class YourOptionsProvider : DynamicOptionsProvider<YourOptions> |
|||
{ |
|||
public YourOptionsProvider(IOptions<YourOptions> options) |
|||
: base(options) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 链接 |
|||
|
|||
* [English document](./README.EN.md) |
|||
@ -0,0 +1,68 @@ |
|||
# LINGYUN.Abp.ExceptionHandling.Emailing |
|||
|
|||
An email notification type based on the ABP framework's **IExceptionSubscriber** interface. |
|||
|
|||
## Features |
|||
|
|||
* Supports exception email notifications |
|||
* Supports custom email templates |
|||
* Supports multilingual email content |
|||
* Supports stack trace sending |
|||
* Supports mapping between exception types and recipient mailboxes |
|||
|
|||
## Configuration and Usage |
|||
|
|||
Before use, you need to configure **AbpExceptionHandlingOptions** to define which exceptions need notifications, |
|||
then configure **AbpEmailExceptionHandlingOptions** to define specific exception type notification methods. |
|||
|
|||
```csharp |
|||
[DependsOn( |
|||
typeof(AbpEmailingExceptionHandlingModule) |
|||
)] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Customize exceptions to handle |
|||
Configure<AbpExceptionHandlingOptions>(options => |
|||
{ |
|||
// Add exception types that need to be handled |
|||
options.Handlers.Add<AbpException>(); |
|||
}); |
|||
// Customize exception types that need email notifications |
|||
Configure<AbpEmailExceptionHandlingOptions>(options => |
|||
{ |
|||
// Whether to send stack trace information |
|||
options.SendStackTrace = true; |
|||
// Default receiving email for unspecified exception receivers |
|||
options.DefaultReceiveEmail = "colin.in@foxmail.com"; |
|||
// Specify which email to send for a certain exception type |
|||
options.HandReceivedException<AbpException>("colin.in@foxmail.com"); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
* `SendStackTrace`: Whether to include exception stack trace in the email |
|||
* `DefaultTitle`: Default email title |
|||
* `DefaultContentHeader`: Default email content header |
|||
* `DefaultContentFooter`: Default email content footer |
|||
* `DefaultReceiveEmail`: Default exception receiving email |
|||
* `Handlers`: Dictionary mapping exception types to receiving emails |
|||
|
|||
## Localization Resources |
|||
|
|||
The module includes localization resources in the following languages: |
|||
* en |
|||
* zh-Hans |
|||
|
|||
## Related Links |
|||
|
|||
* [Base Exception Handling Module](../LINGYUN.Abp.ExceptionHandling/README.EN.md) |
|||
* [Exception Real-time Notification Module](../../../modules/realtime-notifications/LINGYUN.Abp.ExceptionHandling.Notifications/README.EN.md) |
|||
|
|||
## More |
|||
|
|||
For more information and configuration examples, please refer to the [documentation](https://github.com/colinin/abp-next-admin). |
|||
@ -0,0 +1,46 @@ |
|||
# LINGYUN.Abp.ExceptionHandling |
|||
|
|||
A secondary extension based on the ABP framework's **IExceptionSubscriber** interface, used for customizing exception notification methods. |
|||
|
|||
## Features |
|||
|
|||
* Provides unified exception handling and notification mechanism |
|||
* Supports custom exception handlers |
|||
* Supports exception notification filtering |
|||
* Supports integration with other notification modules (such as email, real-time notifications, etc.) |
|||
|
|||
## Configuration and Usage |
|||
|
|||
Just configure **AbpExceptionHandlingOptions** to define which exceptions need to send notifications. |
|||
|
|||
```csharp |
|||
[DependsOn( |
|||
typeof(AbpExceptionHandlingModule) |
|||
)] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Customize exception handling |
|||
Configure<AbpExceptionHandlingOptions>(options => |
|||
{ |
|||
// Add exception types that need to be handled |
|||
options.Handlers.Add<AbpException>(); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
* `Handlers`: List of exception handlers, used to define which exception types need to be handled |
|||
* `HasNotifierError`: Check if an exception needs to send notifications |
|||
|
|||
## Extension Modules |
|||
|
|||
* [LINGYUN.Abp.ExceptionHandling.Emailing](../LINGYUN.Abp.ExceptionHandling.Emailing/README.EN.md): Exception email notification module |
|||
* [LINGYUN.Abp.ExceptionHandling.Notifications](../../../modules/realtime-notifications/LINGYUN.Abp.ExceptionHandling.Notifications/README.EN.md): Exception real-time notification module |
|||
|
|||
## More |
|||
|
|||
For more information and configuration examples, please refer to the [documentation](https://github.com/colinin/abp-next-admin). |
|||
@ -0,0 +1,49 @@ |
|||
# LINGYUN.Abp.Features.LimitValidation.Redis.Client |
|||
|
|||
Redis-based client feature limit validation component |
|||
|
|||
## Features |
|||
|
|||
* Inherits all functionality from LINGYUN.Abp.Features.LimitValidation.Redis |
|||
* Specifically designed for client application feature limit validation |
|||
* Support client-specific limitation policies |
|||
|
|||
## Configuration and Usage |
|||
|
|||
1. Add module dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpFeaturesValidationRedisClientModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
2. Configure Redis options (same as LINGYUN.Abp.Features.LimitValidation.Redis) |
|||
|
|||
```json |
|||
{ |
|||
"Features": { |
|||
"Validation": { |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1", |
|||
"InstanceName": "YourInstanceName" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Usage Example |
|||
|
|||
```csharp |
|||
// Limit a client feature to be called at most 1000 times per day |
|||
[RequiresLimitFeature("YourClientFeature.DailyLimit", "YourClientFeature.Interval", LimitPolicy.Days)] |
|||
public async Task YourClientMethod() |
|||
{ |
|||
// Client business logic |
|||
} |
|||
``` |
|||
|
|||
[简体中文](./README.md) | [English](./README.EN.md) |
|||
@ -0,0 +1,49 @@ |
|||
# LINGYUN.Abp.Features.LimitValidation.Redis.Client |
|||
|
|||
基于Redis的客户端功能限制验证组件 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 继承自LINGYUN.Abp.Features.LimitValidation.Redis的所有功能 |
|||
* 专门针对客户端应用的功能限制验证 |
|||
* 支持客户端特定的限制策略 |
|||
|
|||
## 配置使用 |
|||
|
|||
1. 添加模块依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpFeaturesValidationRedisClientModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
2. 配置Redis选项(与LINGYUN.Abp.Features.LimitValidation.Redis相同) |
|||
|
|||
```json |
|||
{ |
|||
"Features": { |
|||
"Validation": { |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1", |
|||
"InstanceName": "YourInstanceName" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 使用示例 |
|||
|
|||
```csharp |
|||
// 限制客户端某个功能每天最多调用1000次 |
|||
[RequiresLimitFeature("YourClientFeature.DailyLimit", "YourClientFeature.Interval", LimitPolicy.Days)] |
|||
public async Task YourClientMethod() |
|||
{ |
|||
// 客户端业务逻辑 |
|||
} |
|||
``` |
|||
|
|||
[简体中文](./README.md) | [English](./README.EN.md) |
|||
@ -0,0 +1,56 @@ |
|||
# LINGYUN.Abp.Features.LimitValidation.Redis |
|||
|
|||
Redis-based feature limit validation component |
|||
|
|||
## Features |
|||
|
|||
* Use Redis to store and validate feature call count limits |
|||
* Support Lua scripts for atomic operations |
|||
* Support multiple limitation policies (minute, hour, day, week, month, year) |
|||
* Support custom Redis configuration options |
|||
|
|||
## Configuration and Usage |
|||
|
|||
1. Add module dependency |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpFeaturesValidationRedisModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
2. Configure Redis options |
|||
|
|||
```json |
|||
{ |
|||
"Features": { |
|||
"Validation": { |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1", |
|||
"InstanceName": "YourInstanceName" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
* Configuration: Redis connection string |
|||
* InstanceName: Redis instance name (optional) |
|||
* ConfigurationOptions: Redis configuration options (optional, for more detailed Redis configuration) |
|||
|
|||
## Usage Example |
|||
|
|||
```csharp |
|||
// Limit a method to be called at most 100 times per minute |
|||
[RequiresLimitFeature("YourFeature.MethodLimit", "YourFeature.Interval", LimitPolicy.Minute)] |
|||
public async Task YourMethod() |
|||
{ |
|||
// Business logic |
|||
} |
|||
``` |
|||
|
|||
[简体中文](./README.md) | [English](./README.EN.md) |
|||
@ -0,0 +1,56 @@ |
|||
# LINGYUN.Abp.Features.LimitValidation.Redis |
|||
|
|||
基于Redis的功能限制验证组件 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 使用Redis存储和验证功能调用次数限制 |
|||
* 支持Lua脚本进行原子性操作 |
|||
* 支持多种限制策略(分钟、小时、天、周、月、年) |
|||
* 支持自定义Redis配置选项 |
|||
|
|||
## 配置使用 |
|||
|
|||
1. 添加模块依赖 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpFeaturesValidationRedisModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
// other |
|||
} |
|||
``` |
|||
|
|||
2. 配置Redis选项 |
|||
|
|||
```json |
|||
{ |
|||
"Features": { |
|||
"Validation": { |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1", |
|||
"InstanceName": "YourInstanceName" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 配置项说明 |
|||
|
|||
* Configuration:Redis连接字符串 |
|||
* InstanceName:Redis实例名称(可选) |
|||
* ConfigurationOptions:Redis配置选项(可选,用于更详细的Redis配置) |
|||
|
|||
## 使用示例 |
|||
|
|||
```csharp |
|||
// 限制某个方法每分钟最多调用100次 |
|||
[RequiresLimitFeature("YourFeature.MethodLimit", "YourFeature.Interval", LimitPolicy.Minute)] |
|||
public async Task YourMethod() |
|||
{ |
|||
// 业务逻辑 |
|||
} |
|||
``` |
|||
|
|||
[简体中文](./README.md) | [English](./README.EN.md) |
|||
@ -0,0 +1,83 @@ |
|||
# LINGYUN.Abp.Hangfire.Dashboard |
|||
|
|||
English | [简体中文](README.md) |
|||
|
|||
## 1. Introduction |
|||
|
|||
`LINGYUN.Abp.Hangfire.Dashboard` is an ABP module for integrating the Hangfire dashboard, providing a user-friendly web interface for monitoring and managing Hangfire background jobs. This module supports permission control and authentication to ensure secure access to the dashboard. |
|||
|
|||
## 2. Features |
|||
|
|||
* Integration with Hangfire dashboard |
|||
* Access control based on ABP permission system |
|||
* Support for loading dashboard in iframe |
|||
* Access token authentication support |
|||
* Dashboard permission caching mechanism |
|||
|
|||
## 3. Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Hangfire.Dashboard |
|||
``` |
|||
|
|||
## 4. Usage |
|||
|
|||
1. Add `AbpHangfireDashboardModule` to your module dependencies: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHangfireDashboardModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Configure middleware: |
|||
|
|||
```csharp |
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
|
|||
// Add Hangfire authentication middleware |
|||
app.UseHangfireAuthorication(); |
|||
} |
|||
``` |
|||
|
|||
3. Configure dashboard options: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<DashboardOptions>(options => |
|||
{ |
|||
options.Authorization = new[] |
|||
{ |
|||
new DashboardAuthorizationFilter("YourPermissionName") |
|||
}; |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
## 5. Authentication and Authorization |
|||
|
|||
### 5.1 Authentication Methods |
|||
|
|||
The module supports the following authentication methods: |
|||
* Pass access token via URL parameter: `?access_token=your_token` |
|||
* Pass access token via Cookie |
|||
* Pass access token via Authorization Header |
|||
|
|||
### 5.2 Permission Caching |
|||
|
|||
Permission check results are cached for 5 minutes to improve performance. |
|||
|
|||
## 6. Dependencies |
|||
|
|||
* Volo.Abp.Authorization |
|||
* Volo.Abp.Hangfire |
|||
* Microsoft.Extensions.Caching.Memory |
|||
|
|||
## 7. Documentation and Resources |
|||
|
|||
* [Hangfire Official Documentation](https://docs.hangfire.io/) |
|||
* [ABP Framework Documentation](https://docs.abp.io/) |
|||
@ -0,0 +1,83 @@ |
|||
# LINGYUN.Abp.Hangfire.Dashboard |
|||
|
|||
[English](README.EN.md) | 简体中文 |
|||
|
|||
## 1. 介绍 |
|||
|
|||
`LINGYUN.Abp.Hangfire.Dashboard` 是一个用于集成Hangfire仪表板的ABP模块,它提供了一个用户友好的Web界面来监控和管理Hangfire后台作业。该模块支持权限控制和认证,确保仪表板的安全访问。 |
|||
|
|||
## 2. 功能特性 |
|||
|
|||
* 集成Hangfire仪表板 |
|||
* 基于ABP权限系统的访问控制 |
|||
* 支持通过iframe加载仪表板 |
|||
* 支持访问令牌认证 |
|||
* 仪表板权限缓存机制 |
|||
|
|||
## 3. 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Hangfire.Dashboard |
|||
``` |
|||
|
|||
## 4. 使用方法 |
|||
|
|||
1. 添加 `AbpHangfireDashboardModule` 到模块依赖中: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHangfireDashboardModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 配置中间件: |
|||
|
|||
```csharp |
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
|
|||
// 添加Hangfire认证中间件 |
|||
app.UseHangfireAuthorication(); |
|||
} |
|||
``` |
|||
|
|||
3. 配置仪表板选项: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<DashboardOptions>(options => |
|||
{ |
|||
options.Authorization = new[] |
|||
{ |
|||
new DashboardAuthorizationFilter("YourPermissionName") |
|||
}; |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
## 5. 认证和授权 |
|||
|
|||
### 5.1 认证方式 |
|||
|
|||
模块支持以下认证方式: |
|||
* 通过URL参数传递访问令牌: `?access_token=your_token` |
|||
* 通过Cookie传递访问令牌 |
|||
* 通过Authorization Header传递访问令牌 |
|||
|
|||
### 5.2 权限缓存 |
|||
|
|||
权限检查结果会被缓存5分钟,以提高性能。 |
|||
|
|||
## 6. 依赖项 |
|||
|
|||
* Volo.Abp.Authorization |
|||
* Volo.Abp.Hangfire |
|||
* Microsoft.Extensions.Caching.Memory |
|||
|
|||
## 7. 文档和资源 |
|||
|
|||
* [Hangfire官方文档](https://docs.hangfire.io/) |
|||
* [ABP框架文档](https://docs.abp.io/) |
|||
@ -0,0 +1,77 @@ |
|||
# LINGYUN.Abp.Hangfire.Storage.MySql |
|||
|
|||
English | [简体中文](README.md) |
|||
|
|||
## 1. Introduction |
|||
|
|||
`LINGYUN.Abp.Hangfire.Storage.MySql` is an ABP module for configuring Hangfire to use MySQL as storage. This module provides a simple configuration approach to easily use MySQL as Hangfire's persistent storage. |
|||
|
|||
## 2. Features |
|||
|
|||
* Simple MySQL storage configuration |
|||
* Custom connection string support |
|||
* MySQL storage options configuration |
|||
* Seamless integration with ABP configuration system |
|||
|
|||
## 3. Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Hangfire.Storage.MySql |
|||
``` |
|||
|
|||
## 4. Usage |
|||
|
|||
1. Add `AbpHangfireMySqlStorageModule` to your module dependencies: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHangfireMySqlStorageModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Configure connection string and storage options in appsettings.json: |
|||
|
|||
```json |
|||
{ |
|||
"Hangfire": { |
|||
"MySql": { |
|||
"Connection": "Server=localhost;Database=YourDb;Uid=root;Pwd=123456;", |
|||
"TablePrefix": "Hangfire", |
|||
"CommandBatchMaxTimeout": "00:05:00", |
|||
"SlidingInvisibilityTimeout": "00:05:00", |
|||
"QueuePollInterval": "00:00:00", |
|||
"UseRecommendedIsolationLevel": true, |
|||
"DisableGlobalLocks": true |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 5. Configuration |
|||
|
|||
### 5.1 Connection String Configuration |
|||
|
|||
The module looks for connection string in the following order: |
|||
1. `Hangfire:MySql:Connection` |
|||
2. `ConnectionStrings:Default` |
|||
|
|||
### 5.2 Storage Options |
|||
|
|||
* `TablePrefix`: Table prefix for database tables |
|||
* `CommandBatchMaxTimeout`: Maximum timeout for command batches |
|||
* `SlidingInvisibilityTimeout`: Sliding invisibility timeout |
|||
* `QueuePollInterval`: Queue polling interval |
|||
* `UseRecommendedIsolationLevel`: Whether to use recommended isolation level |
|||
* `DisableGlobalLocks`: Whether to disable global locks |
|||
|
|||
## 6. Dependencies |
|||
|
|||
* Volo.Abp.Hangfire |
|||
* Hangfire.MySql.Core |
|||
|
|||
## 7. Documentation and Resources |
|||
|
|||
* [Hangfire Official Documentation](https://docs.hangfire.io/) |
|||
* [Hangfire.MySql.Core Documentation](https://github.com/arnoldasgudas/Hangfire.MySqlStorage) |
|||
* [ABP Framework Documentation](https://docs.abp.io/) |
|||
@ -0,0 +1,77 @@ |
|||
# LINGYUN.Abp.Hangfire.Storage.MySql |
|||
|
|||
[English](README.EN.md) | 简体中文 |
|||
|
|||
## 1. 介绍 |
|||
|
|||
`LINGYUN.Abp.Hangfire.Storage.MySql` 是一个用于配置Hangfire使用MySQL作为存储的ABP模块。该模块提供了简单的配置方式,让你能够轻松地将MySQL作为Hangfire的持久化存储。 |
|||
|
|||
## 2. 功能特性 |
|||
|
|||
* 简单的MySQL存储配置 |
|||
* 支持自定义连接字符串 |
|||
* 支持MySQL存储选项配置 |
|||
* 与ABP配置系统无缝集成 |
|||
|
|||
## 3. 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Hangfire.Storage.MySql |
|||
``` |
|||
|
|||
## 4. 使用方法 |
|||
|
|||
1. 添加 `AbpHangfireMySqlStorageModule` 到模块依赖中: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHangfireMySqlStorageModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 在appsettings.json中配置连接字符串和存储选项: |
|||
|
|||
```json |
|||
{ |
|||
"Hangfire": { |
|||
"MySql": { |
|||
"Connection": "Server=localhost;Database=YourDb;Uid=root;Pwd=123456;", |
|||
"TablePrefix": "Hangfire", |
|||
"CommandBatchMaxTimeout": "00:05:00", |
|||
"SlidingInvisibilityTimeout": "00:05:00", |
|||
"QueuePollInterval": "00:00:00", |
|||
"UseRecommendedIsolationLevel": true, |
|||
"DisableGlobalLocks": true |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 5. 配置项 |
|||
|
|||
### 5.1 连接字符串配置 |
|||
|
|||
模块会按以下顺序查找连接字符串: |
|||
1. `Hangfire:MySql:Connection` |
|||
2. `ConnectionStrings:Default` |
|||
|
|||
### 5.2 存储选项 |
|||
|
|||
* `TablePrefix`: 数据表前缀 |
|||
* `CommandBatchMaxTimeout`: 命令批处理最大超时时间 |
|||
* `SlidingInvisibilityTimeout`: 滑动不可见超时时间 |
|||
* `QueuePollInterval`: 队列轮询间隔 |
|||
* `UseRecommendedIsolationLevel`: 是否使用推荐的隔离级别 |
|||
* `DisableGlobalLocks`: 是否禁用全局锁 |
|||
|
|||
## 6. 依赖项 |
|||
|
|||
* Volo.Abp.Hangfire |
|||
* Hangfire.MySql.Core |
|||
|
|||
## 7. 文档和资源 |
|||
|
|||
* [Hangfire官方文档](https://docs.hangfire.io/) |
|||
* [Hangfire.MySql.Core文档](https://github.com/arnoldasgudas/Hangfire.MySqlStorage) |
|||
* [ABP框架文档](https://docs.abp.io/) |
|||
@ -0,0 +1,75 @@ |
|||
# LINGYUN.Abp.Hangfire.Storage.SqlServer |
|||
|
|||
English | [简体中文](README.md) |
|||
|
|||
## 1. Introduction |
|||
|
|||
`LINGYUN.Abp.Hangfire.Storage.SqlServer` is an ABP module for configuring Hangfire to use SQL Server as storage. This module provides a simple configuration approach to easily use SQL Server as Hangfire's persistent storage. |
|||
|
|||
## 2. Features |
|||
|
|||
* Simple SQL Server storage configuration |
|||
* Custom connection string support |
|||
* SQL Server storage options configuration |
|||
* Seamless integration with ABP configuration system |
|||
|
|||
## 3. Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Hangfire.Storage.SqlServer |
|||
``` |
|||
|
|||
## 4. Usage |
|||
|
|||
1. Add `AbpHangfireSqlServerStorageModule` to your module dependencies: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHangfireSqlServerStorageModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. Configure connection string and storage options in appsettings.json: |
|||
|
|||
```json |
|||
{ |
|||
"Hangfire": { |
|||
"SqlServer": { |
|||
"Connection": "Server=localhost;Database=YourDb;Trusted_Connection=True;", |
|||
"CommandBatchMaxTimeout": "00:05:00", |
|||
"SlidingInvisibilityTimeout": "00:05:00", |
|||
"QueuePollInterval": "00:00:00", |
|||
"UseRecommendedIsolationLevel": true, |
|||
"DisableGlobalLocks": true |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 5. Configuration |
|||
|
|||
### 5.1 Connection String Configuration |
|||
|
|||
The module looks for connection string in the following order: |
|||
1. `Hangfire:SqlServer:Connection` |
|||
2. `ConnectionStrings:Default` |
|||
|
|||
### 5.2 Storage Options |
|||
|
|||
* `CommandBatchMaxTimeout`: Maximum timeout for command batches |
|||
* `SlidingInvisibilityTimeout`: Sliding invisibility timeout |
|||
* `QueuePollInterval`: Queue polling interval |
|||
* `UseRecommendedIsolationLevel`: Whether to use recommended isolation level |
|||
* `DisableGlobalLocks`: Whether to disable global locks |
|||
|
|||
## 6. Dependencies |
|||
|
|||
* Volo.Abp.Hangfire |
|||
* Hangfire.SqlServer |
|||
|
|||
## 7. Documentation and Resources |
|||
|
|||
* [Hangfire Official Documentation](https://docs.hangfire.io/) |
|||
* [Hangfire.SqlServer Documentation](https://docs.hangfire.io/en/latest/configuration/using-sql-server.html) |
|||
* [ABP Framework Documentation](https://docs.abp.io/) |
|||
@ -0,0 +1,75 @@ |
|||
# LINGYUN.Abp.Hangfire.Storage.SqlServer |
|||
|
|||
[English](README.EN.md) | 简体中文 |
|||
|
|||
## 1. 介绍 |
|||
|
|||
`LINGYUN.Abp.Hangfire.Storage.SqlServer` 是一个用于配置Hangfire使用SQL Server作为存储的ABP模块。该模块提供了简单的配置方式,让你能够轻松地将SQL Server作为Hangfire的持久化存储。 |
|||
|
|||
## 2. 功能特性 |
|||
|
|||
* 简单的SQL Server存储配置 |
|||
* 支持自定义连接字符串 |
|||
* 支持SQL Server存储选项配置 |
|||
* 与ABP配置系统无缝集成 |
|||
|
|||
## 3. 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Hangfire.Storage.SqlServer |
|||
``` |
|||
|
|||
## 4. 使用方法 |
|||
|
|||
1. 添加 `AbpHangfireSqlServerStorageModule` 到模块依赖中: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHangfireSqlServerStorageModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
2. 在appsettings.json中配置连接字符串和存储选项: |
|||
|
|||
```json |
|||
{ |
|||
"Hangfire": { |
|||
"SqlServer": { |
|||
"Connection": "Server=localhost;Database=YourDb;Trusted_Connection=True;", |
|||
"CommandBatchMaxTimeout": "00:05:00", |
|||
"SlidingInvisibilityTimeout": "00:05:00", |
|||
"QueuePollInterval": "00:00:00", |
|||
"UseRecommendedIsolationLevel": true, |
|||
"DisableGlobalLocks": true |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 5. 配置项 |
|||
|
|||
### 5.1 连接字符串配置 |
|||
|
|||
模块会按以下顺序查找连接字符串: |
|||
1. `Hangfire:SqlServer:Connection` |
|||
2. `ConnectionStrings:Default` |
|||
|
|||
### 5.2 存储选项 |
|||
|
|||
* `CommandBatchMaxTimeout`: 命令批处理最大超时时间 |
|||
* `SlidingInvisibilityTimeout`: 滑动不可见超时时间 |
|||
* `QueuePollInterval`: 队列轮询间隔 |
|||
* `UseRecommendedIsolationLevel`: 是否使用推荐的隔离级别 |
|||
* `DisableGlobalLocks`: 是否禁用全局锁 |
|||
|
|||
## 6. 依赖项 |
|||
|
|||
* Volo.Abp.Hangfire |
|||
* Hangfire.SqlServer |
|||
|
|||
## 7. 文档和资源 |
|||
|
|||
* [Hangfire官方文档](https://docs.hangfire.io/) |
|||
* [Hangfire.SqlServer文档](https://docs.hangfire.io/en/latest/configuration/using-sql-server.html) |
|||
* [ABP框架文档](https://docs.abp.io/) |
|||
@ -0,0 +1,45 @@ |
|||
# LINGYUN.Abp.Http.Client.Wrapper |
|||
|
|||
HTTP client wrapper module for automatically adding wrapper request headers in HTTP client requests. |
|||
|
|||
[简体中文](./README.md) |
|||
|
|||
## Features |
|||
|
|||
* Automatic addition of wrapper request headers |
|||
* Integration with ABP HTTP client |
|||
* Support for global wrapper configuration |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Http.Client.Wrapper |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHttpClientWrapperModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpWrapperOptions>(options => |
|||
{ |
|||
// Enable wrapper |
|||
options.IsEnabled = true; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## How It Works |
|||
|
|||
When the wrapper is enabled (`AbpWrapperOptions.IsEnabled = true`), the module automatically adds the `_AbpWrapResult` header to all HTTP client requests. |
|||
When the wrapper is disabled (`AbpWrapperOptions.IsEnabled = false`), the module automatically adds the `_AbpDontWrapResult` header to all HTTP client requests. |
|||
|
|||
This ensures that the HTTP client request results remain consistent with the server-side wrapper configuration. |
|||
|
|||
## Source Code |
|||
|
|||
[LINGYUN.Abp.Http.Client.Wrapper](https://github.com/colinin/abp-next-admin/tree/master/aspnet-core/framework/common/LINGYUN.Abp.Http.Client.Wrapper) |
|||
@ -0,0 +1,45 @@ |
|||
# LINGYUN.Abp.Http.Client.Wrapper |
|||
|
|||
HTTP客户端包装器模块,用于在HTTP客户端请求中自动添加包装器请求头。 |
|||
|
|||
[English](./README.EN.md) |
|||
|
|||
## 功能特性 |
|||
|
|||
* 自动添加包装器请求头 |
|||
* 与ABP HTTP客户端集成 |
|||
* 支持全局配置包装器开关 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Http.Client.Wrapper |
|||
``` |
|||
|
|||
## 配置使用 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpHttpClientWrapperModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpWrapperOptions>(options => |
|||
{ |
|||
// 启用包装器 |
|||
options.IsEnabled = true; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 工作原理 |
|||
|
|||
当启用包装器时(`AbpWrapperOptions.IsEnabled = true`),模块会自动为所有HTTP客户端请求添加 `_AbpWrapResult` 请求头。 |
|||
当禁用包装器时(`AbpWrapperOptions.IsEnabled = false`),模块会自动为所有HTTP客户端请求添加 `_AbpDontWrapResult` 请求头。 |
|||
|
|||
这样可以确保HTTP客户端的请求结果与服务器端的包装配置保持一致。 |
|||
|
|||
## 源码位置 |
|||
|
|||
[LINGYUN.Abp.Http.Client.Wrapper](https://github.com/colinin/abp-next-admin/tree/master/aspnet-core/framework/common/LINGYUN.Abp.Http.Client.Wrapper) |
|||
@ -0,0 +1,106 @@ |
|||
# LINGYUN.Abp.IP2Region |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.IP2Region` is an ABP framework module based on IP2Region, providing IP address query functionality. This module integrates the IP2Region.Net library and provides convenient IP address query services. |
|||
|
|||
## Features |
|||
|
|||
* Provides IP address query service |
|||
* Supports multiple caching strategies |
|||
* Built-in IP database file |
|||
* Supports ABP virtual file system |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.IP2Region |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Add `[DependsOn(typeof(AbpIP2RegionModule))]` to your module class. |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpIP2RegionModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Inject and use the IP query service: |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly ISearcher _searcher; |
|||
|
|||
public YourService(ISearcher searcher) |
|||
{ |
|||
_searcher = searcher; |
|||
} |
|||
|
|||
public async Task<string> SearchIpInfo(string ip) |
|||
{ |
|||
return await _searcher.SearchAsync(ip); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## IP2Region.Net Library Description |
|||
|
|||
### Installation |
|||
|
|||
Install the package with [NuGet](https://www.nuget.org/packages/IP2Region.Net) |
|||
|
|||
```bash |
|||
Install-Package IP2Region.Net |
|||
``` |
|||
|
|||
### Usage |
|||
|
|||
```csharp |
|||
using IP2Region.Net.Abstractions; |
|||
using IP2Region.Net.XDB; |
|||
|
|||
ISearcher searcher = new Searcher(CachePolicy , "your xdb file path"); |
|||
``` |
|||
|
|||
### Cache Policy Description |
|||
| Cache Policy | Description | Thread Safe | |
|||
|-------------------------|------------------------------------------------------------------------------------------------------------|-------------| |
|||
| CachePolicy.Content | Cache the entire `xdb` data. | Yes | |
|||
| CachePolicy.VectorIndex | Cache `vecotorIndex` to speed up queries and reduce system io pressure by reducing one fixed IO operation. | Yes | |
|||
| CachePolicy.File | Completely file-based queries | Yes | |
|||
|
|||
### XDB File Description |
|||
Generate using [maker](https://github.com/lionsoul2014/ip2region/tree/master/maker/csharp), or [download](https://github.com/lionsoul2014/ip2region/blob/master/data/ip2region.xdb) pre-generated xdb files |
|||
|
|||
## Performance |
|||
|
|||
``` ini |
|||
BenchmarkDotNet=v0.13.2, OS=macOS 13.4.1 (c) (22F770820d) [Darwin 22.5.0] |
|||
Apple M1, 1 CPU, 8 logical and 8 physical cores |
|||
.NET SDK=7.0.306 |
|||
[Host] : .NET 6.0.20 (6.0.2023.32017), Arm64 RyuJIT AdvSIMD |
|||
DefaultJob : .NET 6.0.20 (6.0.2023.32017), Arm64 RyuJIT AdvSIMD |
|||
``` |
|||
|
|||
| Method | Mean | Error | StdDev | |
|||
|-------------------------|-----------:|---------:|---------:| |
|||
| CachePolicy_Content | 155.7 ns | 0.46 ns | 0.39 ns | |
|||
| CachePolicy_File | 2,186.8 ns | 34.27 ns | 32.06 ns | |
|||
| CachePolicy_VectorIndex | 1,570.3 ns | 27.53 ns | 22.99 ns | |
|||
|
|||
## Contributing |
|||
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. |
|||
|
|||
Please make sure to update tests as appropriate. |
|||
|
|||
## License |
|||
[Apache License 2.0](https://github.com/lionsoul2014/ip2region/blob/master/LICENSE.md) |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,73 @@ |
|||
# LINGYUN.Abp.IdGenerator |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.IdGenerator` is a distributed ID generator module that implements the Snowflake algorithm to generate distributed unique IDs. |
|||
|
|||
## Features |
|||
|
|||
* Snowflake Algorithm ID Generator (`SnowflakeIdGenerator`) |
|||
* Support for custom worker ID and datacenter ID |
|||
* Support for custom sequence bits |
|||
* Support for time rollback handling |
|||
* Provides unique ID generation in distributed environments |
|||
|
|||
## Configuration |
|||
|
|||
### SnowflakeIdOptions |
|||
|
|||
* `WorkerIdBits` (default: 5) - Number of bits for worker ID |
|||
* `DatacenterIdBits` (default: 5) - Number of bits for datacenter ID |
|||
* `Sequence` (default: 0) - Initial value for sequence |
|||
* `SequenceBits` (default: 12) - Number of bits for sequence |
|||
* `UsePreviousInTimeRollback` (default: true) - Whether to use previous timestamp when time rolls back |
|||
* `WorkerId` - Worker ID, if not specified, gets from environment variable WORKERID or generates randomly |
|||
* `DatacenterId` - Datacenter ID, if not specified, gets from environment variable DATACENTERID or generates randomly |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.IdGenerator |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Add `[DependsOn(typeof(AbpIdGeneratorModule))]` to your module class. |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpIdGeneratorModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<SnowflakeIdOptions>(options => |
|||
{ |
|||
options.WorkerId = 1; |
|||
options.DatacenterId = 1; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Inject and use the ID generator: |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly IDistributedIdGenerator _idGenerator; |
|||
|
|||
public YourService(IDistributedIdGenerator idGenerator) |
|||
{ |
|||
_idGenerator = idGenerator; |
|||
} |
|||
|
|||
public long CreateId() |
|||
{ |
|||
return _idGenerator.Create(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,73 @@ |
|||
# LINGYUN.Abp.IdGenerator |
|||
|
|||
## 介绍 |
|||
|
|||
`LINGYUN.Abp.IdGenerator` 是一个分布式ID生成器模块,主要实现了雪花算法(Snowflake)来生成分布式唯一ID。 |
|||
|
|||
## 功能 |
|||
|
|||
* 雪花算法ID生成器 (`SnowflakeIdGenerator`) |
|||
* 支持自定义工作机器ID和数据中心ID |
|||
* 支持自定义序列号位数 |
|||
* 支持时间回退处理 |
|||
* 提供分布式环境下的唯一ID生成 |
|||
|
|||
## 配置项 |
|||
|
|||
### SnowflakeIdOptions |
|||
|
|||
* `WorkerIdBits` (默认: 5) - 工作机器ID位数 |
|||
* `DatacenterIdBits` (默认: 5) - 数据中心ID位数 |
|||
* `Sequence` (默认: 0) - 序列号起始值 |
|||
* `SequenceBits` (默认: 12) - 序列号位数 |
|||
* `UsePreviousInTimeRollback` (默认: true) - 是否在时间回退时使用上一个时间戳 |
|||
* `WorkerId` - 工作机器ID,如未指定则从环境变量WORKERID获取或随机生成 |
|||
* `DatacenterId` - 数据中心ID,如未指定则从环境变量DATACENTERID获取或随机生成 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.IdGenerator |
|||
``` |
|||
|
|||
## 使用 |
|||
|
|||
1. 添加 `[DependsOn(typeof(AbpIdGeneratorModule))]` 到你的模块类上。 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpIdGeneratorModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<SnowflakeIdOptions>(options => |
|||
{ |
|||
options.WorkerId = 1; |
|||
options.DatacenterId = 1; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 注入并使用ID生成器: |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly IDistributedIdGenerator _idGenerator; |
|||
|
|||
public YourService(IDistributedIdGenerator idGenerator) |
|||
{ |
|||
_idGenerator = idGenerator; |
|||
} |
|||
|
|||
public long CreateId() |
|||
{ |
|||
return _idGenerator.Create(); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 链接 |
|||
|
|||
* [English document](./README.EN.md) |
|||
@ -0,0 +1,98 @@ |
|||
# LINGYUN.Abp.Idempotent |
|||
|
|||
Interface idempotency check module for preventing duplicate submissions and ensuring interface call idempotency. |
|||
|
|||
## Features |
|||
|
|||
* Automatic idempotency checking |
|||
* Support for custom idempotent key generation |
|||
* Flexible timeout configuration |
|||
* Distributed lock support |
|||
* Multi-language error messages |
|||
* Support for ignoring specific interfaces or methods |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Idempotent |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpIdempotentModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpIdempotentOptions>(options => |
|||
{ |
|||
// Enable idempotency check globally |
|||
options.IsEnabled = true; |
|||
// Default 5-second timeout for each interface |
|||
options.DefaultTimeout = 5000; |
|||
// Idempotent token name, passed through HttpHeader |
|||
options.IdempotentTokenName = "X-With-Idempotent-Token"; |
|||
// HTTP status code when idempotency check fails |
|||
options.HttpStatusCode = 429; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
* `IsEnabled` - Whether to enable idempotency checking, default: false |
|||
* `DefaultTimeout` - Default idempotency check timeout (milliseconds), default: 5000 |
|||
* `IdempotentTokenName` - HTTP header name for idempotency token, default: X-With-Idempotent-Token |
|||
* `HttpStatusCode` - HTTP status code when idempotency check fails, default: 429 (Too Many Requests) |
|||
|
|||
## Usage Examples |
|||
|
|||
### 1. Basic Usage |
|||
|
|||
```csharp |
|||
[Idempotent] |
|||
public class OrderAppService : ApplicationService |
|||
{ |
|||
public async Task<OrderDto> CreateAsync(CreateOrderDto input) |
|||
{ |
|||
// Method will automatically perform idempotency check |
|||
return await _orderRepository.CreateAsync(input); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 2. Custom Idempotent Key |
|||
|
|||
```csharp |
|||
[Idempotent( |
|||
iodempotentKey: "custom-key", |
|||
timeout: 10000, |
|||
keyMap: new[] { "orderId", "userId" })] |
|||
public async Task<OrderDto> UpdateAsync(UpdateOrderDto input) |
|||
{ |
|||
return await _orderRepository.UpdateAsync(input); |
|||
} |
|||
``` |
|||
|
|||
### 3. Ignore Idempotency Check |
|||
|
|||
```csharp |
|||
[IgnoreIdempotent] |
|||
public async Task<OrderDto> QueryAsync(string orderId) |
|||
{ |
|||
return await _orderRepository.GetAsync(orderId); |
|||
} |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
1. By default, idempotency checking is enabled for all services inheriting from `ICreateAppService`, `IUpdateAppService`, and `IDeleteAppService` |
|||
2. You can use the `[IgnoreIdempotent]` attribute to ignore idempotency checking for specific methods |
|||
3. Idempotency checking is implemented based on distributed locks to ensure correctness in distributed environments |
|||
4. It is recommended to enable idempotency checking on all interfaces that modify data |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,137 @@ |
|||
# LINGYUN.Abp.Location.Baidu |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.Location.Baidu` is a location service implementation module based on Baidu Maps API, providing functionalities such as geocoding, reverse geocoding, IP location, and more. |
|||
|
|||
## Features |
|||
|
|||
* Geocoding: Convert structured addresses into latitude and longitude coordinates |
|||
* Reverse Geocoding: Convert coordinates into structured addresses |
|||
* IP Location: Get location information based on IP addresses |
|||
* POI (Points of Interest) Information: Get information about nearby businesses, restaurants, and other points of interest |
|||
* Road Information: Get information about nearby roads |
|||
* Administrative Region Information: Get detailed administrative region hierarchy information |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Location.Baidu |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
1. Add module dependency: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpBaiduLocationModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<BaiduLocationOptions>(options => |
|||
{ |
|||
// Set Baidu Maps API key |
|||
options.AccessKey = "your-baidu-map-ak"; |
|||
// Optional: Set security key (for sn verification) |
|||
options.SecurityKey = "your-baidu-map-sk"; |
|||
// Optional: Set coordinate system type (default is bd09ll) |
|||
options.CoordType = "bd09ll"; |
|||
// Optional: Set output format (default is json) |
|||
options.Output = "json"; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Inject and use the location resolution service: |
|||
|
|||
```csharp |
|||
public class YourLocationService |
|||
{ |
|||
private readonly ILocationResolveProvider _locationProvider; |
|||
|
|||
public YourLocationService(ILocationResolveProvider locationProvider) |
|||
{ |
|||
_locationProvider = locationProvider; |
|||
} |
|||
|
|||
// Geocoding: Convert address to coordinates |
|||
public async Task<GecodeLocation> GeocodeAsync(string address) |
|||
{ |
|||
// city parameter is optional, used to specify the city of the address |
|||
return await _locationProvider.GeocodeAsync(address, "Beijing"); |
|||
} |
|||
|
|||
// Reverse Geocoding: Convert coordinates to address |
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
|||
{ |
|||
// radius parameter is optional, specifies search radius (in meters) |
|||
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
|||
} |
|||
|
|||
// IP Geolocation |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
return await _locationProvider.IPGeocodeAsync(ipAddress); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Response Data Description |
|||
|
|||
### Geocoding Response Data |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // Latitude value |
|||
"lng": 116.403963 // Longitude value |
|||
}, |
|||
"precise": 1, // Additional location info, precise match or not (1 for precise, 0 for not precise) |
|||
"confidence": 80, // Confidence level |
|||
"comprehension": 100, // Address understanding level |
|||
"level": "门址" // Address type |
|||
} |
|||
``` |
|||
|
|||
### Reverse Geocoding Response Data |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // Latitude value |
|||
"lng": 116.403963 // Longitude value |
|||
}, |
|||
"formatted_address": "Dongchangan Street, Dongcheng District, Beijing", // Structured address |
|||
"business": "Tiananmen", // Business area information |
|||
"addressComponent": { |
|||
"country": "China", // Country |
|||
"province": "Beijing", // Province |
|||
"city": "Beijing", // City |
|||
"district": "Dongcheng District", // District |
|||
"street": "Dongchangan Street", // Street |
|||
"street_number": "1" // Street number |
|||
}, |
|||
"pois": [ // Nearby POIs |
|||
{ |
|||
"name": "Tiananmen", // POI name |
|||
"type": "Tourist Attraction", // POI type |
|||
"distance": "100" // Distance (meters) |
|||
} |
|||
], |
|||
"roads": [ // Nearby roads |
|||
{ |
|||
"name": "Dongchangan Street", // Road name |
|||
"distance": "50" // Distance (meters) |
|||
} |
|||
] |
|||
} |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [中文文档](./README.md) |
|||
* [Baidu Maps Open Platform](https://lbsyun.baidu.com/) |
|||
@ -0,0 +1,137 @@ |
|||
# LINGYUN.Abp.Location.Baidu |
|||
|
|||
## 介绍 |
|||
|
|||
`LINGYUN.Abp.Location.Baidu` 是基于百度地图API的位置服务实现模块,提供了地理编码、反向地理编码、IP定位等功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 地理编码:将详细的结构化地址转换为对应的经纬度坐标 |
|||
* 反向地理编码:将经纬度坐标转换为对应的结构化地址 |
|||
* IP定位:根据IP地址获取位置信息 |
|||
* POI(兴趣点)信息:获取周边的商铺、餐厅等兴趣点信息 |
|||
* 道路信息:获取附近的道路信息 |
|||
* 行政区划信息:获取详细的行政区划层级信息 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Location.Baidu |
|||
``` |
|||
|
|||
## 配置 |
|||
|
|||
1. 添加模块依赖: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpBaiduLocationModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<BaiduLocationOptions>(options => |
|||
{ |
|||
// 设置百度地图API密钥 |
|||
options.AccessKey = "your-baidu-map-ak"; |
|||
// 可选:设置安全密钥(sn校验) |
|||
options.SecurityKey = "your-baidu-map-sk"; |
|||
// 可选:设置坐标系类型(默认为bd09ll) |
|||
options.CoordType = "bd09ll"; |
|||
// 可选:设置输出格式(默认为json) |
|||
options.Output = "json"; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 使用方法 |
|||
|
|||
1. 注入并使用位置解析服务: |
|||
|
|||
```csharp |
|||
public class YourLocationService |
|||
{ |
|||
private readonly ILocationResolveProvider _locationProvider; |
|||
|
|||
public YourLocationService(ILocationResolveProvider locationProvider) |
|||
{ |
|||
_locationProvider = locationProvider; |
|||
} |
|||
|
|||
// 地理编码:地址转坐标 |
|||
public async Task<GecodeLocation> GeocodeAsync(string address) |
|||
{ |
|||
// city参数可选,用于指定地址所在城市 |
|||
return await _locationProvider.GeocodeAsync(address, "北京市"); |
|||
} |
|||
|
|||
// 反向地理编码:坐标转地址 |
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
|||
{ |
|||
// radius参数可选,指定搜索半径(米) |
|||
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
|||
} |
|||
|
|||
// IP地理位置解析 |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
return await _locationProvider.IPGeocodeAsync(ipAddress); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 返回数据说明 |
|||
|
|||
### 地理编码返回数据 |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // 纬度值 |
|||
"lng": 116.403963 // 经度值 |
|||
}, |
|||
"precise": 1, // 位置的附加信息,是否精确查找(1为精确,0为不精确) |
|||
"confidence": 80, // 可信度 |
|||
"comprehension": 100, // 地址理解程度 |
|||
"level": "门址" // 地址类型 |
|||
} |
|||
``` |
|||
|
|||
### 反向地理编码返回数据 |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // 纬度值 |
|||
"lng": 116.403963 // 经度值 |
|||
}, |
|||
"formatted_address": "北京市东城区东长安街", // 结构化地址信息 |
|||
"business": "天安门", // 商圈信息 |
|||
"addressComponent": { |
|||
"country": "中国", // 国家 |
|||
"province": "北京市", // 省份 |
|||
"city": "北京市", // 城市 |
|||
"district": "东城区", // 区县 |
|||
"street": "东长安街", // 街道 |
|||
"street_number": "1号" // 门牌号 |
|||
}, |
|||
"pois": [ // 周边POI信息 |
|||
{ |
|||
"name": "天安门", // POI名称 |
|||
"type": "旅游景点", // POI类型 |
|||
"distance": "100" // 距离(米) |
|||
} |
|||
], |
|||
"roads": [ // 周边道路信息 |
|||
{ |
|||
"name": "东长安街", // 道路名称 |
|||
"distance": "50" // 距离(米) |
|||
} |
|||
] |
|||
} |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [English Documentation](./README.EN.md) |
|||
* [百度地图开放平台](https://lbsyun.baidu.com/) |
|||
@ -0,0 +1,144 @@ |
|||
# LINGYUN.Abp.Location.Tencent |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.Location.Tencent` is a location service implementation module based on Tencent Maps API, providing functionalities such as geocoding, reverse geocoding, IP location, and more. |
|||
|
|||
## Features |
|||
|
|||
* Geocoding: Convert structured addresses into latitude and longitude coordinates |
|||
* Reverse Geocoding: Convert coordinates into structured addresses |
|||
* IP Location: Get location information based on IP addresses |
|||
* POI (Points of Interest) Information: Get information about nearby businesses, restaurants, and other points of interest |
|||
* Administrative Region Information: Get detailed administrative region hierarchy information |
|||
* Address Parsing: Intelligent address parsing supporting multiple formats |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Location.Tencent |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
1. Add module dependency: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentLocationModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<TencentLocationOptions>(options => |
|||
{ |
|||
// Set Tencent Maps API key |
|||
options.Key = "your-tencent-map-key"; |
|||
// Optional: Set security key (for SK verification) |
|||
options.SecretKey = "your-tencent-map-sk"; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Inject and use the location resolution service: |
|||
|
|||
```csharp |
|||
public class YourLocationService |
|||
{ |
|||
private readonly ILocationResolveProvider _locationProvider; |
|||
|
|||
public YourLocationService(ILocationResolveProvider locationProvider) |
|||
{ |
|||
_locationProvider = locationProvider; |
|||
} |
|||
|
|||
// Geocoding: Convert address to coordinates |
|||
public async Task<GecodeLocation> GeocodeAsync(string address) |
|||
{ |
|||
// city parameter is optional, used to specify the city of the address |
|||
return await _locationProvider.GeocodeAsync(address, "Beijing"); |
|||
} |
|||
|
|||
// Reverse Geocoding: Convert coordinates to address |
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
|||
{ |
|||
// radius parameter is optional, specifies search radius (in meters) |
|||
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
|||
} |
|||
|
|||
// IP Geolocation |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
return await _locationProvider.IPGeocodeAsync(ipAddress); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Response Data Description |
|||
|
|||
### Geocoding Response Data |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // Latitude value |
|||
"lng": 116.403963 // Longitude value |
|||
}, |
|||
"title": "Tiananmen", // Place name |
|||
"address": "Dongchangan Street, Dongcheng District, Beijing", // Address |
|||
"category": "Tourist Attraction", // Category |
|||
"adcode": "110101", // Administrative region code |
|||
"similarity": 0.8, // Similarity (0-1) |
|||
"reliability": 7, // Reliability (1-10) |
|||
"level": 11 // Address type |
|||
} |
|||
``` |
|||
|
|||
### Reverse Geocoding Response Data |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // Latitude value |
|||
"lng": 116.403963 // Longitude value |
|||
}, |
|||
"address": "Dongchangan Street, Dongcheng District, Beijing", // Complete address |
|||
"formatted_addresses": { |
|||
"recommend": "Tiananmen, Dongcheng District", // Recommended address |
|||
"rough": "Dongcheng District, Beijing" // Rough address |
|||
}, |
|||
"address_component": { |
|||
"nation": "China", // Country |
|||
"province": "Beijing", // Province |
|||
"city": "Beijing", // City |
|||
"district": "Dongcheng District", // District |
|||
"street": "Dongchangan Street", // Street |
|||
"street_number": "1" // Street number |
|||
}, |
|||
"pois": [ // Nearby POIs |
|||
{ |
|||
"title": "Tiananmen", // POI name |
|||
"address": "Dongchangan Street, Dongcheng District, Beijing", // POI address |
|||
"category": "Tourist Attraction", // POI type |
|||
"distance": 100, // Distance (meters) |
|||
"_distance": 100.0, // Distance (meters, float) |
|||
"tel": "", // Phone number |
|||
"ad_info": { // Administrative region info |
|||
"adcode": "110101", // Administrative region code |
|||
"name": "Dongcheng District", // Administrative region name |
|||
"location": { // Administrative region center point |
|||
"lat": 39.915119, |
|||
"lng": 116.403963 |
|||
} |
|||
} |
|||
} |
|||
] |
|||
} |
|||
``` |
|||
|
|||
## More Information |
|||
|
|||
* [中文文档](./README.md) |
|||
* [Tencent Location Service](https://lbs.qq.com/) |
|||
@ -0,0 +1,144 @@ |
|||
# LINGYUN.Abp.Location.Tencent |
|||
|
|||
## 介绍 |
|||
|
|||
`LINGYUN.Abp.Location.Tencent` 是基于腾讯地图API的位置服务实现模块,提供了地理编码、反向地理编码、IP定位等功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 地理编码:将详细的结构化地址转换为对应的经纬度坐标 |
|||
* 反向地理编码:将经纬度坐标转换为对应的结构化地址 |
|||
* IP定位:根据IP地址获取位置信息 |
|||
* POI(兴趣点)信息:获取周边的商铺、餐厅等兴趣点信息 |
|||
* 行政区划信息:获取详细的行政区划层级信息 |
|||
* 地址解析:智能解析地址信息,支持多种格式 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Location.Tencent |
|||
``` |
|||
|
|||
## 配置 |
|||
|
|||
1. 添加模块依赖: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpTencentLocationModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<TencentLocationOptions>(options => |
|||
{ |
|||
// 设置腾讯地图API密钥 |
|||
options.Key = "your-tencent-map-key"; |
|||
// 可选:设置安全密钥(SK校验) |
|||
options.SecretKey = "your-tencent-map-sk"; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 使用方法 |
|||
|
|||
1. 注入并使用位置解析服务: |
|||
|
|||
```csharp |
|||
public class YourLocationService |
|||
{ |
|||
private readonly ILocationResolveProvider _locationProvider; |
|||
|
|||
public YourLocationService(ILocationResolveProvider locationProvider) |
|||
{ |
|||
_locationProvider = locationProvider; |
|||
} |
|||
|
|||
// 地理编码:地址转坐标 |
|||
public async Task<GecodeLocation> GeocodeAsync(string address) |
|||
{ |
|||
// city参数可选,用于指定地址所在城市 |
|||
return await _locationProvider.GeocodeAsync(address, "北京市"); |
|||
} |
|||
|
|||
// 反向地理编码:坐标转地址 |
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
|||
{ |
|||
// radius参数可选,指定搜索半径(米) |
|||
return await _locationProvider.ReGeocodeAsync(lat, lng, 1000); |
|||
} |
|||
|
|||
// IP地理位置解析 |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
return await _locationProvider.IPGeocodeAsync(ipAddress); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 返回数据说明 |
|||
|
|||
### 地理编码返回数据 |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // 纬度值 |
|||
"lng": 116.403963 // 经度值 |
|||
}, |
|||
"title": "天安门", // 地点名称 |
|||
"address": "北京市东城区东长安街", // 地址 |
|||
"category": "旅游景点", // 类别 |
|||
"adcode": "110101", // 行政区划代码 |
|||
"similarity": 0.8, // 相似度(0-1) |
|||
"reliability": 7, // 可信度(1-10) |
|||
"level": 11 // 地址类型 |
|||
} |
|||
``` |
|||
|
|||
### 反向地理编码返回数据 |
|||
|
|||
```json |
|||
{ |
|||
"location": { |
|||
"lat": 39.915119, // 纬度值 |
|||
"lng": 116.403963 // 经度值 |
|||
}, |
|||
"address": "北京市东城区东长安街", // 完整地址 |
|||
"formatted_addresses": { |
|||
"recommend": "东城区天安门", // 推荐地址 |
|||
"rough": "北京市东城区" // 粗略地址 |
|||
}, |
|||
"address_component": { |
|||
"nation": "中国", // 国家 |
|||
"province": "北京市", // 省份 |
|||
"city": "北京市", // 城市 |
|||
"district": "东城区", // 区县 |
|||
"street": "东长安街", // 街道 |
|||
"street_number": "1号" // 门牌号 |
|||
}, |
|||
"pois": [ // 周边POI信息 |
|||
{ |
|||
"title": "天安门", // POI名称 |
|||
"address": "北京市东城区东长安街", // POI地址 |
|||
"category": "旅游景点", // POI类型 |
|||
"distance": 100, // 距离(米) |
|||
"_distance": 100.0, // 距离(米,浮点数) |
|||
"tel": "", // 电话 |
|||
"ad_info": { // 行政区划信息 |
|||
"adcode": "110101", // 行政区划代码 |
|||
"name": "东城区", // 行政区划名称 |
|||
"location": { // 行政区划中心点 |
|||
"lat": 39.915119, |
|||
"lng": 116.403963 |
|||
} |
|||
} |
|||
} |
|||
] |
|||
} |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [English Documentation](./README.EN.md) |
|||
* [腾讯位置服务](https://lbs.qq.com/) |
|||
@ -0,0 +1,151 @@ |
|||
# LINGYUN.Abp.Location |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.Location` is a location service foundation module that provides geographic location-related functionality, including geocoding (forward/reverse), distance calculation, and more. |
|||
|
|||
## Features |
|||
|
|||
* Geocoding and Reverse Geocoding |
|||
* IP Geolocation Resolution |
|||
* Location distance calculation (based on Google algorithm, error <0.2m) |
|||
* Location offset calculation |
|||
* Support for POI (Points of Interest) and road information |
|||
* Extensible location resolution providers |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Location |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Add module dependency: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpLocationModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Inject and use the location resolution service: |
|||
|
|||
```csharp |
|||
public class YourLocationService |
|||
{ |
|||
private readonly ILocationResolveProvider _locationProvider; |
|||
|
|||
public YourLocationService(ILocationResolveProvider locationProvider) |
|||
{ |
|||
_locationProvider = locationProvider; |
|||
} |
|||
|
|||
// Geocoding: Convert address to coordinates |
|||
public async Task<GecodeLocation> GeocodeAsync(string address) |
|||
{ |
|||
return await _locationProvider.GeocodeAsync(address); |
|||
} |
|||
|
|||
// Reverse Geocoding: Convert coordinates to address |
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
|||
{ |
|||
return await _locationProvider.ReGeocodeAsync(lat, lng); |
|||
} |
|||
|
|||
// IP Geolocation Resolution |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
return await _locationProvider.IPGeocodeAsync(ipAddress); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Advanced Usage |
|||
|
|||
### 1. Distance Calculation |
|||
|
|||
```csharp |
|||
// Create location objects |
|||
var location1 = new Location { Latitude = 39.9042, Longitude = 116.4074 }; // Beijing |
|||
var location2 = new Location { Latitude = 31.2304, Longitude = 121.4737 }; // Shanghai |
|||
|
|||
// Calculate distance between two points (in meters) |
|||
double distance = location1.CalcDistance(location2); |
|||
|
|||
// Calculate location offset |
|||
var offset = location1.CalcOffset(1000, 45); // Offset 1000 meters to the northeast |
|||
``` |
|||
|
|||
### 2. Calculate Location Offset Range |
|||
|
|||
```csharp |
|||
var location = new Location { Latitude = 39.9042, Longitude = 116.4074 }; |
|||
// Calculate offset range for specified distance (meters) |
|||
var position = Location.CalcOffsetDistance(location, 1000); // 1km range |
|||
``` |
|||
|
|||
### 3. Custom Location Resolution Provider |
|||
|
|||
```csharp |
|||
public class CustomLocationProvider : ILocationResolveProvider |
|||
{ |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
// Implement IP geolocation resolution |
|||
} |
|||
|
|||
public async Task<GecodeLocation> GeocodeAsync(string address, string city = null) |
|||
{ |
|||
// Implement geocoding |
|||
} |
|||
|
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng, int radius = 50) |
|||
{ |
|||
// Implement reverse geocoding |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Custom Location Resolution Provider Implementation |
|||
|
|||
To implement a custom location resolution provider: |
|||
|
|||
1. Implement the `ILocationResolveProvider` interface: |
|||
|
|||
```csharp |
|||
public class CustomLocationProvider : ILocationResolveProvider |
|||
{ |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
// Implement IP geolocation resolution |
|||
} |
|||
|
|||
public async Task<GecodeLocation> GeocodeAsync(string address, string city = null) |
|||
{ |
|||
// Implement geocoding |
|||
} |
|||
|
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng, int radius = 50) |
|||
{ |
|||
// Implement reverse geocoding |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Register your implementation in your module: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddTransient<ILocationResolveProvider, CustomLocationProvider>(); |
|||
} |
|||
``` |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
* [Baidu Maps Location Service](./LINGYUN.Abp.Location.Baidu/README.EN.md) |
|||
* [Tencent Maps Location Service](./LINGYUN.Abp.Location.Tencent/README.EN.md) |
|||
@ -0,0 +1,121 @@ |
|||
# LINGYUN.Abp.Location |
|||
|
|||
## 介绍 |
|||
|
|||
`LINGYUN.Abp.Location` 是一个位置服务基础模块,提供了地理位置相关的功能,包括地理编码(正向/反向)、距离计算等功能。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 地理编码(Geocoding)和反向地理编码(Reverse Geocoding) |
|||
* IP地理位置解析 |
|||
* 位置距离计算(基于Google算法,误差<0.2米) |
|||
* 位置偏移量计算 |
|||
* 支持POI(兴趣点)和道路信息 |
|||
* 可扩展的位置解析提供程序 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Location |
|||
``` |
|||
|
|||
## 使用方法 |
|||
|
|||
1. 添加模块依赖: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpLocationModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 注入并使用位置解析服务: |
|||
|
|||
```csharp |
|||
public class YourLocationService |
|||
{ |
|||
private readonly ILocationResolveProvider _locationProvider; |
|||
|
|||
public YourLocationService(ILocationResolveProvider locationProvider) |
|||
{ |
|||
_locationProvider = locationProvider; |
|||
} |
|||
|
|||
// 地理编码:地址转坐标 |
|||
public async Task<GecodeLocation> GeocodeAsync(string address) |
|||
{ |
|||
return await _locationProvider.GeocodeAsync(address); |
|||
} |
|||
|
|||
// 反向地理编码:坐标转地址 |
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng) |
|||
{ |
|||
return await _locationProvider.ReGeocodeAsync(lat, lng); |
|||
} |
|||
|
|||
// IP地理位置解析 |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
return await _locationProvider.IPGeocodeAsync(ipAddress); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 位置计算 |
|||
|
|||
模块提供了强大的位置计算功能: |
|||
|
|||
```csharp |
|||
// 创建位置对象 |
|||
var location1 = new Location { Latitude = 39.9042, Longitude = 116.4074 }; // 北京 |
|||
var location2 = new Location { Latitude = 31.2304, Longitude = 121.4737 }; // 上海 |
|||
|
|||
// 计算两点之间的距离(米) |
|||
double distance = location1.CalcDistance(location2); |
|||
|
|||
// 计算位置的偏移 |
|||
var offset = location1.CalcOffset(1000, 45); // 向东北方向偏移1000米 |
|||
``` |
|||
|
|||
## 自定义位置解析提供程序 |
|||
|
|||
要实现自定义的位置解析提供程序,需要: |
|||
|
|||
1. 实现 `ILocationResolveProvider` 接口: |
|||
|
|||
```csharp |
|||
public class CustomLocationProvider : ILocationResolveProvider |
|||
{ |
|||
public async Task<IPGecodeLocation> IPGeocodeAsync(string ipAddress) |
|||
{ |
|||
// 实现IP地理位置解析 |
|||
} |
|||
|
|||
public async Task<GecodeLocation> GeocodeAsync(string address, string city = null) |
|||
{ |
|||
// 实现地理编码 |
|||
} |
|||
|
|||
public async Task<ReGeocodeLocation> ReGeocodeAsync(double lat, double lng, int radius = 50) |
|||
{ |
|||
// 实现反向地理编码 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 在模块中注册你的实现: |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddTransient<ILocationResolveProvider, CustomLocationProvider>(); |
|||
} |
|||
``` |
|||
|
|||
## 更多信息 |
|||
|
|||
* [English Documentation](./README.EN.md) |
|||
* [百度地图定位服务](./LINGYUN.Abp.Location.Baidu/README.md) |
|||
* [腾讯地图定位服务](./LINGYUN.Abp.Location.Tencent/README.md) |
|||
@ -0,0 +1,95 @@ |
|||
# LINGYUN.Abp.RealTime |
|||
|
|||
## Introduction |
|||
|
|||
`LINGYUN.Abp.RealTime` is a real-time communication foundation module that provides infrastructure for real-time message delivery. This module is mainly used for handling real-time notifications, messages, and event delivery. |
|||
|
|||
## Features |
|||
|
|||
* Real-time event delivery infrastructure |
|||
* Support for localized string handling |
|||
* Distributed event integration |
|||
* Extensible event handling mechanism |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.RealTime |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Add `[DependsOn(typeof(AbpRealTimeModule))]` to your module class. |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpRealTimeModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. Create real-time event data transfer object: |
|||
|
|||
```csharp |
|||
public class YourRealTimeEto : RealTimeEto<YourData> |
|||
{ |
|||
public YourRealTimeEto(YourData data) |
|||
: base(data) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. Use localized strings: |
|||
|
|||
```csharp |
|||
public class LocalizedMessage |
|||
{ |
|||
private readonly LocalizableStringInfo _localizableString; |
|||
|
|||
public LocalizedMessage() |
|||
{ |
|||
_localizableString = new LocalizableStringInfo( |
|||
"YourResource", |
|||
"MessageKey", |
|||
new Dictionary<object, object> |
|||
{ |
|||
{ "param1", "value1" } |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Advanced Usage |
|||
|
|||
### 1. Custom Real-Time Events |
|||
|
|||
```csharp |
|||
[EventName("your-custom-event")] |
|||
public class CustomRealTimeEto : RealTimeEto<CustomData> |
|||
{ |
|||
public CustomRealTimeEto(CustomData data) |
|||
: base(data) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 2. Real-Time Event Handling |
|||
|
|||
```csharp |
|||
public class YourRealTimeEventHandler : |
|||
IDistributedEventHandler<YourRealTimeEto>, |
|||
ITransientDependency |
|||
{ |
|||
public async Task HandleEventAsync(YourRealTimeEto eventData) |
|||
{ |
|||
// Handle real-time event |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,95 @@ |
|||
# LINGYUN.Abp.RealTime |
|||
|
|||
## 介绍 |
|||
|
|||
`LINGYUN.Abp.RealTime` 是一个实时通信基础模块,提供了实时消息传递的基础设施。该模块主要用于处理实时通知、消息和事件的传递。 |
|||
|
|||
## 功能 |
|||
|
|||
* 实时事件传递基础设施 |
|||
* 支持本地化字符串处理 |
|||
* 分布式事件集成 |
|||
* 可扩展的事件处理机制 |
|||
|
|||
## 安装 |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.RealTime |
|||
``` |
|||
|
|||
## 使用 |
|||
|
|||
1. 添加 `[DependsOn(typeof(AbpRealTimeModule))]` 到你的模块类上。 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpRealTimeModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
// ... |
|||
} |
|||
``` |
|||
|
|||
2. 创建实时事件数据传输对象: |
|||
|
|||
```csharp |
|||
public class YourRealTimeEto : RealTimeEto<YourData> |
|||
{ |
|||
public YourRealTimeEto(YourData data) |
|||
: base(data) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. 使用本地化字符串: |
|||
|
|||
```csharp |
|||
public class LocalizedMessage |
|||
{ |
|||
private readonly LocalizableStringInfo _localizableString; |
|||
|
|||
public LocalizedMessage() |
|||
{ |
|||
_localizableString = new LocalizableStringInfo( |
|||
"YourResource", |
|||
"MessageKey", |
|||
new Dictionary<object, object> |
|||
{ |
|||
{ "param1", "value1" } |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 高级用法 |
|||
|
|||
### 1. 自定义实时事件 |
|||
|
|||
```csharp |
|||
[EventName("your-custom-event")] |
|||
public class CustomRealTimeEto : RealTimeEto<CustomData> |
|||
{ |
|||
public CustomRealTimeEto(CustomData data) |
|||
: base(data) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 2. 实时事件处理 |
|||
|
|||
```csharp |
|||
public class YourRealTimeEventHandler : |
|||
IDistributedEventHandler<YourRealTimeEto>, |
|||
ITransientDependency |
|||
{ |
|||
public async Task HandleEventAsync(YourRealTimeEto eventData) |
|||
{ |
|||
// 处理实时事件 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 链接 |
|||
|
|||
* [English document](./README.EN.md) |
|||
@ -0,0 +1,105 @@ |
|||
# LINGYUN.Abp.Wrapper |
|||
|
|||
A wrapper module for unifying API response results and exception handling. |
|||
|
|||
## Features |
|||
|
|||
* Unified response result wrapping |
|||
* Flexible exception handling mechanism |
|||
* Support for multiple ignore strategies |
|||
* Configurable empty result handling |
|||
* Custom exception handlers |
|||
|
|||
## Installation |
|||
|
|||
```bash |
|||
dotnet add package LINGYUN.Abp.Wrapper |
|||
``` |
|||
|
|||
## Configuration |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpWrapperModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpWrapperOptions>(options => |
|||
{ |
|||
// Enable wrapper |
|||
options.IsEnabled = true; |
|||
|
|||
// Custom error code for unhandled exceptions |
|||
options.CodeWithUnhandled = "500"; |
|||
|
|||
// Ignore specific URL prefixes |
|||
options.IgnorePrefixUrls.Add("/api/health"); |
|||
|
|||
// Add custom exception handler |
|||
options.AddHandler<CustomException>(new CustomExceptionHandler()); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
* `AbpWrapperOptions.IsEnabled` - Whether to wrap return results, default: false |
|||
* `AbpWrapperOptions.CodeWithUnhandled` - Error code for unhandled exceptions, default: 500 |
|||
* `AbpWrapperOptions.CodeWithSuccess` - Success code for successful operations, default: 0 |
|||
* `AbpWrapperOptions.ErrorWithEmptyResult` - Whether to return error message when resource is empty, default: false |
|||
* `AbpWrapperOptions.HttpStatusCode` - Http response code after wrapping, default: 200 |
|||
* `AbpWrapperOptions.CodeWithEmptyResult` - Error code when returning empty object, default: 404 |
|||
* `AbpWrapperOptions.MessageWithEmptyResult` - Error message when returning empty object, default: Not Found |
|||
|
|||
* `AbpWrapperOptions.IgnorePrefixUrls` - Specify which URL prefixes to ignore |
|||
* `AbpWrapperOptions.IgnoreNamespaces` - Specify which namespaces to ignore |
|||
* `AbpWrapperOptions.IgnoreControllers` - Specify which controllers to ignore |
|||
* `AbpWrapperOptions.IgnoreReturnTypes` - Specify which return types to ignore |
|||
* `AbpWrapperOptions.IgnoreExceptions` - Specify which exception types to ignore |
|||
* `AbpWrapperOptions.IgnoredInterfaces` - Specify which interfaces to ignore (by default, implements **IWrapDisabled** interface will not be processed) |
|||
|
|||
## Usage Examples |
|||
|
|||
### 1. Basic Usage |
|||
|
|||
```csharp |
|||
public class TestController : AbpController |
|||
{ |
|||
public async Task<WrapResult<string>> GetAsync() |
|||
{ |
|||
return new WrapResult<string>("0", "Hello World"); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 2. Ignore Wrapping |
|||
|
|||
```csharp |
|||
[IgnoreWrapResult] |
|||
public class HealthController : AbpController |
|||
{ |
|||
public async Task<string> GetAsync() |
|||
{ |
|||
return "OK"; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 3. Custom Exception Handler |
|||
|
|||
```csharp |
|||
public class CustomExceptionHandler : IExceptionWrapHandler |
|||
{ |
|||
public void Wrap(ExceptionWrapContext context) |
|||
{ |
|||
context.WithCode("CUSTOM_ERROR") |
|||
.WithMessage("Custom exception occurred") |
|||
.WithDetails(context.Exception.Message); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,181 @@ |
|||
# LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper |
|||
|
|||
Dapr Actors ASP.NET Core wrapper module for handling Actor method call response wrapping and unwrapping. |
|||
|
|||
## Features |
|||
|
|||
* Automatic Actor response result wrapping/unwrapping |
|||
* Integration with ABP's wrapper system |
|||
* Error handling for Actor method calls |
|||
* Support for success/error code configuration |
|||
* Integration with Dapr.Actors.AspNetCore |
|||
* Support for custom response wrapper format |
|||
* Flexible wrapping control options |
|||
|
|||
## Basic Usage |
|||
|
|||
Module reference as needed: |
|||
|
|||
```csharp |
|||
[DependsOn( |
|||
typeof(AbpDaprActorsAspNetCoreModule), |
|||
typeof(AbpWrapperModule) |
|||
)] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
The module uses `AbpWrapperOptions` from the `LINGYUN.Abp.Wrapper` package for configuration: |
|||
|
|||
```json |
|||
{ |
|||
"Wrapper": { |
|||
"IsEnabled": true, // Enable/disable response wrapping |
|||
"CodeWithSuccess": "0", // Success code in wrapped response |
|||
"HttpStatusCode": 200, // Default HTTP status code for wrapped responses |
|||
"WrapOnError": true, // Whether to wrap error responses |
|||
"WrapOnSuccess": true // Whether to wrap success responses |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Implementation Example |
|||
|
|||
1. Actor Interface Definition |
|||
|
|||
```csharp |
|||
public interface ICounterActor : IActor |
|||
{ |
|||
Task<int> GetCountAsync(); |
|||
Task IncrementCountAsync(); |
|||
} |
|||
``` |
|||
|
|||
2. Actor Implementation |
|||
|
|||
```csharp |
|||
public class CounterActor : Actor, ICounterActor |
|||
{ |
|||
private const string CountStateName = "count"; |
|||
|
|||
public CounterActor(ActorHost host) : base(host) |
|||
{ |
|||
} |
|||
|
|||
public async Task<int> GetCountAsync() |
|||
{ |
|||
var count = await StateManager.TryGetStateAsync<int>(CountStateName); |
|||
return count.HasValue ? count.Value : 0; |
|||
} |
|||
|
|||
public async Task IncrementCountAsync() |
|||
{ |
|||
var currentCount = await GetCountAsync(); |
|||
await StateManager.SetStateAsync(CountStateName, currentCount + 1); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Response Format |
|||
|
|||
When wrapping is enabled, Actor method responses will be in the following format: |
|||
|
|||
```json |
|||
{ |
|||
"code": "0", // Response code, "0" indicates success by default |
|||
"message": "Success", // Response message |
|||
"details": null, // Additional details (optional) |
|||
"result": { // Actual response data |
|||
// ... Actor method return value |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Error Handling |
|||
|
|||
The module automatically handles Actor method call errors: |
|||
* For wrapped responses: |
|||
* Unwraps the response and checks the code |
|||
* If code doesn't match `CodeWithSuccess`, throws `AbpRemoteCallException` |
|||
* Includes error message, details, and code in the exception |
|||
* Supports custom error code mapping |
|||
* For Actor runtime errors: |
|||
* Automatically wraps as standard error response |
|||
* Preserves original exception information |
|||
* Includes Actor-related context information |
|||
|
|||
### Error Response Example |
|||
|
|||
```json |
|||
{ |
|||
"code": "ERROR_001", |
|||
"message": "Actor method call failed", |
|||
"details": "Failed to access state for actor 'counter'", |
|||
"result": null |
|||
} |
|||
``` |
|||
|
|||
## Advanced Usage |
|||
|
|||
### 1. Controlling Response Wrapping |
|||
|
|||
Response wrapping can be controlled per Actor call using HTTP headers: |
|||
|
|||
```csharp |
|||
// Add to request headers |
|||
var headers = new Dictionary<string, string> |
|||
{ |
|||
{ "X-Abp-Wrap-Result", "true" }, // Force enable wrapping |
|||
// or |
|||
{ "X-Abp-Dont-Wrap-Result", "true" } // Force disable wrapping |
|||
}; |
|||
|
|||
// Use in Actor method |
|||
public async Task<int> GetCountAsync() |
|||
{ |
|||
var context = ActorContext.GetContext(); |
|||
context.Headers.Add("X-Abp-Wrap-Result", "true"); |
|||
|
|||
var count = await StateManager.TryGetStateAsync<int>(CountStateName); |
|||
return count.HasValue ? count.Value : 0; |
|||
} |
|||
``` |
|||
|
|||
### 2. Custom Error Handling |
|||
|
|||
```csharp |
|||
public class CustomActorErrorHandler : IAbpWrapperErrorHandler |
|||
{ |
|||
public Task HandleAsync(AbpWrapperErrorContext context) |
|||
{ |
|||
if (context.Exception is ActorMethodInvocationException actorException) |
|||
{ |
|||
// Custom Actor error handling logic |
|||
context.Response = new WrapperResponse |
|||
{ |
|||
Code = "ACTOR_ERROR", |
|||
Message = actorException.Message, |
|||
Details = actorException.ActorId |
|||
}; |
|||
} |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
* Response wrapping can be controlled through: |
|||
* Global settings in configuration |
|||
* HTTP headers for individual requests |
|||
* Dynamic control in Actor methods |
|||
* Error responses maintain original error structure for Actor methods |
|||
* The module integrates with ABP's remote service error handling system |
|||
* Recommended to use response wrapping consistently in microservices architecture |
|||
* Wrapper format can be customized by implementing `IAbpWrapperResponseBuilder` |
|||
* Actor state operation errors are properly wrapped and handled |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,181 @@ |
|||
# LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper |
|||
|
|||
Dapr Actors ASP.NET Core响应包装模块,用于处理Actor方法调用的响应包装和解包。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* Actor响应结果自动包装/解包 |
|||
* 与ABP包装系统集成 |
|||
* 支持Actor方法调用的错误处理 |
|||
* 支持成功/错误代码配置 |
|||
* 与Dapr.Actors.AspNetCore集成 |
|||
* 支持自定义响应包装格式 |
|||
* 灵活的包装控制选项 |
|||
|
|||
## 配置使用 |
|||
|
|||
模块按需引用: |
|||
|
|||
```csharp |
|||
[DependsOn( |
|||
typeof(AbpDaprActorsAspNetCoreModule), |
|||
typeof(AbpWrapperModule) |
|||
)] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
## 配置选项 |
|||
|
|||
模块使用来自`LINGYUN.Abp.Wrapper`包的`AbpWrapperOptions`进行配置: |
|||
|
|||
```json |
|||
{ |
|||
"Wrapper": { |
|||
"IsEnabled": true, // 启用/禁用响应包装 |
|||
"CodeWithSuccess": "0", // 包装响应中的成功代码 |
|||
"HttpStatusCode": 200, // 包装响应的默认HTTP状态码 |
|||
"WrapOnError": true, // 是否包装错误响应 |
|||
"WrapOnSuccess": true // 是否包装成功响应 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 实现示例 |
|||
|
|||
1. Actor接口定义 |
|||
|
|||
```csharp |
|||
public interface ICounterActor : IActor |
|||
{ |
|||
Task<int> GetCountAsync(); |
|||
Task IncrementCountAsync(); |
|||
} |
|||
``` |
|||
|
|||
2. Actor实现 |
|||
|
|||
```csharp |
|||
public class CounterActor : Actor, ICounterActor |
|||
{ |
|||
private const string CountStateName = "count"; |
|||
|
|||
public CounterActor(ActorHost host) : base(host) |
|||
{ |
|||
} |
|||
|
|||
public async Task<int> GetCountAsync() |
|||
{ |
|||
var count = await StateManager.TryGetStateAsync<int>(CountStateName); |
|||
return count.HasValue ? count.Value : 0; |
|||
} |
|||
|
|||
public async Task IncrementCountAsync() |
|||
{ |
|||
var currentCount = await GetCountAsync(); |
|||
await StateManager.SetStateAsync(CountStateName, currentCount + 1); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 响应格式 |
|||
|
|||
当启用包装时,Actor方法的响应将采用以下格式: |
|||
|
|||
```json |
|||
{ |
|||
"code": "0", // 响应代码,默认"0"表示成功 |
|||
"message": "Success", // 响应消息 |
|||
"details": null, // 附加详情(可选) |
|||
"result": { // 实际响应数据 |
|||
// ... Actor方法的返回值 |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 错误处理 |
|||
|
|||
模块自动处理Actor方法调用的错误: |
|||
* 对于包装的响应: |
|||
* 解包响应并检查代码 |
|||
* 如果代码与`CodeWithSuccess`不匹配,抛出`AbpRemoteCallException` |
|||
* 在异常中包含错误消息、详情和代码 |
|||
* 支持自定义错误代码映射 |
|||
* 对于Actor运行时错误: |
|||
* 自动包装为标准错误响应 |
|||
* 保留原始异常信息 |
|||
* 包含Actor相关的上下文信息 |
|||
|
|||
### 错误响应示例 |
|||
|
|||
```json |
|||
{ |
|||
"code": "ERROR_001", |
|||
"message": "Actor方法调用失败", |
|||
"details": "Actor 'counter' 的状态访问失败", |
|||
"result": null |
|||
} |
|||
``` |
|||
|
|||
## 高级用法 |
|||
|
|||
### 1. 控制响应包装 |
|||
|
|||
可以通过HTTP头控制单个Actor调用的响应包装: |
|||
|
|||
```csharp |
|||
// 在请求头中添加 |
|||
var headers = new Dictionary<string, string> |
|||
{ |
|||
{ "X-Abp-Wrap-Result", "true" }, // 强制启用包装 |
|||
// 或 |
|||
{ "X-Abp-Dont-Wrap-Result", "true" } // 强制禁用包装 |
|||
}; |
|||
|
|||
// 在Actor方法中使用 |
|||
public async Task<int> GetCountAsync() |
|||
{ |
|||
var context = ActorContext.GetContext(); |
|||
context.Headers.Add("X-Abp-Wrap-Result", "true"); |
|||
|
|||
var count = await StateManager.TryGetStateAsync<int>(CountStateName); |
|||
return count.HasValue ? count.Value : 0; |
|||
} |
|||
``` |
|||
|
|||
### 2. 自定义错误处理 |
|||
|
|||
```csharp |
|||
public class CustomActorErrorHandler : IAbpWrapperErrorHandler |
|||
{ |
|||
public Task HandleAsync(AbpWrapperErrorContext context) |
|||
{ |
|||
if (context.Exception is ActorMethodInvocationException actorException) |
|||
{ |
|||
// 自定义Actor错误处理逻辑 |
|||
context.Response = new WrapperResponse |
|||
{ |
|||
Code = "ACTOR_ERROR", |
|||
Message = actorException.Message, |
|||
Details = actorException.ActorId |
|||
}; |
|||
} |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 注意事项 |
|||
|
|||
* 响应包装可以通过以下方式控制: |
|||
* 配置文件中的全局设置 |
|||
* HTTP头控制单个请求 |
|||
* Actor方法中的动态控制 |
|||
* Actor方法的错误响应会保持原始错误结构 |
|||
* 模块与ABP的远程服务错误处理系统集成 |
|||
* 建议在微服务架构中统一使用响应包装 |
|||
* 包装格式可以通过继承`IAbpWrapperResponseBuilder`自定义 |
|||
* Actor状态操作的错误会被正确包装和处理 |
|||
|
|||
[查看英文](README.EN.md) |
|||
@ -0,0 +1,123 @@ |
|||
# LINGYUN.Abp.Dapr.Actors.AspNetCore |
|||
|
|||
Integration of Dapr.Actors with ASP.NET Core in the ABP framework. This module automatically scans and registers Actor services defined within assemblies as Dapr.Actors. |
|||
|
|||
## Features |
|||
|
|||
* Automatic Actor service registration |
|||
* Integration with ABP's dependency injection system |
|||
* Support for custom Actor type names through `RemoteServiceAttribute` |
|||
* Actor runtime configuration through `ActorRuntimeOptions` |
|||
* Automatic Actor endpoint mapping |
|||
* Actor interface validation |
|||
|
|||
## Basic Usage |
|||
|
|||
Module reference as needed: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDaprActorsAspNetCoreModule))] |
|||
public class YourProjectModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Configure Actor runtime options |
|||
PreConfigure<ActorRuntimeOptions>(options => |
|||
{ |
|||
options.ActorIdleTimeout = TimeSpan.FromMinutes(60); |
|||
options.ActorScanInterval = TimeSpan.FromSeconds(30); |
|||
options.DrainOngoingCallTimeout = TimeSpan.FromSeconds(30); |
|||
options.DrainRebalancedActors = true; |
|||
options.RemindersStoragePartitions = 7; |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Implementation Example |
|||
|
|||
1. Define Actor Interface |
|||
|
|||
```csharp |
|||
[RemoteService("counter")] // Optional: customize Actor type name |
|||
public interface ICounterActor : IActor |
|||
{ |
|||
Task<int> GetCountAsync(); |
|||
Task IncrementCountAsync(); |
|||
} |
|||
``` |
|||
|
|||
2. Implement Actor |
|||
|
|||
```csharp |
|||
public class CounterActor : Actor, ICounterActor |
|||
{ |
|||
private const string CountStateName = "count"; |
|||
|
|||
public CounterActor(ActorHost host) : base(host) |
|||
{ |
|||
} |
|||
|
|||
public async Task<int> GetCountAsync() |
|||
{ |
|||
var count = await StateManager.TryGetStateAsync<int>(CountStateName); |
|||
return count.HasValue ? count.Value : 0; |
|||
} |
|||
|
|||
public async Task IncrementCountAsync() |
|||
{ |
|||
var currentCount = await GetCountAsync(); |
|||
await StateManager.SetStateAsync(CountStateName, currentCount + 1); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
The module will automatically: |
|||
1. Detect the `CounterActor` implementation |
|||
2. Register it with Dapr.Actors |
|||
3. Configure the Actor runtime |
|||
4. Map the Actor endpoints |
|||
|
|||
## Actor Runtime Configuration |
|||
|
|||
The module supports all standard Dapr Actor runtime configurations through `ActorRuntimeOptions`: |
|||
|
|||
```csharp |
|||
PreConfigure<ActorRuntimeOptions>(options => |
|||
{ |
|||
// Actor timeout settings |
|||
options.ActorIdleTimeout = TimeSpan.FromMinutes(60); |
|||
options.ActorScanInterval = TimeSpan.FromSeconds(30); |
|||
|
|||
// Draining settings |
|||
options.DrainOngoingCallTimeout = TimeSpan.FromSeconds(30); |
|||
options.DrainRebalancedActors = true; |
|||
|
|||
// Reminders settings |
|||
options.RemindersStoragePartitions = 7; |
|||
|
|||
// Custom serialization settings |
|||
options.JsonSerializerOptions = new JsonSerializerOptions |
|||
{ |
|||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase |
|||
}; |
|||
}); |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
* Actor implementations must be registered in the dependency injection container |
|||
* Actor interfaces must inherit from `IActor` |
|||
* Actor type names can be customized using the `RemoteServiceAttribute` |
|||
* The module automatically maps Actor endpoints using ABP's endpoint routing system |
|||
* Actor runtime options should be configured in the `PreConfigureServices` phase |
|||
|
|||
## Endpoint Mapping |
|||
|
|||
The module automatically maps the following Actor endpoints: |
|||
* `/dapr/actors/{actorType}/{actorId}/method/{methodName}` |
|||
* `/dapr/actors/{actorType}/{actorId}/state` |
|||
* `/dapr/actors/{actorType}/{actorId}/reminders/{reminderName}` |
|||
* `/dapr/actors/{actorType}/{actorId}/timers/{timerName}` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,129 @@ |
|||
# LINGYUN.Abp.Dapr.Actors |
|||
|
|||
Dapr.IActor client proxy module |
|||
|
|||
## Features |
|||
|
|||
* Dynamic proxy generation for Dapr Actors |
|||
* Integration with ABP's remote service system |
|||
* Support for Actor authentication and authorization |
|||
* Multi-tenant support |
|||
* Automatic request/response handling |
|||
* Custom error handling |
|||
* Culture and language header support |
|||
|
|||
## Basic Usage |
|||
|
|||
Module reference as needed: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDaprActorsModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Register proxies similar to Volo.Abp.Http.Client module |
|||
context.Services.AddDaprActorProxies( |
|||
typeof(YouProjectActorInterfaceModule).Assembly, // Search for IActor definitions in YouProjectActorInterfaceModule |
|||
RemoteServiceName |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
```json |
|||
{ |
|||
"RemoteServices": { |
|||
"Default": { |
|||
"BaseUrl": "http://localhost:3500", // Required, Dapr HTTP endpoint |
|||
"DaprApiToken": "your-api-token", // Optional, Dapr API Token |
|||
"RequestTimeout": "30000" // Optional, request timeout in milliseconds (default: 30000) |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Implementation Example |
|||
|
|||
1. Actor Interface Definition |
|||
|
|||
```csharp |
|||
public interface ICounterActor : IActor |
|||
{ |
|||
Task<int> GetCountAsync(); |
|||
Task IncrementCountAsync(); |
|||
} |
|||
``` |
|||
|
|||
2. Actor Implementation |
|||
|
|||
```csharp |
|||
public class CounterActor : Actor, ICounterActor |
|||
{ |
|||
private const string CountStateName = "count"; |
|||
|
|||
public CounterActor(ActorHost host) : base(host) |
|||
{ |
|||
} |
|||
|
|||
public async Task<int> GetCountAsync() |
|||
{ |
|||
var count = await StateManager.TryGetStateAsync<int>(CountStateName); |
|||
return count.HasValue ? count.Value : 0; |
|||
} |
|||
|
|||
public async Task IncrementCountAsync() |
|||
{ |
|||
var currentCount = await GetCountAsync(); |
|||
await StateManager.SetStateAsync(CountStateName, currentCount + 1); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
3. Client Usage |
|||
|
|||
```csharp |
|||
public class CounterService |
|||
{ |
|||
private readonly ICounterActor _counterActor; |
|||
|
|||
public CounterService(ICounterActor counterActor) |
|||
{ |
|||
_counterActor = counterActor; |
|||
} |
|||
|
|||
public async Task<int> GetAndIncrementCountAsync() |
|||
{ |
|||
var count = await _counterActor.GetCountAsync(); |
|||
await _counterActor.IncrementCountAsync(); |
|||
return count; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
* Actor methods must return `Task` or `Task<T>` |
|||
* Actor methods can have at most one parameter |
|||
* Actor instances are single-threaded, processing one request at a time |
|||
* Actor state is managed by the Dapr runtime |
|||
* The module automatically handles: |
|||
* Authentication headers |
|||
* Tenant context |
|||
* Culture information |
|||
* Request timeouts |
|||
* Error handling |
|||
|
|||
## Error Handling |
|||
|
|||
The module provides custom error handling for Actor calls: |
|||
* `AbpDaprActorCallException`: Thrown when an Actor method call fails |
|||
* `ActorMethodInvocationException`: Contains detailed information about the failure |
|||
* Error responses include: |
|||
* Error message |
|||
* Error code |
|||
* Original exception type |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,189 @@ |
|||
# LINGYUN.Abp.Dapr.Client.Wrapper |
|||
|
|||
Dapr service-to-service invocation module that handles wrapped response result unpacking. |
|||
|
|||
## Features |
|||
|
|||
* Automatic response result wrapping/unwrapping |
|||
* Integration with ABP's wrapper system |
|||
* Custom error handling for wrapped responses |
|||
* Support for success/error code configuration |
|||
* HTTP status code mapping |
|||
* Support for custom response wrapper format |
|||
* Flexible wrapping control options |
|||
|
|||
## Basic Usage |
|||
|
|||
Module reference as needed: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDaprClientModule))] |
|||
public class AbpDaprClientWrapperModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
## Configuration Options |
|||
|
|||
The module uses `AbpWrapperOptions` from the `LINGYUN.Abp.Wrapper` package for configuration: |
|||
|
|||
```json |
|||
{ |
|||
"Wrapper": { |
|||
"IsEnabled": true, // Enable/disable response wrapping |
|||
"CodeWithSuccess": "0", // Success code in wrapped response |
|||
"HttpStatusCode": 200, // Default HTTP status code for wrapped responses |
|||
"WrapOnError": true, // Whether to wrap error responses |
|||
"WrapOnSuccess": true // Whether to wrap success responses |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Implementation Example |
|||
|
|||
1. Service Definition |
|||
|
|||
```csharp |
|||
public interface IProductService |
|||
{ |
|||
Task<ProductDto> GetAsync(string id); |
|||
Task<List<ProductDto>> GetListAsync(); |
|||
Task<ProductDto> CreateAsync(CreateProductDto input); |
|||
} |
|||
``` |
|||
|
|||
2. Service Implementation |
|||
|
|||
```csharp |
|||
public class ProductService : IProductService |
|||
{ |
|||
private readonly DaprClient _daprClient; |
|||
|
|||
public ProductService(DaprClient daprClient) |
|||
{ |
|||
_daprClient = daprClient; |
|||
} |
|||
|
|||
public async Task<ProductDto> GetAsync(string id) |
|||
{ |
|||
// Response wrapping is handled automatically |
|||
return await _daprClient.InvokeMethodAsync<ProductDto>( |
|||
"product-service", // Target service ID |
|||
$"api/products/{id}", // Method path |
|||
HttpMethod.Get |
|||
); |
|||
} |
|||
|
|||
public async Task<List<ProductDto>> GetListAsync() |
|||
{ |
|||
return await _daprClient.InvokeMethodAsync<List<ProductDto>>( |
|||
"product-service", |
|||
"api/products", |
|||
HttpMethod.Get |
|||
); |
|||
} |
|||
|
|||
public async Task<ProductDto> CreateAsync(CreateProductDto input) |
|||
{ |
|||
return await _daprClient.InvokeMethodAsync<ProductDto>( |
|||
"product-service", |
|||
"api/products", |
|||
HttpMethod.Post, |
|||
input |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Response Format |
|||
|
|||
When wrapping is enabled, the response will be in the following format: |
|||
|
|||
```json |
|||
{ |
|||
"code": "0", // Response code, "0" indicates success by default |
|||
"message": "Success", // Response message |
|||
"details": null, // Additional details (optional) |
|||
"result": { // Actual response data |
|||
// ... response content |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Error Handling |
|||
|
|||
The module automatically handles error responses: |
|||
* For wrapped responses (with `AbpWrapResult` header): |
|||
* Unwraps the response and checks the code |
|||
* If code doesn't match `CodeWithSuccess`, throws `AbpRemoteCallException` |
|||
* Includes error message, details, and code in the exception |
|||
* Supports custom error code mapping |
|||
* For unwrapped responses: |
|||
* Passes through the original response |
|||
* Uses standard HTTP error handling |
|||
* Maintains original error information |
|||
|
|||
### Error Response Example |
|||
|
|||
```json |
|||
{ |
|||
"code": "ERROR_001", |
|||
"message": "Product not found", |
|||
"details": "Product with ID '123' does not exist", |
|||
"result": null |
|||
} |
|||
``` |
|||
|
|||
## Advanced Usage |
|||
|
|||
### 1. Controlling Response Wrapping |
|||
|
|||
Response wrapping can be controlled per request using HTTP headers: |
|||
|
|||
```csharp |
|||
// Add to request headers |
|||
var headers = new Dictionary<string, string> |
|||
{ |
|||
{ "X-Abp-Wrap-Result", "true" }, // Force enable wrapping |
|||
// or |
|||
{ "X-Abp-Dont-Wrap-Result", "true" } // Force disable wrapping |
|||
}; |
|||
|
|||
await _daprClient.InvokeMethodAsync<ProductDto>( |
|||
"product-service", |
|||
"api/products", |
|||
HttpMethod.Get, |
|||
null, |
|||
headers |
|||
); |
|||
``` |
|||
|
|||
### 2. Custom Error Handling |
|||
|
|||
```csharp |
|||
public class CustomErrorHandler : IAbpWrapperErrorHandler |
|||
{ |
|||
public Task HandleAsync(AbpWrapperErrorContext context) |
|||
{ |
|||
// Custom error handling logic |
|||
if (context.Response.Code == "CUSTOM_ERROR") |
|||
{ |
|||
// Special handling |
|||
} |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
* Response wrapping can be controlled through: |
|||
* Global settings in configuration |
|||
* HTTP headers for individual requests |
|||
* Dynamic control in code |
|||
* Error responses maintain original error structure when possible |
|||
* The module integrates with ABP's remote service error handling system |
|||
* Recommended to use response wrapping consistently in microservices architecture |
|||
* Wrapper format can be customized by implementing `IAbpWrapperResponseBuilder` |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,277 @@ |
|||
[Actors](../README.md) | Dapr.Client Documentation |
|||
|
|||
# LINGYUN.Abp.Dapr.Client |
|||
|
|||
Implements service-to-service invocation as described in the Dapr documentation. The project design is consistent with Volo.Abp.Http.Client and can seamlessly replace Volo.Abp.Http.Client through configuration. |
|||
|
|||
For configuration reference, see [AbpRemoteServiceOptions](https://docs.abp.io/en/abp/latest/API/Dynamic-CSharp-API-Clients#abpremoteserviceoptions) |
|||
|
|||
## Features |
|||
|
|||
* Integration with ABP remote service system |
|||
* Dynamic proxy generation |
|||
* Service discovery and load balancing |
|||
* Custom request and response handling |
|||
* Error handling and formatting |
|||
* Multiple service endpoint configuration |
|||
* Request/response interceptors |
|||
* Custom DaprClient behavior support |
|||
|
|||
## Configuration Options |
|||
|
|||
```json |
|||
{ |
|||
"RemoteServices": { |
|||
"Default": { |
|||
"AppId": "default-app", // Dapr application ID |
|||
"BaseUrl": "http://localhost:3500", // Dapr HTTP endpoint |
|||
"HealthCheckUrl": "/health", // Health check endpoint |
|||
"RequestTimeout": 30000, // Request timeout in milliseconds |
|||
"RetryCount": 3, // Number of retry attempts |
|||
"RetryWaitTime": 1000 // Retry wait time in milliseconds |
|||
}, |
|||
"System": { |
|||
"AppId": "system-app", |
|||
"BaseUrl": "http://localhost:50000", |
|||
"Headers": { // Custom request headers |
|||
"Tenant": "Default", |
|||
"Culture": "en-US" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
Module reference as needed: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDaprClientModule))] |
|||
public class YourProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Register proxies similar to Volo.Abp.Http.Client module |
|||
context.Services.AddDaprClientProxies( |
|||
typeof(YourProjectInterfaceModule).Assembly, // Search for remote service definitions |
|||
RemoteServiceName |
|||
); |
|||
|
|||
// Configure proxy options |
|||
Configure<AbpDaprClientProxyOptions>(options => |
|||
{ |
|||
// Configure request interceptor |
|||
options.ProxyRequestActions.Add((appId, request) => |
|||
{ |
|||
request.Headers.Add("Custom-Header", "Value"); |
|||
}); |
|||
|
|||
// Configure response handling |
|||
options.OnResponse(async (response, serviceProvider) => |
|||
{ |
|||
return await response.Content.ReadAsStringAsync(); |
|||
}); |
|||
|
|||
// Configure error handling |
|||
options.OnError(async (response, serviceProvider) => |
|||
{ |
|||
var error = await response.Content.ReadAsStringAsync(); |
|||
return new RemoteServiceErrorInfo |
|||
{ |
|||
Code = response.StatusCode.ToString(), |
|||
Message = error |
|||
}; |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Implementation Example |
|||
|
|||
### 1. Interface Definition |
|||
|
|||
```csharp |
|||
// IApplicationService implements IRemoteService |
|||
public interface ISystemAppService : IApplicationService |
|||
{ |
|||
Task<string> GetAsync(); |
|||
Task<SystemDto> CreateAsync(CreateSystemDto input); |
|||
Task<List<SystemDto>> GetListAsync(); |
|||
Task DeleteAsync(string id); |
|||
} |
|||
|
|||
public class SystemInterfaceModule : AbpModule |
|||
{ |
|||
} |
|||
``` |
|||
|
|||
### 2. Server Implementation |
|||
|
|||
```csharp |
|||
[DependsOn( |
|||
typeof(SystemInterfaceModule), |
|||
typeof(AbpAspNetCoreMvcModule) |
|||
)] |
|||
public class SystemServerModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<IMvcBuilder>(mvcBuilder => |
|||
{ |
|||
mvcBuilder.AddApplicationPartIfNotExists(typeof(SystemServerModule).Assembly); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public class SystemAppService : ApplicationService, ISystemAppService |
|||
{ |
|||
private readonly ISystemRepository _systemRepository; |
|||
|
|||
public SystemAppService(ISystemRepository systemRepository) |
|||
{ |
|||
_systemRepository = systemRepository; |
|||
} |
|||
|
|||
public async Task<string> GetAsync() |
|||
{ |
|||
return "System"; |
|||
} |
|||
|
|||
public async Task<SystemDto> CreateAsync(CreateSystemDto input) |
|||
{ |
|||
var system = await _systemRepository.CreateAsync( |
|||
new System |
|||
{ |
|||
Name = input.Name, |
|||
Description = input.Description |
|||
} |
|||
); |
|||
return ObjectMapper.Map<System, SystemDto>(system); |
|||
} |
|||
|
|||
public async Task<List<SystemDto>> GetListAsync() |
|||
{ |
|||
var systems = await _systemRepository.GetListAsync(); |
|||
return ObjectMapper.Map<List<System>, List<SystemDto>>(systems); |
|||
} |
|||
|
|||
public async Task DeleteAsync(string id) |
|||
{ |
|||
await _systemRepository.DeleteAsync(id); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 3. Client Usage |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDaprClientModule))] |
|||
public class SystemClientModule : AbpModule |
|||
{ |
|||
private const string RemoteServiceName = "System"; |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Register proxies |
|||
context.Services.AddDaprClientProxies( |
|||
typeof(SystemInterfaceModule).Assembly, |
|||
RemoteServiceName |
|||
); |
|||
|
|||
// Configure retry policy |
|||
context.Services.AddDaprClientBuilder(builder => |
|||
{ |
|||
builder.ConfigureHttpClient((sp, client) => |
|||
{ |
|||
client.Timeout = TimeSpan.FromSeconds(30); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public class SystemService |
|||
{ |
|||
private readonly ISystemAppService _systemAppService; |
|||
|
|||
public SystemService(ISystemAppService systemAppService) |
|||
{ |
|||
_systemAppService = systemAppService; |
|||
} |
|||
|
|||
public async Task<List<SystemDto>> GetSystemsAsync() |
|||
{ |
|||
try |
|||
{ |
|||
return await _systemAppService.GetListAsync(); |
|||
} |
|||
catch (AbpRemoteCallException ex) |
|||
{ |
|||
// Handle remote call exception |
|||
_logger.LogError(ex, "Failed to get systems"); |
|||
throw; |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Advanced Usage |
|||
|
|||
### 1. Custom Request Handling |
|||
|
|||
```csharp |
|||
public class CustomRequestHandler |
|||
{ |
|||
public void Configure(HttpRequestMessage request) |
|||
{ |
|||
request.Headers.Add("Correlation-Id", Guid.NewGuid().ToString()); |
|||
request.Headers.Add("Client-Version", "1.0.0"); |
|||
} |
|||
} |
|||
|
|||
// Register in module |
|||
Configure<AbpDaprClientProxyOptions>(options => |
|||
{ |
|||
options.ProxyRequestActions.Add((appId, request) => |
|||
{ |
|||
new CustomRequestHandler().Configure(request); |
|||
}); |
|||
}); |
|||
``` |
|||
|
|||
### 2. Custom Response Handling |
|||
|
|||
```csharp |
|||
public class CustomResponseHandler |
|||
{ |
|||
public async Task<string> HandleAsync(HttpResponseMessage response) |
|||
{ |
|||
var content = await response.Content.ReadAsStringAsync(); |
|||
// Custom response handling logic |
|||
return content; |
|||
} |
|||
} |
|||
|
|||
// Register in module |
|||
Configure<AbpDaprClientProxyOptions>(options => |
|||
{ |
|||
options.OnResponse(async (response, sp) => |
|||
{ |
|||
return await new CustomResponseHandler().HandleAsync(response); |
|||
}); |
|||
}); |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
* Remote service interfaces must inherit `IRemoteService` |
|||
* Configuration changes require recreating proxy instances |
|||
* Configure appropriate timeout and retry policies |
|||
* Error handling should consider network exceptions and service unavailability |
|||
* Enable service discovery in production environments |
|||
* Use health checks to ensure service availability |
|||
* Request header configuration should consider security and authentication requirements |
|||
* Logging is important for problem diagnosis |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,204 @@ |
|||
# LINGYUN.Abp.Dapr |
|||
|
|||
Dapr integration base module, implementing the named singleton DaprClient as described in the Dapr documentation. |
|||
|
|||
See: https://docs.dapr.io/developing-applications/sdks/dotnet/dotnet-client/dotnet-daprclient-usage |
|||
|
|||
## Features |
|||
|
|||
* Support for creating default and named DaprClient instances |
|||
* Support for configuring HTTP and gRPC endpoints |
|||
* Support for custom JSON serialization options |
|||
* Support for Dapr API Token authentication |
|||
* Support for gRPC channel configuration |
|||
* Support for DaprClient instance configuration and builder configuration extensions |
|||
* Support for multiple Dapr Sidecar connections |
|||
* Support for custom DaprClient behaviors |
|||
|
|||
## Configuration Options |
|||
|
|||
```json |
|||
{ |
|||
"Dapr": { |
|||
"Client": { |
|||
"DaprApiToken": "your-api-token", // Optional, Dapr API Token |
|||
"HttpEndpoint": "http://localhost:3500", // Optional, HTTP endpoint |
|||
"GrpcEndpoint": "http://localhost:50001", // Optional, gRPC endpoint |
|||
"JsonSerializerOptions": { // Optional, JSON serialization options |
|||
"PropertyNamingPolicy": "CamelCase", |
|||
"PropertyNameCaseInsensitive": true, |
|||
"WriteIndented": true, |
|||
"DefaultIgnoreCondition": "WhenWritingNull" |
|||
}, |
|||
"GrpcChannelOptions": { // Optional, gRPC channel options |
|||
"Credentials": "Insecure", |
|||
"MaxReceiveMessageSize": 1048576, |
|||
"MaxSendMessageSize": 1048576 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
Module reference as needed: |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDaprModule))] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Create a DaprClient |
|||
context.Services.AddDaprClient(); |
|||
|
|||
// Create a named DaprClient |
|||
context.Services.AddDaprClient("__DaprClient"); |
|||
|
|||
// Configure DaprClient options |
|||
Configure<DaprClientFactoryOptions>(options => |
|||
{ |
|||
options.HttpEndpoint = "http://localhost:3500"; |
|||
options.GrpcEndpoint = "http://localhost:50001"; |
|||
options.DaprApiToken = "your-api-token"; |
|||
|
|||
// Add DaprClient configuration actions |
|||
options.DaprClientActions.Add(client => |
|||
{ |
|||
// Configure DaprClient instance |
|||
}); |
|||
|
|||
// Add DaprClientBuilder configuration actions |
|||
options.DaprClientBuilderActions.Add(builder => |
|||
{ |
|||
// Configure DaprClientBuilder |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Advanced Usage |
|||
|
|||
### 1. Configure DaprClient |
|||
|
|||
```csharp |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Configure named DaprClient |
|||
context.Services.AddDaprClient("CustomClient", builder => |
|||
{ |
|||
// Configure HTTP endpoint |
|||
builder.UseHttpEndpoint("http://localhost:3500"); |
|||
|
|||
// Configure gRPC endpoint |
|||
builder.UseGrpcEndpoint("http://localhost:50001"); |
|||
|
|||
// Configure API Token |
|||
builder.UseDaprApiToken("your-api-token"); |
|||
|
|||
// Configure JSON serialization options |
|||
builder.UseJsonSerializerOptions(new JsonSerializerOptions |
|||
{ |
|||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, |
|||
PropertyNameCaseInsensitive = true |
|||
}); |
|||
|
|||
// Configure gRPC channel options |
|||
builder.UseGrpcChannelOptions(new GrpcChannelOptions |
|||
{ |
|||
MaxReceiveMessageSize = 1024 * 1024, |
|||
MaxSendMessageSize = 1024 * 1024 |
|||
}); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
### 2. Using DaprClient |
|||
|
|||
```csharp |
|||
public class YourService |
|||
{ |
|||
private readonly IDaprClientFactory _daprClientFactory; |
|||
|
|||
public YourService(IDaprClientFactory daprClientFactory) |
|||
{ |
|||
_daprClientFactory = daprClientFactory; |
|||
} |
|||
|
|||
public async Task InvokeMethodAsync() |
|||
{ |
|||
// Use default client |
|||
var defaultClient = _daprClientFactory.CreateClient(); |
|||
|
|||
// Use named client |
|||
var namedClient = _daprClientFactory.CreateClient("CustomClient"); |
|||
|
|||
// Invoke service method |
|||
var response = await defaultClient.InvokeMethodAsync<OrderDto>( |
|||
HttpMethod.Get, |
|||
"order-service", // Target service ID |
|||
"api/orders/1", // Method path |
|||
new { id = 1 } // Request parameters |
|||
); |
|||
|
|||
// Publish event |
|||
await defaultClient.PublishEventAsync( |
|||
"pubsub", // Pub/sub component name |
|||
"order-created", // Topic name |
|||
response // Event data |
|||
); |
|||
|
|||
// Save state |
|||
await defaultClient.SaveStateAsync( |
|||
"statestore", // State store component name |
|||
"order-1", // Key |
|||
response // Value |
|||
); |
|||
|
|||
// Get state |
|||
var state = await defaultClient.GetStateAsync<OrderDto>( |
|||
"statestore", // State store component name |
|||
"order-1" // Key |
|||
); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 3. Custom DaprClient Behavior |
|||
|
|||
```csharp |
|||
public class CustomDaprClientBehavior |
|||
{ |
|||
public void Configure(DaprClient client) |
|||
{ |
|||
// Configure custom behavior |
|||
} |
|||
} |
|||
|
|||
// Register in module |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<DaprClientFactoryOptions>(options => |
|||
{ |
|||
options.DaprClientActions.Add(client => |
|||
{ |
|||
new CustomDaprClientBehavior().Configure(client); |
|||
}); |
|||
}); |
|||
} |
|||
``` |
|||
|
|||
## Important Notes |
|||
|
|||
* DaprClient instances are thread-safe, singleton pattern is recommended |
|||
* Named DaprClients can have different configurations, suitable for scenarios requiring connections to different Dapr Sidecars |
|||
* Configuration changes require recreating the DaprClient instance to take effect |
|||
* Pay attention to performance and resource consumption when configuring gRPC channels |
|||
* JSON serialization options affect all requests using that DaprClient |
|||
* API Tokens should be managed through secure configuration management systems |
|||
* Recommended to use different named DaprClients for different microservices |
|||
* Configure appropriate timeout and retry policies in production environments |
|||
|
|||
[查看中文](README.md) |
|||
@ -0,0 +1,256 @@ |
|||
# LINGYUN.Abp.DistributedLocking.Dapr |
|||
|
|||
An ABP distributed locking implementation based on the Dapr distributed lock API. This module provides seamless integration with Dapr's distributed locking service, supporting cross-service and cross-instance locking capabilities. |
|||
|
|||
Reference: [Dapr Distributed Lock API](https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/distributed-lock-api-overview/) |
|||
|
|||
## Features |
|||
|
|||
* Integration with ABP distributed locking system |
|||
* Support for custom lock resource owner identification |
|||
* Configurable lock timeout duration |
|||
* Automatic lock release support |
|||
* Multiple lock storage component support |
|||
* Lock acquisition and release event notifications |
|||
* Distributed lock health check support |
|||
|
|||
## Configuration Options |
|||
|
|||
```json |
|||
{ |
|||
"DistributedLocking": { |
|||
"Dapr": { |
|||
"StoreName": "lockstore", // Storage name defined in Dapr component |
|||
"DefaultIdentifier": "dapr-lock-owner", // Default lock resource owner identifier |
|||
"DefaultTimeout": "00:00:30" // Default lock timeout (30 seconds) |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Basic Usage |
|||
|
|||
### 1. Module Configuration |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDistributedLockingDaprModule))] |
|||
public class YourProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// Basic configuration |
|||
Configure<AbpDistributedLockingDaprOptions>(options => |
|||
{ |
|||
options.StoreName = "redis-lock"; // Use Redis as lock storage |
|||
options.DefaultIdentifier = "my-service"; // Custom lock owner identifier |
|||
options.DefaultTimeout = TimeSpan.FromMinutes(1); // Set default timeout to 1 minute |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 2. Basic Usage |
|||
|
|||
```csharp |
|||
public class OrderService |
|||
{ |
|||
private readonly IDistributedLockProvider _lockProvider; |
|||
|
|||
public OrderService(IDistributedLockProvider lockProvider) |
|||
{ |
|||
_lockProvider = lockProvider; |
|||
} |
|||
|
|||
public async Task ProcessOrderAsync(string orderId) |
|||
{ |
|||
// Try to acquire lock |
|||
using (var handle = await _lockProvider.TryAcquireAsync($"order:{orderId}")) |
|||
{ |
|||
if (handle != null) |
|||
{ |
|||
try |
|||
{ |
|||
// Execute business logic that requires locking |
|||
await ProcessOrderInternalAsync(orderId); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
// Handle exception |
|||
_logger.LogError(ex, "Error occurred while processing order"); |
|||
throw; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
throw new ConcurrencyException("Order is being processed by another process"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 3. Advanced Usage |
|||
|
|||
```csharp |
|||
public class InventoryService |
|||
{ |
|||
private readonly IDistributedLockProvider _lockProvider; |
|||
private readonly ILogger<InventoryService> _logger; |
|||
|
|||
public InventoryService( |
|||
IDistributedLockProvider lockProvider, |
|||
ILogger<InventoryService> logger) |
|||
{ |
|||
_lockProvider = lockProvider; |
|||
_logger = logger; |
|||
} |
|||
|
|||
public async Task UpdateInventoryAsync(string productId, int quantity) |
|||
{ |
|||
// Custom lock configuration |
|||
var lockOptions = new DistributedLockOptions |
|||
{ |
|||
Timeout = TimeSpan.FromSeconds(10), // Custom timeout |
|||
RetryDelay = TimeSpan.FromMilliseconds(100) // Retry delay |
|||
}; |
|||
|
|||
try |
|||
{ |
|||
using (var handle = await _lockProvider.TryAcquireAsync( |
|||
$"inventory:{productId}", |
|||
lockOptions)) |
|||
{ |
|||
if (handle == null) |
|||
{ |
|||
_logger.LogWarning("Unable to acquire inventory lock for product ID: {ProductId}", productId); |
|||
throw new ConcurrencyException("Unable to acquire inventory lock"); |
|||
} |
|||
|
|||
// Execute inventory update operation |
|||
await UpdateInventoryInternalAsync(productId, quantity); |
|||
} |
|||
} |
|||
catch (Exception ex) when (ex is not ConcurrencyException) |
|||
{ |
|||
_logger.LogError(ex, "Error occurred while updating inventory"); |
|||
throw; |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Component Configuration |
|||
|
|||
### Redis Lock Store Configuration Example |
|||
|
|||
```yaml |
|||
apiVersion: dapr.io/v1alpha1 |
|||
kind: Component |
|||
metadata: |
|||
name: redis-lock # Corresponds to StoreName configuration |
|||
spec: |
|||
type: lock.redis |
|||
version: v1 |
|||
metadata: |
|||
- name: redisHost |
|||
value: localhost:6379 |
|||
- name: redisPassword |
|||
value: "" |
|||
- name: enableTLS |
|||
value: false |
|||
- name: maxRetries |
|||
value: 5 |
|||
- name: maxRetryBackoff |
|||
value: 5s |
|||
``` |
|||
|
|||
### Consul Lock Store Configuration Example |
|||
|
|||
```yaml |
|||
apiVersion: dapr.io/v1alpha1 |
|||
kind: Component |
|||
metadata: |
|||
name: consul-lock |
|||
spec: |
|||
type: lock.consul |
|||
version: v1 |
|||
metadata: |
|||
- name: host |
|||
value: localhost:8500 |
|||
- name: sessionTTL |
|||
value: 10 |
|||
- name: scheme |
|||
value: http |
|||
``` |
|||
|
|||
## Core Interfaces |
|||
|
|||
### ILockOwnerFinder |
|||
|
|||
Interface for providing lock resource owner identification. |
|||
|
|||
```csharp |
|||
public interface ILockOwnerFinder |
|||
{ |
|||
string GetOwner(); |
|||
} |
|||
``` |
|||
|
|||
The default implementation `LockOwnerFinder`: |
|||
1. Primarily uses the current user ID as the lock owner identifier |
|||
2. Falls back to the configured `DefaultIdentifier` if no user is logged in |
|||
|
|||
### Custom Lock Owner Identifier Implementation |
|||
|
|||
```csharp |
|||
public class CustomLockOwnerFinder : ILockOwnerFinder |
|||
{ |
|||
private readonly ICurrentTenant _currentTenant; |
|||
|
|||
public CustomLockOwnerFinder(ICurrentTenant currentTenant) |
|||
{ |
|||
_currentTenant = currentTenant; |
|||
} |
|||
|
|||
public string GetOwner() |
|||
{ |
|||
// Use combination of tenant ID and machine name as lock owner identifier |
|||
return $"{_currentTenant.Id ?? "host"}-{Environment.MachineName}"; |
|||
} |
|||
} |
|||
|
|||
// Register custom implementation |
|||
context.Services.AddTransient<ILockOwnerFinder, CustomLockOwnerFinder>(); |
|||
``` |
|||
|
|||
## Best Practices |
|||
|
|||
1. **Set Appropriate Timeout Duration** |
|||
- Set timeout based on expected execution time of business operations |
|||
- Avoid setting excessively long timeouts to prevent deadlocks |
|||
|
|||
2. **Proper Lock Granularity** |
|||
- Keep lock scope as small as possible, only lock necessary resources |
|||
- Avoid holding locks for extended periods, release promptly |
|||
|
|||
3. **Exception Handling** |
|||
- Always use locks within using blocks |
|||
- Handle lock acquisition failures appropriately |
|||
- Log critical lock operations |
|||
|
|||
4. **Performance Optimization** |
|||
- Use appropriate storage components |
|||
- Configure suitable retry policies |
|||
- Monitor lock usage |
|||
|
|||
## Important Notes |
|||
|
|||
* Ensure Dapr Sidecar is properly configured and running |
|||
* Distributed lock component must be correctly defined in Dapr configuration |
|||
* Set appropriate lock timeouts to avoid deadlocks |
|||
* Handle lock acquisition failures properly |
|||
* Consider performance impact in high-concurrency scenarios |
|||
* Configure health checks for lock components |
|||
* Add logging for important operations |
|||
|
|||
[查看中文](README.md) |
|||
@ -1,38 +1,256 @@ |
|||
# LINGYUN.Abp.DistributedLocking.Dapr |
|||
|
|||
Abp分布式锁的Dapr实现 |
|||
基于Dapr分布式锁API的ABP分布式锁实现。该模块提供了与Dapr分布式锁服务的无缝集成,支持跨服务、跨实例的分布式锁定功能。 |
|||
|
|||
See: https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/distributed-lock-api-overview/ |
|||
参考文档: [Dapr Distributed Lock API](https://docs.dapr.io/developing-applications/building-blocks/distributed-lock/distributed-lock-api-overview/) |
|||
|
|||
## 配置使用 |
|||
## 功能特性 |
|||
|
|||
模块按需引用 |
|||
* 与ABP分布式锁系统集成 |
|||
* 支持自定义锁资源拥有者标识 |
|||
* 支持可配置的锁定超时时间 |
|||
* 支持锁资源自动释放 |
|||
* 支持多种锁存储组件 |
|||
* 支持锁获取和释放的事件通知 |
|||
* 支持分布式锁的健康检查 |
|||
|
|||
## 配置选项 |
|||
|
|||
```json |
|||
{ |
|||
"DistributedLocking": { |
|||
"Dapr": { |
|||
"StoreName": "lockstore", // Dapr组件中定义的存储名称 |
|||
"DefaultIdentifier": "dapr-lock-owner", // 默认锁资源拥有者标识 |
|||
"DefaultTimeout": "00:00:30" // 默认锁定超时时间(30秒) |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 基础使用 |
|||
|
|||
### 1. 模块配置 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDistributedLockingDaprModule))] |
|||
public class YouProjectModule : AbpModule |
|||
public class YourProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// 基础配置 |
|||
Configure<AbpDistributedLockingDaprOptions>(options => |
|||
{ |
|||
options.StoreName = "store-name"; |
|||
options.DefaultIdentifier = "default-owner-id"; |
|||
options.DefaultTimeout = TimeSpan.FromSeconds(30); |
|||
options.StoreName = "redis-lock"; // 使用Redis作为锁存储 |
|||
options.DefaultIdentifier = "my-service"; // 自定义锁拥有者标识 |
|||
options.DefaultTimeout = TimeSpan.FromMinutes(1); // 设置默认超时时间为1分钟 |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 配置说明 |
|||
### 2. 基本用法 |
|||
|
|||
```csharp |
|||
public class OrderService |
|||
{ |
|||
private readonly IDistributedLockProvider _lockProvider; |
|||
|
|||
public OrderService(IDistributedLockProvider lockProvider) |
|||
{ |
|||
_lockProvider = lockProvider; |
|||
} |
|||
|
|||
public async Task ProcessOrderAsync(string orderId) |
|||
{ |
|||
// 尝试获取锁 |
|||
using (var handle = await _lockProvider.TryAcquireAsync($"order:{orderId}")) |
|||
{ |
|||
if (handle != null) |
|||
{ |
|||
try |
|||
{ |
|||
// 执行需要加锁的业务逻辑 |
|||
await ProcessOrderInternalAsync(orderId); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
// 处理异常 |
|||
_logger.LogError(ex, "处理订单时发生错误"); |
|||
throw; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
throw new ConcurrencyException("订单正在被其他进程处理"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### 3. 高级用法 |
|||
|
|||
```csharp |
|||
public class InventoryService |
|||
{ |
|||
private readonly IDistributedLockProvider _lockProvider; |
|||
private readonly ILogger<InventoryService> _logger; |
|||
|
|||
public InventoryService( |
|||
IDistributedLockProvider lockProvider, |
|||
ILogger<InventoryService> logger) |
|||
{ |
|||
_lockProvider = lockProvider; |
|||
_logger = logger; |
|||
} |
|||
|
|||
public async Task UpdateInventoryAsync(string productId, int quantity) |
|||
{ |
|||
// 自定义锁配置 |
|||
var lockOptions = new DistributedLockOptions |
|||
{ |
|||
Timeout = TimeSpan.FromSeconds(10), // 自定义超时时间 |
|||
RetryDelay = TimeSpan.FromMilliseconds(100) // 重试延迟 |
|||
}; |
|||
|
|||
try |
|||
{ |
|||
using (var handle = await _lockProvider.TryAcquireAsync( |
|||
$"inventory:{productId}", |
|||
lockOptions)) |
|||
{ |
|||
if (handle == null) |
|||
{ |
|||
_logger.LogWarning("无法获取库存锁,产品ID: {ProductId}", productId); |
|||
throw new ConcurrencyException("无法获取库存锁"); |
|||
} |
|||
|
|||
// 执行库存更新操作 |
|||
await UpdateInventoryInternalAsync(productId, quantity); |
|||
} |
|||
} |
|||
catch (Exception ex) when (ex is not ConcurrencyException) |
|||
{ |
|||
_logger.LogError(ex, "更新库存时发生错误"); |
|||
throw; |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 组件配置 |
|||
|
|||
### Redis锁存储配置示例 |
|||
|
|||
```yaml |
|||
apiVersion: dapr.io/v1alpha1 |
|||
kind: Component |
|||
metadata: |
|||
name: redis-lock # 对应StoreName配置 |
|||
spec: |
|||
type: lock.redis |
|||
version: v1 |
|||
metadata: |
|||
- name: redisHost |
|||
value: localhost:6379 |
|||
- name: redisPassword |
|||
value: "" |
|||
- name: enableTLS |
|||
value: false |
|||
- name: maxRetries |
|||
value: 5 |
|||
- name: maxRetryBackoff |
|||
value: 5s |
|||
``` |
|||
|
|||
### Consul锁存储配置示例 |
|||
|
|||
```yaml |
|||
apiVersion: dapr.io/v1alpha1 |
|||
kind: Component |
|||
metadata: |
|||
name: consul-lock |
|||
spec: |
|||
type: lock.consul |
|||
version: v1 |
|||
metadata: |
|||
- name: host |
|||
value: localhost:8500 |
|||
- name: sessionTTL |
|||
value: 10 |
|||
- name: scheme |
|||
value: http |
|||
``` |
|||
|
|||
## 核心接口 |
|||
|
|||
### ILockOwnerFinder |
|||
|
|||
提供锁资源持有者标识的接口。 |
|||
|
|||
```csharp |
|||
public interface ILockOwnerFinder |
|||
{ |
|||
string GetOwner(); |
|||
} |
|||
``` |
|||
|
|||
默认实现 `LockOwnerFinder` 会: |
|||
1. 优先使用当前用户ID作为锁拥有者标识 |
|||
2. 如果用户未登录,则使用配置的 `DefaultIdentifier` |
|||
|
|||
### 自定义锁拥有者标识实现 |
|||
|
|||
```csharp |
|||
public class CustomLockOwnerFinder : ILockOwnerFinder |
|||
{ |
|||
private readonly ICurrentTenant _currentTenant; |
|||
|
|||
public CustomLockOwnerFinder(ICurrentTenant currentTenant) |
|||
{ |
|||
_currentTenant = currentTenant; |
|||
} |
|||
|
|||
public string GetOwner() |
|||
{ |
|||
// 使用租户ID和机器名称组合作为锁拥有者标识 |
|||
return $"{_currentTenant.Id ?? "host"}-{Environment.MachineName}"; |
|||
} |
|||
} |
|||
|
|||
// 注册自定义实现 |
|||
context.Services.AddTransient<ILockOwnerFinder, CustomLockOwnerFinder>(); |
|||
``` |
|||
|
|||
## 最佳实践 |
|||
|
|||
1. **合理设置超时时间** |
|||
- 根据业务操作的预期执行时间设置合适的超时时间 |
|||
- 避免设置过长的超时时间,以防止死锁 |
|||
|
|||
2. **正确的锁粒度** |
|||
- 锁的范围应该尽可能小,只锁定必要的资源 |
|||
- 避免长时间持有锁,及时释放 |
|||
|
|||
3. **异常处理** |
|||
- 始终在 using 块中使用锁 |
|||
- 妥善处理锁获取失败的情况 |
|||
- 记录关键的锁操作日志 |
|||
|
|||
* AbpDistributedLockingDaprOptions.StoreName 在dapr component文件中定义的metadata name,默认: lockstore; |
|||
* AbpDistributedLockingDaprOptions.DefaultIdentifier 默认锁资源拥有者标识,默认: dapr-lock-owner; |
|||
* AbpDistributedLockingDaprOptions.DefaultTimeout 默认锁定超时时间,默认: 30s. |
|||
4. **性能优化** |
|||
- 使用合适的存储组件 |
|||
- 配置适当的重试策略 |
|||
- 监控锁的使用情况 |
|||
|
|||
## 接口说明 |
|||
## 注意事项 |
|||
|
|||
[ILockOwnerFinder](./LINGYUN/Abp/DistributedLocking/Dapr/ILockOwnerFinder), 提供锁资源持有者标识 |
|||
默认实现 [LockOwnerFinder](./LINGYUN/Abp/DistributedLocking/Dapr/LockOwnerFinder), 获取用户标识,如果不存在,返回DefaultIdentifier |
|||
* 确保Dapr Sidecar已正确配置并运行 |
|||
* 分布式锁组件需要在Dapr配置中正确定义 |
|||
* 合理设置锁的超时时间,避免死锁 |
|||
* 正确处理锁获取失败的情况 |
|||
* 在高并发场景下注意性能影响 |
|||
* 建议配置锁组件的健康检查 |
|||
* 重要操作建议添加日志记录 |
|||
|
|||
## 其他 |
|||
[查看英文](README.EN.md) |
|||
|
|||
@ -0,0 +1,30 @@ |
|||
# LINGYUN.Abp.DataProtection.Abstractions |
|||
|
|||
Data protection abstraction module, providing interface definitions and basic types for data protection. |
|||
|
|||
## Features |
|||
|
|||
* `IDataProtected` - Data protection interface, marking entities that need data protection control |
|||
* `DataProtectedAttribute` - Data protection attribute, marking methods or classes that need data protection control |
|||
* `DisableDataProtectedAttribute` - Disable data protection attribute, marking methods or classes that don't need data protection control |
|||
|
|||
## Data Operation Types |
|||
|
|||
* `DataAccessOperation.Read` - Query operation |
|||
* `DataAccessOperation.Write` - Update operation |
|||
* `DataAccessOperation.Delete` - Delete operation |
|||
|
|||
## Data Filtering |
|||
|
|||
* `DataAccessFilterLogic` - Data filter logic |
|||
* `And` - Logical AND |
|||
* `Or` - Logical OR |
|||
* `DataAccessFilterRule` - Data filter rule |
|||
* `Field` - Field name |
|||
* `Value` - Field value |
|||
* `Operate` - Operator |
|||
* `IsLeft` - Is left parenthesis |
|||
|
|||
## Related Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,30 @@ |
|||
# LINGYUN.Abp.DataProtection.Abstractions |
|||
|
|||
数据权限抽象模块,提供数据权限相关的接口定义和基础类型。 |
|||
|
|||
## 功能 |
|||
|
|||
* `IDataProtected` - 数据权限接口,标记实体需要进行数据权限控制 |
|||
* `DataProtectedAttribute` - 数据权限特性,标记方法或类需要进行数据权限控制 |
|||
* `DisableDataProtectedAttribute` - 禁用数据权限特性,标记方法或类不进行数据权限控制 |
|||
|
|||
## 数据操作类型 |
|||
|
|||
* `DataAccessOperation.Read` - 查询操作 |
|||
* `DataAccessOperation.Write` - 更新操作 |
|||
* `DataAccessOperation.Delete` - 删除操作 |
|||
|
|||
## 数据过滤 |
|||
|
|||
* `DataAccessFilterLogic` - 数据过滤逻辑 |
|||
* `And` - 且 |
|||
* `Or` - 或 |
|||
* `DataAccessFilterRule` - 数据过滤规则 |
|||
* `Field` - 字段名 |
|||
* `Value` - 字段值 |
|||
* `Operate` - 操作符 |
|||
* `IsLeft` - 是否左括号 |
|||
|
|||
## 相关链接 |
|||
|
|||
* [English document](./README.EN.md) |
|||
@ -0,0 +1,105 @@ |
|||
# LINGYUN.Abp.DataProtection.EntityFrameworkCore |
|||
|
|||
Data protection EntityFramework Core implementation module |
|||
|
|||
## Interface Description |
|||
|
|||
* DisableDataProtectedAttribute: Automatically implements DataFilter.Disable<IDataProtected>() through interceptor, data filter will be disabled in the current scope |
|||
|
|||
## Important Notes |
|||
|
|||
* When using repository interfaces, try to avoid using *await GetDbSetAsync()* directly, use *await GetQueryableAsync()* instead, because due to the **DbSet** design pattern, it cannot be processed at the moment |
|||
* Your repository interface should inherit from **EfCoreDataProtectionRepository**, and your *DbContext* should inherit from **AbpDataProtectionDbContext** |
|||
|
|||
## Configuration and Usage |
|||
|
|||
```csharp |
|||
[DependsOn( |
|||
typeof(AbpDataProtectionEntityFrameworkCoreModule) |
|||
)] |
|||
public class YouProjectModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<DataProtectionManagementOptions>(options => |
|||
{ |
|||
// Persist protected entity list |
|||
options.AddEntities(typeof(YouResource), new Type[] |
|||
{ |
|||
typeof(YouProtectionObject), |
|||
}); |
|||
|
|||
// Format as follows |
|||
// options.AddEntities(typeof(IdentityResource), new Type[] |
|||
// { |
|||
// typeof(IdentityUser), |
|||
// typeof(IdentityRole), |
|||
// typeof(OrganizationUnit), |
|||
// }); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public class YouDbContext : AbpDataProtectionDbContext<YouDbContext> |
|||
{ |
|||
public DbSet<YouProtectionObject> ProtectionObjects { get; set; } |
|||
public YouDbContext( |
|||
DbContextOptions<YouDbContext> options) : base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
modelBuilder.Entity<YouProtectionObject>(b => |
|||
{ |
|||
// ... |
|||
}); |
|||
} |
|||
} |
|||
|
|||
public class EfCoreYouProtectionObjectRepository : |
|||
EfCoreDataProtectionRepository<YouDbContext, YouProtectionObject, int>, |
|||
IYouProtectionObjectRepository |
|||
{ |
|||
protected IDataFilter DataFilter { get; } |
|||
public EfCoreYouProtectionObjectRepository( |
|||
[NotNull] IDbContextProvider<YouDbContext> dbContextProvider, |
|||
[NotNull] IDataAuthorizationService dataAuthorizationService, |
|||
[NotNull] IEntityTypeFilterBuilder entityTypeFilterBuilder, |
|||
IDataFilter dataFilter) |
|||
: base(dbContextProvider, dataAuthorizationService, entityTypeFilterBuilder) |
|||
{ |
|||
DataFilter = dataFilter; |
|||
} |
|||
|
|||
// Get protected data list |
|||
public async virtual Task<List<YouProtectionObject>> GetProtectedListAsync() |
|||
{ |
|||
return await (await GetQueryableAsync()) |
|||
.ToListAsync(); |
|||
} |
|||
|
|||
// Mark with DisableDataProtected to get all data list, automatically handle DataFilter.Disable<IDataProtected>() through interceptor |
|||
[DisableDataProtected] |
|||
public async virtual Task<List<YouProtectionObject>> GetUnProtectedListAsync() |
|||
{ |
|||
return await (await GetQueryableAsync()) |
|||
.ToListAsync(); |
|||
} |
|||
|
|||
// Disable IDataProtected filter to get all data list (can be used anywhere) |
|||
public async virtual Task<List<YouProtectionObject>> GetUnProtectedByFilterListAsync() |
|||
{ |
|||
using (DataFilter.Disable<IDataProtected>()) |
|||
{ |
|||
return await (await GetQueryableAsync()) |
|||
.ToListAsync(); |
|||
} |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Related Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,103 @@ |
|||
# LINGYUN.Abp.DataProtection |
|||
|
|||
Data protection implementation module, providing core implementation of data protection. |
|||
|
|||
## Features |
|||
|
|||
* Data Protection Interceptor - Automatically intercepts methods marked with data protection attributes |
|||
* Data Authorization Service - Provides data protection validation functionality |
|||
* Data Protection Resource Store - Provides in-memory storage implementation for data protection resources |
|||
|
|||
## Configuration |
|||
|
|||
```csharp |
|||
public class AbpDataProtectionOptions |
|||
{ |
|||
/// <summary> |
|||
/// Whether to enable data protection |
|||
/// Default: true |
|||
/// </summary> |
|||
public bool IsEnabled { get; set; } |
|||
|
|||
/// <summary> |
|||
/// List of data access subject contributors |
|||
/// </summary> |
|||
public IList<IDataAccessSubjectContributor> SubjectContributors { get; } |
|||
|
|||
/// <summary> |
|||
/// Dictionary of data access keyword contributors |
|||
/// </summary> |
|||
public IDictionary<string, IDataAccessKeywordContributor> KeywordContributors { get; } |
|||
|
|||
/// <summary> |
|||
/// Dictionary of data access operation contributors |
|||
/// </summary> |
|||
public IDictionary<DataAccessFilterOperate, IDataAccessOperateContributor> OperateContributors { get; } |
|||
|
|||
/// <summary> |
|||
/// List of ignored audit properties |
|||
/// Default includes: Id, LastModifierId, LastModificationTime, CreatorId, CreationTime, |
|||
/// IsDeleted, DeleterId, DeletionTime, TenantId, EntityVersion, |
|||
/// ConcurrencyStamp, ExtraProperties |
|||
/// </summary> |
|||
public IList<string> IgnoreAuditedProperties { get; } |
|||
} |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
1. Configure Module |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDataProtectionModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpDataProtectionOptions>(options => |
|||
{ |
|||
// Configure data protection options |
|||
options.IsEnabled = true; |
|||
|
|||
// Add custom subject contributor |
|||
options.SubjectContributors.Add(new YourSubjectContributor()); |
|||
|
|||
// Add custom keyword contributor |
|||
options.KeywordContributors.Add("your-keyword", new YourKeywordContributor()); |
|||
|
|||
// Add custom operation contributor |
|||
options.OperateContributors.Add(DataAccessFilterOperate.Equal, new YourOperateContributor()); |
|||
|
|||
// Add ignored audit property |
|||
options.IgnoreAuditedProperties.Add("YourProperty"); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. Use Data Protection Attributes |
|||
|
|||
```csharp |
|||
// Class level data protection control |
|||
[DataProtected] |
|||
public class YourService |
|||
{ |
|||
// Method level data protection control |
|||
[DataProtected] |
|||
public virtual Task<YourEntity> GetAsync(Guid id) |
|||
{ |
|||
// ... |
|||
} |
|||
|
|||
// Disable data protection control |
|||
[DisableDataProtected] |
|||
public virtual Task<YourEntity> GetWithoutProtectionAsync(Guid id) |
|||
{ |
|||
// ... |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Related Links |
|||
|
|||
* [中文文档](./README.md) |
|||
@ -0,0 +1,103 @@ |
|||
# LINGYUN.Abp.DataProtection |
|||
|
|||
数据权限实现模块,提供数据权限的核心实现。 |
|||
|
|||
## 功能 |
|||
|
|||
* 数据权限拦截器 - 自动拦截标记了数据权限特性的方法 |
|||
* 数据权限验证服务 - 提供数据权限验证功能 |
|||
* 数据权限资源存储 - 提供数据权限资源的内存存储实现 |
|||
|
|||
## 配置项 |
|||
|
|||
```csharp |
|||
public class AbpDataProtectionOptions |
|||
{ |
|||
/// <summary> |
|||
/// 是否启用数据权限 |
|||
/// 默认: true |
|||
/// </summary> |
|||
public bool IsEnabled { get; set; } |
|||
|
|||
/// <summary> |
|||
/// 数据权限主体提供者列表 |
|||
/// </summary> |
|||
public IList<IDataAccessSubjectContributor> SubjectContributors { get; } |
|||
|
|||
/// <summary> |
|||
/// 数据权限关键字提供者字典 |
|||
/// </summary> |
|||
public IDictionary<string, IDataAccessKeywordContributor> KeywordContributors { get; } |
|||
|
|||
/// <summary> |
|||
/// 数据权限操作提供者字典 |
|||
/// </summary> |
|||
public IDictionary<DataAccessFilterOperate, IDataAccessOperateContributor> OperateContributors { get; } |
|||
|
|||
/// <summary> |
|||
/// 忽略审计属性列表 |
|||
/// 默认包含:Id, LastModifierId, LastModificationTime, CreatorId, CreationTime, |
|||
/// IsDeleted, DeleterId, DeletionTime, TenantId, EntityVersion, |
|||
/// ConcurrencyStamp, ExtraProperties |
|||
/// </summary> |
|||
public IList<string> IgnoreAuditedProperties { get; } |
|||
} |
|||
``` |
|||
|
|||
## 使用方式 |
|||
|
|||
1. 配置模块 |
|||
|
|||
```csharp |
|||
[DependsOn(typeof(AbpDataProtectionModule))] |
|||
public class YourModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpDataProtectionOptions>(options => |
|||
{ |
|||
// 配置数据权限选项 |
|||
options.IsEnabled = true; |
|||
|
|||
// 添加自定义主体提供者 |
|||
options.SubjectContributors.Add(new YourSubjectContributor()); |
|||
|
|||
// 添加自定义关键字提供者 |
|||
options.KeywordContributors.Add("your-keyword", new YourKeywordContributor()); |
|||
|
|||
// 添加自定义操作提供者 |
|||
options.OperateContributors.Add(DataAccessFilterOperate.Equal, new YourOperateContributor()); |
|||
|
|||
// 添加忽略的审计属性 |
|||
options.IgnoreAuditedProperties.Add("YourProperty"); |
|||
}); |
|||
} |
|||
} |
|||
``` |
|||
|
|||
2. 使用数据权限特性 |
|||
|
|||
```csharp |
|||
// 类级别的数据权限控制 |
|||
[DataProtected] |
|||
public class YourService |
|||
{ |
|||
// 方法级别的数据权限控制 |
|||
[DataProtected] |
|||
public virtual Task<YourEntity> GetAsync(Guid id) |
|||
{ |
|||
// ... |
|||
} |
|||
|
|||
// 禁用数据权限控制 |
|||
[DisableDataProtected] |
|||
public virtual Task<YourEntity> GetWithoutProtectionAsync(Guid id) |
|||
{ |
|||
// ... |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 相关链接 |
|||
|
|||
* [English document](./README.EN.md) |
|||
@ -0,0 +1,52 @@ |
|||
# LINGYUN.Abp.Dynamic.Queryable.Application.Contracts |
|||
|
|||
Dynamic query application service contract module, defining interfaces and DTOs related to dynamic querying. |
|||
|
|||
## Features |
|||
|
|||
* Defines dynamic query application service interface `IDynamicQueryableAppService<TEntityDto>` |
|||
* Provides DTO definitions for dynamic querying |
|||
* Supports parameter options and comparison operator definitions |
|||
|
|||
## Configuration and Usage |
|||
|
|||
1. Install the `LINGYUN.Abp.Dynamic.Queryable.Application.Contracts` NuGet package |
|||
|
|||
2. Add `[DependsOn(typeof(AbpDynamicQueryableApplicationContractsModule))]` to your module class |
|||
|
|||
### Interface Description |
|||
|
|||
```csharp |
|||
public interface IDynamicQueryableAppService<TEntityDto> |
|||
{ |
|||
// Get available fields list |
|||
Task<ListResultDto<DynamicParamterDto>> GetAvailableFieldsAsync(); |
|||
|
|||
// Query data based on dynamic conditions |
|||
Task<PagedResultDto<TEntityDto>> SearchAsync(GetListByDynamicQueryableInput dynamicInput); |
|||
} |
|||
``` |
|||
|
|||
### DTO Description |
|||
|
|||
* `DynamicParamterDto` - Dynamic parameter DTO |
|||
* `Name` - Field name |
|||
* `Type` - Field type |
|||
* `Description` - Field description |
|||
* `JavaScriptType` - JavaScript type |
|||
* `AvailableComparator` - Available comparison operators |
|||
* `Options` - Parameter options (for enum types) |
|||
|
|||
* `ParamterOptionDto` - Parameter option DTO |
|||
* `Key` - Option key |
|||
* `Value` - Option value |
|||
|
|||
* `GetListByDynamicQueryableInput` - Dynamic query input DTO |
|||
* `SkipCount` - Number of records to skip |
|||
* `MaxResultCount` - Maximum number of records to return |
|||
* `Queryable` - Query conditions |
|||
|
|||
## Related Links |
|||
|
|||
* [LINGYUN.Linq.Dynamic.Queryable](../LINGYUN.Linq.Dynamic.Queryable/README.EN.md) |
|||
* [LINGYUN.Abp.Dynamic.Queryable.Application](../LINGYUN.Abp.Dynamic.Queryable.Application/README.EN.md) |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue