Browse Source

Merge branch 'docs/main' into aio/main

# Conflicts:
#	common.props
pull/1067/head^2^2
feijie 1 year ago
parent
commit
4661a76415
  1. 61
      aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/README.EN.md
  2. 6
      aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/README.md
  3. 48
      aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/README.EN.md
  4. 59
      aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/README.EN.md
  5. 59
      aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/README.md
  6. 113
      aspnet-core/framework/auditing/README.md
  7. 64
      aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.QQ/README.EN.md
  8. 64
      aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.QQ/README.md
  9. 81
      aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.WeChat/README.EN.md
  10. 81
      aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.WeChat/README.md
  11. 99
      aspnet-core/framework/authentication/README.md
  12. 73
      aspnet-core/framework/authorization/LINGYUN.Abp.Authorization.OrganizationUnits/README.EN.md
  13. 73
      aspnet-core/framework/authorization/LINGYUN.Abp.Authorization.OrganizationUnits/README.md
  14. 18
      aspnet-core/framework/cli/LINGYUN.Abp.Cli/README.md
  15. 50
      aspnet-core/framework/cli/LINGYUN.Abp.Cli/README.zh-Hans.md
  16. 37
      aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/README.EN.md
  17. 37
      aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/README.md
  18. 23
      aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/README.EN.md
  19. 23
      aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/README.md
  20. 144
      aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/README.EN.md
  21. 141
      aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/README.md
  22. 33
      aspnet-core/framework/cloud-aliyun/README.md
  23. 137
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/README.EN.md
  24. 137
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/README.md
  25. 128
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Sms.Tencent/README.EN.md
  26. 127
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Sms.Tencent/README.md
  27. 81
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.QQ/README.EN.md
  28. 81
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.QQ/README.md
  29. 156
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/README.EN.md
  30. 156
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/README.md
  31. 93
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.TTS/README.EN.md
  32. 93
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.TTS/README.md
  33. 87
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent/README.EN.md
  34. 87
      aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent/README.md
  35. 42
      aspnet-core/framework/cloud-tencent/README.md
  36. 94
      aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.EN.md
  37. 94
      aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.md
  38. 82
      aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.EN.md
  39. 82
      aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.md
  40. 85
      aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/README.EN.md
  41. 67
      aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/README.md
  42. 46
      aspnet-core/framework/common/LINGYUN.Abp.Core/README.EN.md
  43. 46
      aspnet-core/framework/common/LINGYUN.Abp.Core/README.md
  44. 68
      aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling.Emailing/README.EN.md
  45. 35
      aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling.Emailing/README.md
  46. 46
      aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling/README.EN.md
  47. 24
      aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling/README.md
  48. 49
      aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis.Client/README.EN.md
  49. 49
      aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis.Client/README.md
  50. 56
      aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis/README.EN.md
  51. 56
      aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis/README.md
  52. 83
      aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.EN.md
  53. 83
      aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.md
  54. 77
      aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.EN.md
  55. 77
      aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.md
  56. 75
      aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.EN.md
  57. 75
      aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.md
  58. 45
      aspnet-core/framework/common/LINGYUN.Abp.Http.Client.Wrapper/README.EN.md
  59. 45
      aspnet-core/framework/common/LINGYUN.Abp.Http.Client.Wrapper/README.md
  60. 106
      aspnet-core/framework/common/LINGYUN.Abp.IP2Region/README.EN.md
  61. 65
      aspnet-core/framework/common/LINGYUN.Abp.IP2Region/README.md
  62. 73
      aspnet-core/framework/common/LINGYUN.Abp.IdGenerator/README.EN.md
  63. 73
      aspnet-core/framework/common/LINGYUN.Abp.IdGenerator/README.md
  64. 98
      aspnet-core/framework/common/LINGYUN.Abp.Idempotent/README.EN.md
  65. 98
      aspnet-core/framework/common/LINGYUN.Abp.Idempotent/README.md
  66. 137
      aspnet-core/framework/common/LINGYUN.Abp.Location.Baidu/README.EN.md
  67. 137
      aspnet-core/framework/common/LINGYUN.Abp.Location.Baidu/README.md
  68. 144
      aspnet-core/framework/common/LINGYUN.Abp.Location.Tencent/README.EN.md
  69. 144
      aspnet-core/framework/common/LINGYUN.Abp.Location.Tencent/README.md
  70. 151
      aspnet-core/framework/common/LINGYUN.Abp.Location/README.EN.md
  71. 121
      aspnet-core/framework/common/LINGYUN.Abp.Location/README.md
  72. 95
      aspnet-core/framework/common/LINGYUN.Abp.RealTime/README.EN.md
  73. 95
      aspnet-core/framework/common/LINGYUN.Abp.RealTime/README.md
  74. 105
      aspnet-core/framework/common/LINGYUN.Abp.Wrapper/README.EN.md
  75. 84
      aspnet-core/framework/common/LINGYUN.Abp.Wrapper/README.md
  76. 59
      aspnet-core/framework/common/README.md
  77. 181
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/README.EN.md
  78. 181
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/README.md
  79. 123
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/README.EN.md
  80. 110
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/README.md
  81. 129
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors/README.EN.md
  82. 111
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors/README.md
  83. 189
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/README.EN.md
  84. 175
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/README.md
  85. 277
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client/README.EN.md
  86. 270
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client/README.md
  87. 204
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr/README.EN.md
  88. 184
      aspnet-core/framework/dapr/LINGYUN.Abp.Dapr/README.md
  89. 256
      aspnet-core/framework/dapr/LINGYUN.Abp.DistributedLocking.Dapr/README.EN.md
  90. 250
      aspnet-core/framework/dapr/LINGYUN.Abp.DistributedLocking.Dapr/README.md
  91. 30
      aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/README.EN.md
  92. 30
      aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/README.md
  93. 105
      aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/README.EN.md
  94. 103
      aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/README.EN.md
  95. 103
      aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/README.md
  96. 52
      aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/README.EN.md
  97. 52
      aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/README.md
  98. 76
      aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/README.EN.md
  99. 76
      aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/README.md
  100. 58
      aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/README.EN.md

61
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/README.EN.md

@ -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

6
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.Elasticsearch/README.md

@ -1,5 +1,7 @@
# LINGYUN.Abp.AuditLogging.Elasticsearch
简体中文 | [English](./README.EN.md)
审计模块 Elasticsearch 实现
ElasticsearchAuditLogManager 实现了 IAuditLogManager, 审计日志由ES管理
@ -33,6 +35,4 @@ public class YouProjectModule : AbpModule
"IndexPrefix": "auditlogging"
}
}
}
```
}

48
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/README.EN.md

@ -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

59
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/README.EN.md

@ -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));
});
```

59
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/README.md

@ -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));
});
```

113
aspnet-core/framework/auditing/README.md

@ -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 官方模块管理

64
aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.QQ/README.EN.md

@ -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)

64
aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.QQ/README.md

@ -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)

81
aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.WeChat/README.EN.md

@ -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)

81
aspnet-core/framework/authentication/LINGYUN.Abp.Authentication.WeChat/README.md

@ -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)

99
aspnet-core/framework/authentication/README.md

@ -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)
## 许可证
遵循项目的开源许可证

73
aspnet-core/framework/authorization/LINGYUN.Abp.Authorization.OrganizationUnits/README.EN.md

@ -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)

73
aspnet-core/framework/authorization/LINGYUN.Abp.Authorization.OrganizationUnits/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)

18
aspnet-core/framework/cli/LINGYUN.Abp.Cli/README.md

@ -27,8 +27,24 @@ To get a detailed help for a command:
labp help <command>
```
## Features
* Support for generating TypeScript client proxy code
- Axios HTTP client
- Vben Admin integration
- UniApp integration
* Support for generating Flutter client proxy code
- Dio HTTP client
- REST service integration
* Support for generating view code
- Vben Admin view templates
- Flutter GetX view templates
* Custom ABP startup templates
## Feedback
Have a question and need feedback?
- [Github issuses](https://github.com/colinin/abp-next-admin/issuses)
- [Github issues](https://github.com/colinin/abp-next-admin/issues)
[简体中文](./README.zh-Hans.md)

50
aspnet-core/framework/cli/LINGYUN.Abp.Cli/README.zh-Hans.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)

37
aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/README.EN.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)

37
aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.Features/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)

23
aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/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)

23
aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/README.md

@ -1,12 +1,20 @@
# LINGYUN.Abp.Aliyun.SettingManagement
阿里云配置管理模块,引用此模块可管理阿里云相关的配置,可通过网关聚合对外公布的API接口
阿里云配置管理模块,引用此模块可管理阿里云相关的配置,可通过网关聚合对外公布的API接口。
API接口: api/setting-management/aliyun
## 功能特性
## 配置使用
* 提供阿里云服务配置的查询接口
* 支持通过API接口获取阿里云配置信息
* 与ABP设置管理系统集成
模块按需引用,建议在配置管理承载服务引用此模块
## API接口
* **GET api/setting-management/aliyun** - 获取阿里云配置信息
## 模块引用
模块按需引用,建议在配置管理承载服务引用此模块。
```csharp
[DependsOn(typeof(AbpAliyunSettingManagementModule))]
@ -15,6 +23,11 @@ public class YouProjectModule : AbpModule
// other
}
```
## 注意
因后台管理模块负责管理所有配置,此模块仅提供查询接口
* 因后台管理模块负责管理所有配置,此模块仅提供查询接口
* 需要与LINGYUN.Abp.Aliyun模块配合使用
* 建议在配置管理承载服务中引用此模块
[点击查看英文文档](README.EN.md)

144
aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/README.EN.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)

141
aspnet-core/framework/cloud-aliyun/LINGYUN.Abp.Aliyun/README.md

@ -1,12 +1,19 @@
# LINGYUN.Abp.Aliyun
阿里云sdk集成
阿里云 SDK 集成模块。
参照:https://help.aliyun.com/document_detail/28763.html
参照:[阿里云 API 文档](https://help.aliyun.com/document_detail/28763.html)
## 配置使用
## 功能特性
模块按需引用
- 提供阿里云服务的基础 SDK 集成
- 支持阿里云 RAM(访问控制)认证
- 支持 STS Token 访问
- 支持阿里云短信服务(SMS)
- 支持阿里云对象存储(OSS)
- 提供分布式缓存支持,优化高并发场景
## 模块引用
```csharp
[DependsOn(typeof(AbpAliyunModule))]
@ -15,17 +22,123 @@ public class YouProjectModule : AbpModule
// other
}
```
## 配置项说明
* AliyunSettingNames.Authorization.RegionId 可选,区域,默认 default
* AliyunSettingNames.Authorization.AccessKeyId 必须,阿里云RAM账号的AccessKey ID
* AliyunSettingNames.Authorization.AccessKeySecret 必须,RAM账号的AccessKey Secret
* AliyunSettingNames.Authorization.UseSecurityTokenService 可选,建议,使用STS Token访问,按照阿里云文档,建议使用Sts Token访问API,默认false
* AliyunSettingNames.Authorization.RamRoleArn 可选,启用Sts Token之后必须配置,阿里云RAM角色ARN
* AliyunSettingNames.Authorization.RoleSessionName 可选,启用Sts Token之后的用户自定义令牌名称,用于访问审计
* AliyunSettingNames.Authorization.DurationSeconds 可选,用户令牌的过期时间,单位为秒,默认3000
* AliyunSettingNames.Authorization.Policy 可选,权限策略,为json字符串
### 认证配置
- **AliyunSettingNames.Authorization.RegionId**
- 说明:阿里云服务区域
- 类型:可选
- 默认值:default
- 示例:oss-cn-hangzhou
- **AliyunSettingNames.Authorization.AccessKeyId**
- 说明:阿里云 RAM 账号的 AccessKey ID
- 类型:必须
- 获取方式:访问阿里云控制台-访问控制
- **AliyunSettingNames.Authorization.AccessKeySecret**
- 说明:RAM 账号的 AccessKey Secret
- 类型:必须
- 获取方式:访问阿里云控制台-访问控制
### STS Token 配置
- **AliyunSettingNames.Authorization.UseSecurityTokenService**
- 说明:是否使用 STS Token 访问
- 类型:可选
- 默认值:false
- 建议:建议开启,提高安全性
- **AliyunSettingNames.Authorization.RamRoleArn**
- 说明:阿里云 RAM 角色 ARN
- 类型:启用 STS Token 时必须
- 格式:acs:ram::$accountID:role/$roleName
- **AliyunSettingNames.Authorization.RoleSessionName**
- 说明:用户自定义令牌名称
- 类型:可选
- 用途:用于访问审计
- **AliyunSettingNames.Authorization.DurationSeconds**
- 说明:用户令牌的过期时间
- 类型:可选
- 默认值:3000
- 单位:秒
- **AliyunSettingNames.Authorization.Policy**
- 说明:权限策略
- 类型:可选
- 格式:JSON 字符串
### 短信服务配置
```json
{
"Settings": {
"Abp.Aliyun.Sms": {
"Domain": "dysmsapi.aliyuncs.com", // API域名,默认为 dysmsapi.aliyuncs.com
"Version": "2017-05-25", // API版本,默认为 2017-05-25
"ActionName": "SendSms", // API方法名,默认为 SendSms
"DefaultSignName": "", // 默认短信签名
"DefaultTemplateCode": "", // 默认短信模板代码
"DefaultPhoneNumber": "", // 默认接收短信的手机号码
"VisableErrorToClient": "false" // 是否向客户端显示错误信息
}
}
}
```
## 可用区域
本模块支持以下阿里云区域:
- 中国区域
- 华北 1(青岛)- cn-qingdao
- 华北 2(北京)- cn-beijing
- 华北 3(张家口)- cn-zhangjiakou
- 华北 5(呼和浩特)- cn-huhehaote
- 华东 1(杭州)- cn-hangzhou
- 华东 2(上海)- cn-shanghai
- 华南 1(深圳)- cn-shenzhen
- 华南 2(河源)- cn-heyuan
- 华南 3(广州)- cn-guangzhou
- 西南 1(成都)- cn-chengdu
- 香港及海外区域
- 香港 - cn-hongkong
- 美国(硅谷)- us-west-1
- 美国(弗吉尼亚)- us-east-1
- 日本(东京)- ap-northeast-1
- 韩国(首尔)- ap-northeast-2
- 新加坡 - ap-southeast-1
- 澳大利亚(悉尼)- ap-southeast-2
- 马来西亚(吉隆坡)- ap-southeast-3
- 印度尼西亚(雅加达)- ap-southeast-5
- 菲律宾(马尼拉)- ap-southeast-6
- 泰国(曼谷)- ap-southeast-7
- 印度(孟买)- ap-south-1
- 德国(法兰克福)- eu-central-1
- 英国(伦敦)- eu-west-1
- 阿联酋(迪拜)- me-east-1
## 性能优化
- 在高并发场景下,建议开启分布式缓存以提高性能
- 使用 STS Token 时,Token 会自动缓存到过期前
- 建议合理设置 DurationSeconds,避免过于频繁的 Token 刷新
## 相关模块
## 其他
- [LINGYUN.Abp.Aliyun.SettingManagement](../LINGYUN.Abp.Aliyun.SettingManagement/README.md) - 提供配置管理功能
- [LINGYUN.Abp.Aliyun.Features](../LINGYUN.Abp.Aliyun.Features/README.md) - 提供功能管理功能
网络因素在高并发下可能会出现预期外的异常,考虑使用二级缓存
[点击查看英文文档](README.EN.md)

33
aspnet-core/framework/cloud-aliyun/README.md

@ -0,0 +1,33 @@
# LINGYUN.Abp.Aliyun 模块概述
## 简介
LINGYUN.Abp.Aliyun 模块集成了阿里云的 SDK,提供了对阿里云服务的全面支持,包括认证、短信服务和对象存储等功能。
## 包含的项目列表
- **LINGYUN.Abp.Aliyun**
- **LINGYUN.Abp.Aliyun.Features**
- **LINGYUN.Abp.Aliyun.SettingManagement**
## 每个项目的主要功能概述
### LINGYUN.Abp.Aliyun
- 提供阿里云服务的基础 SDK 集成。
- 支持阿里云 RAM 认证和 STS Token 访问。
- 支持短信服务和对象存储。
- 提供分布式缓存支持。
### LINGYUN.Abp.Aliyun.Features
- 提供阿里云服务的功能定义和管理。
- 支持启用/禁用阿里云服务功能。
- 与 ABP 功能管理系统集成。
### LINGYUN.Abp.Aliyun.SettingManagement
- 提供阿里云服务配置的查询接口。
- 通过 API 接口获取阿里云配置信息。
- 与 ABP 设置管理系统集成。
## 模块的整体用途和重要性
该模块为开发者提供了与阿里云服务的无缝集成,简化了云服务的使用和管理,提升了应用程序的灵活性和可扩展性。
## 如何使用或集成该模块
在项目中引用相应的模块,并根据需要配置阿里云的相关参数。确保与 ABP 框架的其他模块配合使用,以实现最佳效果。

137
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/README.EN.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)

137
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.BlobStoring.Tencent/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)

128
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Sms.Tencent/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)

127
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Sms.Tencent/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)

81
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.QQ/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)

81
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.QQ/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)

156
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/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)

156
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/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)

93
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.TTS/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)

93
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent.TTS/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)

87
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent/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)

87
aspnet-core/framework/cloud-tencent/LINGYUN.Abp.Tencent/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)

42
aspnet-core/framework/cloud-tencent/README.md

@ -0,0 +1,42 @@
# LINGYUN.Abp.Tencent 模块概述
## 简介
LINGYUN.Abp.Tencent 模块集成了腾讯云的各项服务,提供了对腾讯云服务的全面支持,包括对象存储、短信服务、QQ 互联和语音合成等功能。
## 包含的项目列表
- **LINGYUN.Abp.Tencent**
- **LINGYUN.Abp.BlobStoring.Tencent**
- **LINGYUN.Abp.Sms.Tencent**
- **LINGYUN.Abp.Tencent.QQ**
- **LINGYUN.Abp.Tencent.SettingManagement**
- **LINGYUN.Abp.Tencent.TTS**
## 每个项目的主要功能概述
### LINGYUN.Abp.Tencent
- 提供腾讯云 SDK 客户端工厂,支持动态创建腾讯云各项服务的客户端。
- 支持多租户配置和多语言本地化。
- 提供统一的腾讯云服务配置管理。
### LINGYUN.Abp.BlobStoring.Tencent
- 支持腾讯云对象存储服务,自动创建存储桶。
- 支持多区域配置和文件大小限制。
### LINGYUN.Abp.Sms.Tencent
- 支持腾讯云短信服务的发送功能,支持多手机号批量发送。
- 内置错误处理和日志记录。
### LINGYUN.Abp.Tencent.QQ
- 支持 QQ 互联快速登录,支持多租户配置。
### LINGYUN.Abp.Tencent.SettingManagement
- 提供腾讯云服务的配置管理界面,支持全局和租户级别的配置管理。
### LINGYUN.Abp.Tencent.TTS
- 支持腾讯云语音合成服务,提供 TTS 客户端工厂。
## 模块的整体用途和重要性
该模块为开发者提供了与腾讯云服务的无缝集成,简化了云服务的使用和管理,提升了应用程序的灵活性和可扩展性。
## 如何使用或集成该模块
在项目中引用相应的模块,并根据需要配置腾讯云的相关参数。确保与 ABP 框架的其他模块配合使用,以实现最佳效果。

94
aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/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/)

94
aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.md

@ -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/)

82
aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.EN.md

@ -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/)

82
aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.md

@ -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/)

85
aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/README.EN.md

@ -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)

67
aspnet-core/framework/common/LINGYUN.Abp.BlobStoring.Aliyun/README.md

@ -1,12 +1,19 @@
# LINGYUN.Abp.BlobStoring.Aliyun
abp框架对象存储提供者**IBlobProvider**的阿里云实现
ABP框架对象存储提供者**IBlobProvider**的阿里云OSS实现
## 配置使用
## 功能特性
模块按需引用
* 实现ABP的IBlobProvider接口,使用阿里云OSS服务
* 支持多租户Blob存储
* 自动创建Bucket
* 可配置的Bucket访问控制
* 支持STS Token访问
* 可自定义的Blob命名策略
事先定义**appsettings.json**文件
## 模块引用
首先定义**appsettings.json**文件:
```json
{
@ -18,13 +25,61 @@ abp框架对象存储提供者**IBlobProvider**的阿里云实现
}
}
}
```
然后在项目中引用模块:
```csharp
[DependsOn(typeof(AbpBlobStoringAliyunModule))]
public class YouProjectModule : AbpModule
{
// other
}
```
```
## 配置说明
### OSS配置
* **BucketName**
* 说明:OSS存储空间名称
* 类型:可选
* 默认值:容器名称
* **Endpoint**
* 说明:OSS服务的接入点
* 类型:必须
* 示例:http://oss-cn-shanghai.aliyuncs.com
* **CreateBucketIfNotExists**
* 说明:如果Bucket不存在是否自动创建
* 类型:可选
* 默认值:false
* **CreateBucketReferer**
* 说明:Bucket访问白名单
* 类型:可选
### Blob命名规则
* 容器(Bucket)名称规则:
* 长度必须在3-63字符之间
* 只能包含小写字母、数字和短横线
* 必须以字母或数字开头
* 不能以短横线开头或结尾
* Blob名称规则:
* 租户:`tenants/{tenantId}/{blobName}`
* 宿主:`host/{blobName}`
## 性能优化
* 使用分布式缓存存储STS Token
* 支持数据冗余配置
* 可配置的Bucket访问控制以提高安全性
## 相关模块
* [LINGYUN.Abp.Aliyun](../../cloud-aliyun/LINGYUN.Abp.Aliyun/README.md) - 提供阿里云基础集成
[Click to view English documentation](README.EN.md)

46
aspnet-core/framework/common/LINGYUN.Abp.Core/README.EN.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)

46
aspnet-core/framework/common/LINGYUN.Abp.Core/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)

68
aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling.Emailing/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).

35
aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling.Emailing/README.md

@ -2,13 +2,20 @@
基于abp框架底层的**IExceptionSubscriber**的邮件通知类型
## 功能特性
* 支持异常邮件通知
* 支持自定义邮件模板
* 支持多语言邮件内容
* 支持堆栈信息发送
* 支持异常类型与接收邮箱映射
## 配置使用
使用前需要配置**AbpExceptionHandlingOptions**定义需要发送通知的异常
然后配置**AbpEmailExceptionHandlingOptions**定义具体异常类型通知方式
```csharp
[DependsOn(
typeof(AbpEmailingExceptionHandlingModule)
)]
@ -34,4 +41,28 @@
});
}
}
```
```
## 配置项说明
* `SendStackTrace`: 是否在邮件中包含异常堆栈信息
* `DefaultTitle`: 默认邮件标题
* `DefaultContentHeader`: 默认邮件内容头部
* `DefaultContentFooter`: 默认邮件内容底部
* `DefaultReceiveEmail`: 默认异常接收邮箱
* `Handlers`: 异常类型与接收邮箱的映射字典
## 本地化资源
模块包含以下语言的本地化资源:
* en
* zh-Hans
## 相关链接
* [基础异常处理模块](../LINGYUN.Abp.ExceptionHandling/README.md)
* [异常实时通知模块](../../../modules/realtime-notifications/LINGYUN.Abp.ExceptionHandling.Notifications/README.md)
## 更多
有关更多信息和配置示例,请参阅[文档](https://github.com/colinin/abp-next-admin)。

46
aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling/README.EN.md

@ -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).

24
aspnet-core/framework/common/LINGYUN.Abp.ExceptionHandling/README.md

@ -2,12 +2,18 @@
基于abp框架底层的**IExceptionSubscriber**实现二次扩展,用于自定义异常通知方式
## 功能特性
* 提供统一的异常处理和通知机制
* 支持自定义异常处理程序
* 支持异常通知筛选
* 支持与其他通知模块集成(如邮件、实时通知等)
## 配置使用
使用前只需配置**AbpExceptionHandlingOptions**定义需要发送通知的异常即可。
```csharp
[DependsOn(
typeof(AbpExceptionHandlingModule)
)]
@ -23,4 +29,18 @@
});
}
}
```
```
## 配置项说明
* `Handlers`: 异常处理程序列表,用于定义需要处理的异常类型
* `HasNotifierError`: 检查异常是否需要发送通知
## 扩展模块
* [LINGYUN.Abp.ExceptionHandling.Emailing](../LINGYUN.Abp.ExceptionHandling.Emailing/README.md): 异常邮件通知模块
* [LINGYUN.Abp.ExceptionHandling.Notifications](../../../modules/realtime-notifications/LINGYUN.Abp.ExceptionHandling.Notifications/README.md): 异常实时通知模块
## 更多
有关更多信息和配置示例,请参阅[文档](https://github.com/colinin/abp-next-admin)。

49
aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis.Client/README.EN.md

@ -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)

49
aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis.Client/README.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)

56
aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis/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)

56
aspnet-core/framework/common/LINGYUN.Abp.Features.LimitValidation.Redis/README.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)

83
aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/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/)

83
aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.md

@ -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/)

77
aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.EN.md

@ -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/)

77
aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.md

@ -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/)

75
aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.EN.md

@ -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/)

75
aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.md

@ -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/)

45
aspnet-core/framework/common/LINGYUN.Abp.Http.Client.Wrapper/README.EN.md

@ -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)

45
aspnet-core/framework/common/LINGYUN.Abp.Http.Client.Wrapper/README.md

@ -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)

106
aspnet-core/framework/common/LINGYUN.Abp.IP2Region/README.EN.md

@ -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)

65
aspnet-core/framework/common/LINGYUN.Abp.IP2Region/README.md

@ -1,8 +1,56 @@
# IP2Region.Net
# LINGYUN.Abp.IP2Region
.NET client library for IP2Region
## 介绍
## Installation
`LINGYUN.Abp.IP2Region` 是一个基于IP2Region的ABP框架模块,提供IP地址查询功能。本模块集成了IP2Region.Net库,提供了便捷的IP地址查询服务。
## 功能
* 提供IP地址查询服务
* 支持多种缓存策略
* 内置IP数据库文件
* 支持ABP虚拟文件系统
## 安装
```bash
dotnet add package LINGYUN.Abp.IP2Region
```
## 使用
1. 添加 `[DependsOn(typeof(AbpIP2RegionModule))]` 到你的模块类上。
```csharp
[DependsOn(typeof(AbpIP2RegionModule))]
public class YourModule : AbpModule
{
// ...
}
```
2. 注入并使用IP查询服务:
```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 库说明
### Installation
Install the package with [NuGet](https://www.nuget.org/packages/IP2Region.Net)
@ -10,7 +58,7 @@ Install the package with [NuGet](https://www.nuget.org/packages/IP2Region.Net)
Install-Package IP2Region.Net
```
## Usage
### Usage
```csharp
using IP2Region.Net.Abstractions;
@ -18,6 +66,7 @@ using IP2Region.Net.XDB;
ISearcher searcher = new Searcher(CachePolicy , "your xdb file path");
```
### Cache Policy Description
| Cache Policy | Description | Thread Safe |
|-------------------------|------------------------------------------------------------------------------------------------------------|-------------|
@ -51,12 +100,14 @@ Apple M1, 1 CPU, 8 logical and 8 physical cores
| 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)
[Apache License 2.0](https://github.com/lionsoul2014/ip2region/blob/master/LICENSE.md)
## 链接
* [English document](./README.EN.md)

73
aspnet-core/framework/common/LINGYUN.Abp.IdGenerator/README.EN.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)

73
aspnet-core/framework/common/LINGYUN.Abp.IdGenerator/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)

98
aspnet-core/framework/common/LINGYUN.Abp.Idempotent/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)

98
aspnet-core/framework/common/LINGYUN.Abp.Idempotent/README.md

@ -1,6 +1,21 @@
# LINGYUN.Abp.Idempotent
接口幂等性检查模块
接口幂等性检查模块,用于防止接口重复提交和确保接口调用的幂等性。
## 功能
* 自动幂等性检查
* 支持自定义幂等键生成
* 灵活的超时配置
* 支持分布式锁
* 支持多语言错误消息
* 支持忽略特定接口或方法
## 安装
```bash
dotnet add package LINGYUN.Abp.Idempotent
```
## 配置使用
@ -8,23 +23,76 @@
[DependsOn(typeof(AbpIdempotentModule))]
public class YouProjectModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpIdempotentOptions>(options =>
{
// 全局启用幂等检查
options.IsEnabled = true;
// 默认每个接口提供5秒超时
options.DefaultTimeout = 5000;
// 幂等token名称, 通过HttpHeader传递
options.IdempotentTokenName = "X-With-Idempotent-Token";
// 幂等校验失败时Http响应代码
options.HttpStatusCode = 429;
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpIdempotentOptions>(options =>
{
// 全局启用幂等检查
options.IsEnabled = true;
// 默认每个接口提供5秒超时
options.DefaultTimeout = 5000;
// 幂等token名称, 通过HttpHeader传递
options.IdempotentTokenName = "X-With-Idempotent-Token";
// 幂等校验失败时Http响应代码
options.HttpStatusCode = 429;
});
}
}
}
```
## 配置项说明
## 其他
* `IsEnabled` - 是否启用幂等检查,默认:false
* `DefaultTimeout` - 默认幂等性检查超时时间(毫秒),默认:5000
* `IdempotentTokenName` - 幂等性Token的HTTP头名称,默认:X-With-Idempotent-Token
* `HttpStatusCode` - 幂等性检查失败时的HTTP状态码,默认:429 (Too Many Requests)
## 使用示例
### 1. 基本使用
```csharp
[Idempotent]
public class OrderAppService : ApplicationService
{
public async Task<OrderDto> CreateAsync(CreateOrderDto input)
{
// 方法会自动进行幂等性检查
return await _orderRepository.CreateAsync(input);
}
}
```
### 2. 自定义幂等键
```csharp
[Idempotent(
iodempotentKey: "custom-key",
timeout: 10000,
keyMap: new[] { "orderId", "userId" })]
public async Task<OrderDto> UpdateAsync(UpdateOrderDto input)
{
return await _orderRepository.UpdateAsync(input);
}
```
### 3. 忽略幂等性检查
```csharp
[IgnoreIdempotent]
public async Task<OrderDto> QueryAsync(string orderId)
{
return await _orderRepository.GetAsync(orderId);
}
```
## 注意事项
1. 默认对所有继承自 `ICreateAppService`、`IUpdateAppService` 和 `IDeleteAppService` 的服务启用幂等性检查
2. 可以通过 `[IgnoreIdempotent]` 特性来忽略特定方法的幂等性检查
3. 幂等性检查基于分布式锁实现,确保在分布式环境中的正确性
4. 建议在所有修改数据的接口上启用幂等性检查
## 链接
* [English document](./README.EN.md)

137
aspnet-core/framework/common/LINGYUN.Abp.Location.Baidu/README.EN.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/)

137
aspnet-core/framework/common/LINGYUN.Abp.Location.Baidu/README.md

@ -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/)

144
aspnet-core/framework/common/LINGYUN.Abp.Location.Tencent/README.EN.md

@ -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/)

144
aspnet-core/framework/common/LINGYUN.Abp.Location.Tencent/README.md

@ -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/)

151
aspnet-core/framework/common/LINGYUN.Abp.Location/README.EN.md

@ -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)

121
aspnet-core/framework/common/LINGYUN.Abp.Location/README.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)

95
aspnet-core/framework/common/LINGYUN.Abp.RealTime/README.EN.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)

95
aspnet-core/framework/common/LINGYUN.Abp.RealTime/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)

105
aspnet-core/framework/common/LINGYUN.Abp.Wrapper/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)

84
aspnet-core/framework/common/LINGYUN.Abp.Wrapper/README.md

@ -1,6 +1,20 @@
# LINGYUN.Abp.Wrapper
包装器模块
包装器模块,用于统一包装API返回结果和异常处理。
## 功能
* 统一的返回结果包装
* 灵活的异常处理机制
* 支持多种忽略策略
* 可配置的空结果处理
* 自定义异常处理器
## 安装
```bash
dotnet add package LINGYUN.Abp.Wrapper
```
## 配置使用
@ -8,16 +22,26 @@
[DependsOn(typeof(AbpWrapperModule))]
public class YouProjectModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpWrapperOptions>(options =>
{
// 启用包装器
options.IsEnabled = true;
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpWrapperOptions>(options =>
{
// 启用包装器
options.IsEnabled = true;
// 自定义未处理异常的错误代码
options.CodeWithUnhandled = "500";
// 忽略特定前缀的URL
options.IgnorePrefixUrls.Add("/api/health");
// 添加自定义异常处理器
options.AddHandler<CustomException>(new CustomExceptionHandler());
});
}
}
}
```
## 配置项说明
* AbpWrapperOptions.IsEnabled 是否包装返回结果,默认: false
@ -36,5 +60,47 @@ public class YouProjectModule : AbpModule
* AbpWrapperOptions.IgnoredInterfaces 指定哪些接口不需要处理(默认实现**IWrapDisabled**接口不进行处理)
## 其他
## 使用示例
### 1. 基本使用
```csharp
public class TestController : AbpController
{
public async Task<WrapResult<string>> GetAsync()
{
return new WrapResult<string>("0", "Hello World");
}
}
```
### 2. 忽略包装
```csharp
[IgnoreWrapResult]
public class HealthController : AbpController
{
public async Task<string> GetAsync()
{
return "OK";
}
}
```
### 3. 自定义异常处理
```csharp
public class CustomExceptionHandler : IExceptionWrapHandler
{
public void Wrap(ExceptionWrapContext context)
{
context.WithCode("CUSTOM_ERROR")
.WithMessage("发生自定义异常")
.WithDetails(context.Exception.Message);
}
}
```
## 链接
* [English document](./README.EN.md)

59
aspnet-core/framework/common/README.md

@ -0,0 +1,59 @@
# common 模块概述
## 模块简介
`common`模块是ABP框架的基础模块,提供了一系列通用功能和服务,旨在支持各种应用程序的开发和扩展。该模块包含多个子模块,每个子模块实现了特定的功能,帮助开发者快速构建高效的应用程序。
## 包含的项目列表
1. **LINGYUN.Abp.Aliyun.Authorization**
- 提供阿里云基础认证功能,支持AppKeyId和AccessKeySecret的配置。
2. **LINGYUN.Abp.AspNetCore.HttpOverrides**
- 实现HTTP传输标头的重写,支持获取反向代理中的真实客户地址。
3. **LINGYUN.Abp.AspNetCore.Mvc.Client**
- 提供可配置的用户配置缓存时间,支持多租户接口。
4. **LINGYUN.Abp.BackgroundJobs.Hangfire**
- 基于Hangfire实现的后台作业模块,支持即时、延迟和周期性任务。
5. **LINGYUN.Abp.ExceptionHandling**
- 提供统一的异常处理和通知机制,支持自定义异常处理程序。
6. **LINGYUN.Abp.Location**
- 提供地理编码、反向地理编码和IP地理位置解析功能。
7. **LINGYUN.Abp.IdGenerator**
- 实现分布式唯一ID生成器,支持雪花算法。
8. **LINGYUN.Abp.Wrapper**
- 统一包装API返回结果和异常处理。
## 每个项目的主要功能概述
- **阿里云认证模块**: 提供阿里云的认证功能,简化了对阿里云服务的访问。
- **HTTP重写模块**: 处理HTTP请求中的标头,确保获取真实的客户端地址。
- **MVC客户端模块**: 提供用户配置缓存,支持多租户架构。
- **后台作业模块**: 支持任务的调度和执行,确保后台任务的可靠性。
- **异常处理模块**: 处理应用中的异常,提供统一的通知机制。
- **位置服务模块**: 提供地理位置相关的功能,支持地址与坐标之间的转换。
- **ID生成模块**: 生成分布式唯一ID,确保在高并发环境下的唯一性。
- **包装器模块**: 统一处理API的返回结果和异常,提升API的可用性。
## 模块的整体用途和重要性
`common`模块为ABP框架提供了基础设施,支持开发者在构建应用时快速集成常用功能,减少重复工作,提高开发效率。通过这些模块,开发者能够更专注于业务逻辑的实现,而无需担心底层的实现细节。
## 如何使用或集成该模块的简要说明
在项目中使用`common`模块时,只需在模块类中添加相应的依赖项,并在`ConfigureServices`方法中进行必要的配置。例如:
```csharp
[DependsOn(typeof(LINGYUN.Abp.Aliyun.Authorization))]
public class YourProjectModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
// 配置服务
}
}
```
## 提示
本项目中的README是由AI模型分析代码逻辑后自动生成的,如有误,请提issues或PR。

181
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/README.EN.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)

181
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore.Wrapper/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)

123
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/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)

110
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors.AspNetCore/README.md

@ -2,6 +2,15 @@
Dapr.Asp.NetCore的Abp框架集成,扫描程序集内部实现的Actor服务列表,批量注册为Dapr.Actors
## 功能特性
* 自动Actor服务注册
* 与ABP依赖注入系统集成
* 通过`RemoteServiceAttribute`支持自定义Actor类型名称
* 通过`ActorRuntimeOptions`配置Actor运行时
* 自动Actor端点映射
* Actor接口验证
## 配置使用
模块按需引用
@ -10,10 +19,105 @@ Dapr.Asp.NetCore的Abp框架集成,扫描程序集内部实现的Actor服务列
[DependsOn(typeof(AbpDaprActorsAspNetCoreModule))]
public class YouProjectModule : AbpModule
{
// other
public override void PreConfigureServices(ServiceConfigurationContext context)
{
// 配置Actor运行时选项
PreConfigure<ActorRuntimeOptions>(options =>
{
options.ActorIdleTimeout = TimeSpan.FromMinutes(60);
options.ActorScanInterval = TimeSpan.FromSeconds(30);
options.DrainOngoingCallTimeout = TimeSpan.FromSeconds(30);
options.DrainRebalancedActors = true;
options.RemindersStoragePartitions = 7;
});
}
}
```
## 实现示例
1. 定义Actor接口
```csharp
[RemoteService("counter")] // 可选:自定义Actor类型名称
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);
}
}
```
## 配置项说明
模块将自动:
1. 检测`CounterActor`实现
2. 将其注册到Dapr.Actors
3. 配置Actor运行时
4. 映射Actor端点
## Actor运行时配置
模块通过`ActorRuntimeOptions`支持所有标准的Dapr Actor运行时配置:
```csharp
PreConfigure<ActorRuntimeOptions>(options =>
{
// Actor超时设置
options.ActorIdleTimeout = TimeSpan.FromMinutes(60);
options.ActorScanInterval = TimeSpan.FromSeconds(30);
// 清理设置
options.DrainOngoingCallTimeout = TimeSpan.FromSeconds(30);
options.DrainRebalancedActors = true;
// 提醒器设置
options.RemindersStoragePartitions = 7;
// 自定义序列化设置
options.JsonSerializerOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
});
```
## 重要说明
* Actor实现必须在依赖注入容器中注册
* Actor接口必须继承自`IActor`
* Actor类型名称可以使用`RemoteServiceAttribute`自定义
* 模块使用ABP的端点路由系统自动映射Actor端点
* Actor运行时选项应在`PreConfigureServices`阶段配置
## 端点映射
模块自动映射以下Actor端点:
* `/dapr/actors/{actorType}/{actorId}/method/{methodName}`
* `/dapr/actors/{actorType}/{actorId}/state`
* `/dapr/actors/{actorType}/{actorId}/reminders/{reminderName}`
* `/dapr/actors/{actorType}/{actorId}/timers/{timerName}`
## 其他
[View English](README.EN.md)

129
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors/README.EN.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)

111
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Actors/README.md

@ -1,6 +1,16 @@
# LINGYUN.Abp.Dapr.Actors
Dapr.IActor客户端代理
Dapr.IActor客户端代理模块
## 功能特性
* Dapr Actors的动态代理生成
* 与ABP远程服务系统集成
* 支持Actor认证和授权
* 多租户支持
* 自动请求/响应处理
* 自定义错误处理
* 文化和语言标头支持
## 配置使用
@ -10,7 +20,7 @@ Dapr.IActor客户端代理
[DependsOn(typeof(AbpDaprActorsModule))]
public class YouProjectModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
public override void ConfigureServices(ServiceConfigurationContext context)
{
// 注册代理类似于 Volo.Abp.Http.Client 模块
context.Services.AddDaprActorProxies(
@ -20,7 +30,100 @@ public class YouProjectModule : AbpModule
}
}
```
## 配置项说明
## 配置选项
```json
{
"RemoteServices": {
"Default": {
"BaseUrl": "http://localhost:3500", // 必需,Dapr HTTP端点
"DaprApiToken": "your-api-token", // 可选,Dapr API Token
"RequestTimeout": "30000" // 可选,请求超时时间(毫秒,默认:30000)
}
}
}
```
## 实现示例
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);
}
}
```
3. 客户端使用
```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;
}
}
```
## 注意事项
* Actor方法必须返回`Task`或`Task<T>`
* Actor方法最多只能有一个参数
* Actor实例是单线程的,一次只能处理一个请求
* Actor状态由Dapr运行时管理
* 模块自动处理:
* 认证标头
* 租户上下文
* 文化信息
* 请求超时
* 错误处理
## 错误处理
模块为Actor调用提供自定义错误处理:
* `AbpDaprActorCallException`:当Actor方法调用失败时抛出
* `ActorMethodInvocationException`:包含有关失败的详细信息
* 错误响应包括:
* 错误消息
* 错误代码
* 原始异常类型
## 其他
[查看更多](README.EN.md)

189
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/README.EN.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)

175
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client.Wrapper/README.md

@ -2,6 +2,16 @@
Dapr服务间调用,对包装后的响应结果解包
## 功能特性
* 自动响应结果包装/解包
* 与ABP包装系统集成
* 自定义包装响应的错误处理
* 支持成功/错误代码配置
* HTTP状态码映射
* 支持自定义响应包装格式
* 灵活的包装控制选项
## 配置使用
模块按需引用
@ -13,4 +23,167 @@ public class AbpDaprClientWrapperModule : AbpModule
}
```
## 其他
## 配置选项
模块使用来自`LINGYUN.Abp.Wrapper`包的`AbpWrapperOptions`进行配置:
```json
{
"Wrapper": {
"IsEnabled": true, // 启用/禁用响应包装
"CodeWithSuccess": "0", // 包装响应中的成功代码
"HttpStatusCode": 200, // 包装响应的默认HTTP状态码
"WrapOnError": true, // 是否包装错误响应
"WrapOnSuccess": true // 是否包装成功响应
}
}
```
## 实现示例
1. 服务定义
```csharp
public interface IProductService
{
Task<ProductDto> GetAsync(string id);
Task<List<ProductDto>> GetListAsync();
Task<ProductDto> CreateAsync(CreateProductDto input);
}
```
2. 服务实现
```csharp
public class ProductService : IProductService
{
private readonly DaprClient _daprClient;
public ProductService(DaprClient daprClient)
{
_daprClient = daprClient;
}
public async Task<ProductDto> GetAsync(string id)
{
// 调用会自动处理响应包装
return await _daprClient.InvokeMethodAsync<ProductDto>(
"product-service", // 目标服务ID
$"api/products/{id}", // 方法路径
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
);
}
}
```
## 响应格式
当启用包装时,响应将采用以下格式:
```json
{
"code": "0", // 响应代码,默认"0"表示成功
"message": "Success", // 响应消息
"details": null, // 附加详情(可选)
"result": { // 实际响应数据
// ... 响应内容
}
}
```
## 错误处理
模块自动处理错误响应:
* 对于包装的响应(带有`AbpWrapResult`头):
* 解包响应并检查代码
* 如果代码与`CodeWithSuccess`不匹配,抛出`AbpRemoteCallException`
* 在异常中包含错误消息、详情和代码
* 支持自定义错误代码映射
* 对于未包装的响应:
* 传递原始响应
* 使用标准HTTP错误处理
* 保持原始错误信息
### 错误响应示例
```json
{
"code": "ERROR_001",
"message": "产品未找到",
"details": "ID为'123'的产品不存在",
"result": null
}
```
## 高级用法
### 1. 控制响应包装
可以通过HTTP头控制单个请求的响应包装:
```csharp
// 在请求头中添加
var headers = new Dictionary<string, string>
{
{ "X-Abp-Wrap-Result", "true" }, // 强制启用包装
// 或
{ "X-Abp-Dont-Wrap-Result", "true" } // 强制禁用包装
};
await _daprClient.InvokeMethodAsync<ProductDto>(
"product-service",
"api/products",
HttpMethod.Get,
null,
headers
);
```
### 2. 自定义错误处理
```csharp
public class CustomErrorHandler : IAbpWrapperErrorHandler
{
public Task HandleAsync(AbpWrapperErrorContext context)
{
// 自定义错误处理逻辑
if (context.Response.Code == "CUSTOM_ERROR")
{
// 特殊处理
}
return Task.CompletedTask;
}
}
```
## 注意事项
* 响应包装可以通过以下方式控制:
* 配置文件中的全局设置
* HTTP头控制单个请求
* 代码中的动态控制
* 错误响应尽可能保持原始错误结构
* 模块与ABP的远程服务错误处理系统集成
* 建议在微服务架构中统一使用响应包装
* 包装格式可以通过继承`IAbpWrapperResponseBuilder`自定义
[查看英文](README.EN.md)

277
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client/README.EN.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)

270
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr.Client/README.md

@ -2,72 +2,118 @@
# LINGYUN.Abp.Dapr.Client
实现了Dapr文档中的服务间调用,项目设计与Volo.Abp.Http.Client一致,通过配置文件即可无缝替代Volo.Abp.Http.Client
实现了Dapr文档中的服务间调用,项目设计与Volo.Abp.Http.Client一致,通过配置文件即可无缝替代Volo.Abp.Http.Client。
配置参考 [AbpRemoteServiceOptions](https://docs.abp.io/zh-Hans/abp/latest/API/Dynamic-CSharp-API-Clients#abpremoteserviceoptions)
配置参考 [AbpRemoteServiceOptions](https://docs.abp.io/zh-Hans/abp/latest/API/Dynamic-CSharp-API-Clients#abpremoteserviceoptions)
## 功能特性
* 与ABP远程服务系统集成
* 支持动态代理生成
* 支持服务发现和负载均衡
* 支持自定义请求和响应处理
* 支持错误处理和格式化
* 支持多服务端点配置
* 支持请求/响应拦截器
* 支持自定义DaprClient行为
## 配置选项
```json
{
"RemoteServices": {
"Default": {
"AppId": "default-app", // Dapr应用ID
"BaseUrl": "http://localhost:3500", // Dapr HTTP端点
"HealthCheckUrl": "/health", // 健康检查端点
"RequestTimeout": 30000, // 请求超时时间(毫秒)
"RetryCount": 3, // 重试次数
"RetryWaitTime": 1000 // 重试等待时间(毫秒)
},
"System": {
"AppId": "system-app",
"BaseUrl": "http://localhost:50000",
"Headers": { // 自定义请求头
"Tenant": "Default",
"Culture": "zh-Hans"
}
}
}
}
```
## 配置使用
模块按需引用
模块按需引用
```csharp
[DependsOn(typeof(AbpDaprClientModule))]
public class YouProjectModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
public override void ConfigureServices(ServiceConfigurationContext context)
{
// 注册代理类似于 Volo.Abp.Http.Client 模块
// 注册代理类似于 Volo.Abp.Http.Client 模块
context.Services.AddDaprClientProxies(
typeof(YouProjectInterfaceModule).Assembly, // 搜索 YouProjectInterfaceModule 模块下的远程服务定义
typeof(YouProjectInterfaceModule).Assembly, // 搜索模块下的远程服务定义
RemoteServiceName
);
// 配置代理选项
Configure<AbpDaprClientProxyOptions>(options =>
{
// 配置请求拦截器
options.ProxyRequestActions.Add((appId, request) =>
{
request.Headers.Add("Custom-Header", "Value");
});
// 配置响应处理
options.OnResponse(async (response, serviceProvider) =>
{
return await response.Content.ReadAsStringAsync();
});
// 配置错误处理
options.OnError(async (response, serviceProvider) =>
{
var error = await response.Content.ReadAsStringAsync();
return new RemoteServiceErrorInfo
{
Code = response.StatusCode.ToString(),
Message = error
};
});
});
}
}
```
## 实现示例
### 1、接口定义
```c#
### 1. 接口定义
```csharp
// IApplicationService 实现了 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、服务端
引用 Volo.Abp.AspNetCore.Mvc
* 实现接口
```c#
public class SystemAppService : ApplicationService, ISystemAppService
{
public Task<string> GetAsync()
{
retuen Task.FromResult("System");
}
}
```
* 创建模块
```c#
### 2. 服务端实现
```csharp
[DependsOn(
typeof(SystemInterfaceModule),
typeof(AbpAspNetCoreMvcModule))]
typeof(SystemInterfaceModule),
typeof(AbpAspNetCoreMvcModule)
)]
public class SystemServerModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
@ -79,93 +125,153 @@ public class SystemServerModule : AbpModule
}
}
```
* 发布到Dapr
```shell
# --app-port .net程序映射端口
# -H 对外暴露 http 监听端口
# -G 对外暴露 grpc 监听端口
dapr run --app-id myapp --app-port 5000 -H 50000 -G 40001 -- dotnet run
```
public class SystemAppService : ApplicationService, ISystemAppService
{
private readonly ISystemRepository _systemRepository;
### 3、客户端
public SystemAppService(ISystemRepository systemRepository)
{
_systemRepository = systemRepository;
}
引用 LINGYUN.Abp.Dapr.Client
public async Task<string> GetAsync()
{
return "System";
}
* 配置文件 **appsettings.json**
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);
}
```json
public async Task<List<SystemDto>> GetListAsync()
{
var systems = await _systemRepository.GetListAsync();
return ObjectMapper.Map<List<System>, List<SystemDto>>(systems);
}
{
"RemoteServices": {
"System": {
"AppId": "myapp",
"BaseUrl": "http://127.0.0.1:50000"
}
public async Task DeleteAsync(string id)
{
await _systemRepository.DeleteAsync(id);
}
}
```
* 客户端代码
```c#
### 3. 客户端使用
// 模块依赖
[DependsOn(
typeof(AbpDaprClientModule))]
public class SystemActorClientModule : AbpModule
```csharp
[DependsOn(typeof(AbpDaprClientModule))]
public class SystemClientModule : AbpModule
{
private const string RemoteServiceName = "System";
public override void ConfigureServices(ServiceConfigurationContext context)
{
// 注册代理类似于 Volo.Abp.Http.Client 模块
// 注册代理
context.Services.AddDaprClientProxies(
typeof(SystemInterfaceModule).Assembly, // 搜索 SystemInterfaceModule 模块下的IRemoteService定义创建代理
typeof(SystemInterfaceModule).Assembly,
RemoteServiceName
);
// 配置重试策略
context.Services.AddDaprClientBuilder(builder =>
{
builder.ConfigureHttpClient((sp, client) =>
{
client.Timeout = TimeSpan.FromSeconds(30);
});
});
}
}
// 调用方法,直接依赖注入即可
public class InvokeClass
public class SystemService
{
private readonly ISystemAppService _systemAppService;
public InvokeClass(ISystemAppService systemAppService)
public SystemService(ISystemAppService systemAppService)
{
_systemAppService = systemAppService;
_systemAppService = systemAppService;
}
public async Task InvokeAsync()
public async Task<List<SystemDto>> GetSystemsAsync()
{
await _systemAppService.GetAsync();
try
{
return await _systemAppService.GetListAsync();
}
catch (AbpRemoteCallException ex)
{
// 处理远程调用异常
_logger.LogError(ex, "Failed to get systems");
throw;
}
}
}
```
## 高级用法
## 配置项说明
* AbpRemoteServiceOptions.RemoteServices 配置Dapr.AppId
### 1. 自定义请求处理
```json
```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");
}
}
// 在模块中注册
Configure<AbpDaprClientProxyOptions>(options =>
{
"RemoteServices": {
"System": {
"AppId": "myapp",
"BaserUrl": "http://127.0.0.1:50000"
}
options.ProxyRequestActions.Add((appId, request) =>
{
new CustomRequestHandler().Configure(request);
});
});
```
### 2. 自定义响应处理
```csharp
public class CustomResponseHandler
{
public async Task<string> HandleAsync(HttpResponseMessage response)
{
var content = await response.Content.ReadAsStringAsync();
// 自定义响应处理逻辑
return content;
}
}
// 在模块中注册
Configure<AbpDaprClientProxyOptions>(options =>
{
options.OnResponse(async (response, sp) =>
{
return await new CustomResponseHandler().HandleAsync(response);
});
});
```
## 注意事项
* 远程服务接口必须继承`IRemoteService`
* 配置更改需要重新创建代理实例才能生效
* 建议配置适当的超时和重试策略
* 错误处理应该考虑网络异常和服务不可用的情况
* 在生产环境中应该启用服务发现
* 建议使用健康检查确保服务可用性
* 请求头配置应考虑安全性和身份验证需求
* 日志记录对于问题诊断很重要
## 其他
[查看英文](README.EN.md)

204
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr/README.EN.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)

184
aspnet-core/framework/dapr/LINGYUN.Abp.Dapr/README.md

@ -4,23 +4,201 @@ Dapr 集成基础模块, 实现dapr文档中的命名单例DaprClient
See: https://docs.dapr.io/developing-applications/sdks/dotnet/dotnet-client/dotnet-daprclient-usage
## 功能特性
* 支持创建默认和具名DaprClient实例
* 支持配置HTTP和gRPC端点
* 支持自定义JSON序列化选项
* 支持Dapr API Token认证
* 支持gRPC通道配置
* 支持DaprClient实例配置和构建配置的扩展
* 支持多个Dapr Sidecar连接
* 支持自定义DaprClient行为
## 配置选项
```json
{
"Dapr": {
"Client": {
"DaprApiToken": "your-api-token", // 可选,Dapr API Token
"HttpEndpoint": "http://localhost:3500", // 可选,HTTP端点
"GrpcEndpoint": "http://localhost:50001", // 可选,gRPC端点
"JsonSerializerOptions": { // 可选,JSON序列化选项
"PropertyNamingPolicy": "CamelCase",
"PropertyNameCaseInsensitive": true,
"WriteIndented": true,
"DefaultIgnoreCondition": "WhenWritingNull"
},
"GrpcChannelOptions": { // 可选,gRPC通道选项
"Credentials": "Insecure",
"MaxReceiveMessageSize": 1048576,
"MaxSendMessageSize": 1048576
}
}
}
}
```
## 配置使用
模块按需引用
模块按需引用
```csharp
[DependsOn(typeof(AbpDaprModule))]
public class YouProjectModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
public override void ConfigureServices(ServiceConfigurationContext context)
{
// 创建一个DaprClient
context.Services.AddDaprClient();
// 创建一个具名DaprClient
context.Services.AddDaprClient("__DaprClient");
// 配置DaprClient选项
Configure<DaprClientFactoryOptions>(options =>
{
options.HttpEndpoint = "http://localhost:3500";
options.GrpcEndpoint = "http://localhost:50001";
options.DaprApiToken = "your-api-token";
// 添加DaprClient配置动作
options.DaprClientActions.Add(client =>
{
// 配置DaprClient实例
});
// 添加DaprClientBuilder配置动作
options.DaprClientBuilderActions.Add(builder =>
{
// 配置DaprClientBuilder
});
});
}
}
```
## 高级用法
### 1. 配置DaprClient
```csharp
public override void ConfigureServices(ServiceConfigurationContext context)
{
// 配置具名DaprClient
context.Services.AddDaprClient("CustomClient", builder =>
{
// 配置HTTP端点
builder.UseHttpEndpoint("http://localhost:3500");
// 配置gRPC端点
builder.UseGrpcEndpoint("http://localhost:50001");
// 配置API Token
builder.UseDaprApiToken("your-api-token");
// 配置JSON序列化选项
builder.UseJsonSerializerOptions(new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
PropertyNameCaseInsensitive = true
});
// 配置gRPC通道选项
builder.UseGrpcChannelOptions(new GrpcChannelOptions
{
MaxReceiveMessageSize = 1024 * 1024,
MaxSendMessageSize = 1024 * 1024
});
});
}
```
### 2. 使用DaprClient
```csharp
public class YourService
{
private readonly IDaprClientFactory _daprClientFactory;
public YourService(IDaprClientFactory daprClientFactory)
{
_daprClientFactory = daprClientFactory;
}
public async Task InvokeMethodAsync()
{
// 使用默认客户端
var defaultClient = _daprClientFactory.CreateClient();
// 使用具名客户端
var namedClient = _daprClientFactory.CreateClient("CustomClient");
// 调用服务方法
var response = await defaultClient.InvokeMethodAsync<OrderDto>(
HttpMethod.Get,
"order-service", // 目标服务ID
"api/orders/1", // 方法路径
new { id = 1 } // 请求参数
);
// 发布事件
await defaultClient.PublishEventAsync(
"pubsub", // Pub/sub组件名称
"order-created", // 主题名称
response // 事件数据
);
// 保存状态
await defaultClient.SaveStateAsync(
"statestore", // 状态存储组件名称
"order-1", // 键
response // 值
);
// 获取状态
var state = await defaultClient.GetStateAsync<OrderDto>(
"statestore", // 状态存储组件名称
"order-1" // 键
);
}
}
```
## 其他
### 3. 自定义DaprClient行为
```csharp
public class CustomDaprClientBehavior
{
public void Configure(DaprClient client)
{
// 配置自定义行为
}
}
// 在模块中注册
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<DaprClientFactoryOptions>(options =>
{
options.DaprClientActions.Add(client =>
{
new CustomDaprClientBehavior().Configure(client);
});
});
}
```
## 注意事项
* DaprClient实例是线程安全的,建议使用单例模式
* 具名DaprClient可以有不同的配置,适用于需要连接不同Dapr Sidecar的场景
* 配置更改后需要重新创建DaprClient实例才能生效
* gRPC通道配置需要注意性能和资源消耗
* JSON序列化选项会影响所有使用该DaprClient的请求
* API Token应该通过安全的配置管理系统管理
* 建议为不同的微服务使用不同的具名DaprClient
* 在生产环境中应该适当配置超时和重试策略
[查看英文](README.EN.md)

256
aspnet-core/framework/dapr/LINGYUN.Abp.DistributedLocking.Dapr/README.EN.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)

250
aspnet-core/framework/dapr/LINGYUN.Abp.DistributedLocking.Dapr/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)

30
aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/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)

30
aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.Abstractions/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)

105
aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection.EntityFrameworkCore/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)

103
aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/README.EN.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)

103
aspnet-core/framework/data-protection/LINGYUN.Abp.DataProtection/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)

52
aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/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)

52
aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/README.md

@ -0,0 +1,52 @@
# LINGYUN.Abp.Dynamic.Queryable.Application.Contracts
动态查询应用服务契约模块,定义了动态查询相关的接口和DTO。
## 功能特性
* 定义动态查询应用服务接口 `IDynamicQueryableAppService<TEntityDto>`
* 提供动态查询相关的DTO定义
* 支持参数选项和比较运算符的定义
## 配置使用
1. 安装 `LINGYUN.Abp.Dynamic.Queryable.Application.Contracts` NuGet包
2. 添加 `[DependsOn(typeof(AbpDynamicQueryableApplicationContractsModule))]` 到你的模块类
### 接口说明
```csharp
public interface IDynamicQueryableAppService<TEntityDto>
{
// 获取可用字段列表
Task<ListResultDto<DynamicParamterDto>> GetAvailableFieldsAsync();
// 根据动态条件查询数据
Task<PagedResultDto<TEntityDto>> SearchAsync(GetListByDynamicQueryableInput dynamicInput);
}
```
### DTO说明
* `DynamicParamterDto` - 动态参数DTO
* `Name` - 字段名称
* `Type` - 字段类型
* `Description` - 字段描述
* `JavaScriptType` - JavaScript类型
* `AvailableComparator` - 可用的比较运算符
* `Options` - 参数选项(用于枚举类型)
* `ParamterOptionDto` - 参数选项DTO
* `Key` - 选项键
* `Value` - 选项值
* `GetListByDynamicQueryableInput` - 动态查询输入DTO
* `SkipCount` - 跳过记录数
* `MaxResultCount` - 最大返回记录数
* `Queryable` - 查询条件
## 相关链接
* [LINGYUN.Linq.Dynamic.Queryable](../LINGYUN.Linq.Dynamic.Queryable/README.md)
* [LINGYUN.Abp.Dynamic.Queryable.Application](../LINGYUN.Abp.Dynamic.Queryable.Application/README.md)

76
aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/README.EN.md

@ -0,0 +1,76 @@
# LINGYUN.Abp.Dynamic.Queryable.Application
Dynamic query application service module, providing dynamic query functionality implementation based on the ABP framework.
## Features
* Provides dynamic query application service base class `DynamicQueryableAppService<TEntity, TEntityDto>`
* Automatically generates available field list with localization support
* Supports field filtering and ignoring
* Supports enum type option list generation
## Configuration and Usage
1. Install the `LINGYUN.Abp.Dynamic.Queryable.Application` NuGet package
2. Add `[DependsOn(typeof(AbpDynamicQueryableApplicationModule))]` to your module class
3. Configure options (optional)
```csharp
Configure<AbpDynamicQueryableOptions>(options =>
{
// Add fields to ignore
options.IgnoreFields.Add("FieldName");
});
```
### Implementing Dynamic Query Service
```csharp
public class MyEntityAppService : DynamicQueryableAppService<MyEntity, MyEntityDto>
{
private readonly IRepository<MyEntity> _repository;
public MyEntityAppService(IRepository<MyEntity> repository)
{
_repository = repository;
}
protected override async Task<int> GetCountAsync(Expression<Func<MyEntity, bool>> condition)
{
return await _repository.CountAsync(condition);
}
protected override async Task<List<MyEntity>> GetListAsync(
Expression<Func<MyEntity, bool>> condition,
GetListByDynamicQueryableInput dynamicInput)
{
return await _repository
.Where(condition)
.PageBy(dynamicInput.SkipCount, dynamicInput.MaxResultCount)
.ToListAsync();
}
protected override List<TEntityDto> MapToEntitiesDto(List<MyEntity> entities)
{
return ObjectMapper.Map<List<MyEntity>, List<MyEntityDto>>(entities);
}
// Custom fields to ignore (optional)
protected override IEnumerable<string> GetUserDefineIgnoreFields()
{
return new[] { "CustomField" };
}
}
```
### Configuration Options
* `IgnoreFields` - List of fields to ignore in queries
* Defaults include: Id, TenantId, IsDeleted, DeleterId, DeletionTime and other audit fields
## Related Links
* [LINGYUN.Linq.Dynamic.Queryable](../LINGYUN.Linq.Dynamic.Queryable/README.EN.md)
* [LINGYUN.Abp.Dynamic.Queryable.Application.Contracts](../LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/README.EN.md)

76
aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/README.md

@ -0,0 +1,76 @@
# LINGYUN.Abp.Dynamic.Queryable.Application
动态查询应用服务模块,提供基于ABP框架的动态查询功能实现。
## 功能特性
* 提供动态查询应用服务基类 `DynamicQueryableAppService<TEntity, TEntityDto>`
* 自动生成可用字段列表,支持字段本地化
* 支持字段过滤和忽略
* 支持枚举类型的选项列表生成
## 配置使用
1. 安装 `LINGYUN.Abp.Dynamic.Queryable.Application` NuGet包
2. 添加 `[DependsOn(typeof(AbpDynamicQueryableApplicationModule))]` 到你的模块类
3. 配置选项(可选)
```csharp
Configure<AbpDynamicQueryableOptions>(options =>
{
// 添加需要忽略的字段
options.IgnoreFields.Add("FieldName");
});
```
### 实现动态查询服务
```csharp
public class MyEntityAppService : DynamicQueryableAppService<MyEntity, MyEntityDto>
{
private readonly IRepository<MyEntity> _repository;
public MyEntityAppService(IRepository<MyEntity> repository)
{
_repository = repository;
}
protected override async Task<int> GetCountAsync(Expression<Func<MyEntity, bool>> condition)
{
return await _repository.CountAsync(condition);
}
protected override async Task<List<MyEntity>> GetListAsync(
Expression<Func<MyEntity, bool>> condition,
GetListByDynamicQueryableInput dynamicInput)
{
return await _repository
.Where(condition)
.PageBy(dynamicInput.SkipCount, dynamicInput.MaxResultCount)
.ToListAsync();
}
protected override List<TEntityDto> MapToEntitiesDto(List<MyEntity> entities)
{
return ObjectMapper.Map<List<MyEntity>, List<MyEntityDto>>(entities);
}
// 自定义需要忽略的字段(可选)
protected override IEnumerable<string> GetUserDefineIgnoreFields()
{
return new[] { "CustomField" };
}
}
```
### 配置项说明
* `IgnoreFields` - 需要在查询中忽略的字段列表
* 默认包含:Id、TenantId、IsDeleted、DeleterId、DeletionTime等审计字段
## 相关链接
* [LINGYUN.Linq.Dynamic.Queryable](../LINGYUN.Linq.Dynamic.Queryable/README.md)
* [LINGYUN.Abp.Dynamic.Queryable.Application.Contracts](../LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/README.md)

58
aspnet-core/framework/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/README.EN.md

@ -0,0 +1,58 @@
# LINGYUN.Abp.Dynamic.Queryable.HttpApi
Dynamic query HTTP API module, providing HTTP API implementation for dynamic querying based on the ABP framework.
## Features
* Provides dynamic query controller base class `DynamicQueryableControllerBase<TEntity, TEntityDto>`
* Automatically generates REST API endpoints
* Supports HTTP transport of dynamic query parameters
## Configuration and Usage
1. Install the `LINGYUN.Abp.Dynamic.Queryable.HttpApi` NuGet package
2. Add `[DependsOn(typeof(AbpDynamicQueryableHttpApiModule))]` to your module class
### Implementing Dynamic Query Controller
```csharp
[Route("api/my-entity")]
public class MyEntityController : DynamicQueryableControllerBase<MyEntity, MyEntityDto>
{
public MyEntityController(IDynamicQueryableAppService<MyEntityDto> dynamicQueryableAppService)
: base(dynamicQueryableAppService)
{
}
}
```
### API Endpoints
* GET `/api/my-entity/available-fields` - Get available fields list
* POST `/api/my-entity/search` - Query data based on dynamic conditions
### Query Example
```json
POST /api/my-entity/search
{
"maxResultCount": 10,
"skipCount": 0,
"queryable": {
"paramters": [
{
"field": "Name",
"comparison": "Equal",
"value": "test"
}
]
}
}
```
## 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)
* [LINGYUN.Abp.Dynamic.Queryable.Application.Contracts](../LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/README.EN.md)

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save