8 changed files with 477 additions and 1 deletions
@ -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) |
|||
@ -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) |
|||
@ -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) |
|||
@ -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) |
|||
@ -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) |
|||
@ -0,0 +1,58 @@ |
|||
# LINGYUN.Abp.Dynamic.Queryable.HttpApi |
|||
|
|||
动态查询HTTP API模块,提供基于ABP框架的动态查询HTTP API实现。 |
|||
|
|||
## 功能特性 |
|||
|
|||
* 提供动态查询控制器基类 `DynamicQueryableControllerBase<TEntity, TEntityDto>` |
|||
* 自动生成REST API端点 |
|||
* 支持动态查询参数的HTTP传输 |
|||
|
|||
## 配置使用 |
|||
|
|||
1. 安装 `LINGYUN.Abp.Dynamic.Queryable.HttpApi` NuGet包 |
|||
|
|||
2. 添加 `[DependsOn(typeof(AbpDynamicQueryableHttpApiModule))]` 到你的模块类 |
|||
|
|||
### 实现动态查询控制器 |
|||
|
|||
```csharp |
|||
[Route("api/my-entity")] |
|||
public class MyEntityController : DynamicQueryableControllerBase<MyEntity, MyEntityDto> |
|||
{ |
|||
public MyEntityController(IDynamicQueryableAppService<MyEntityDto> dynamicQueryableAppService) |
|||
: base(dynamicQueryableAppService) |
|||
{ |
|||
} |
|||
} |
|||
``` |
|||
|
|||
### API端点 |
|||
|
|||
* GET `/api/my-entity/available-fields` - 获取可用字段列表 |
|||
* POST `/api/my-entity/search` - 根据动态条件查询数据 |
|||
|
|||
### 查询示例 |
|||
|
|||
```json |
|||
POST /api/my-entity/search |
|||
{ |
|||
"maxResultCount": 10, |
|||
"skipCount": 0, |
|||
"queryable": { |
|||
"paramters": [ |
|||
{ |
|||
"field": "Name", |
|||
"comparison": "Equal", |
|||
"value": "test" |
|||
} |
|||
] |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## 相关链接 |
|||
|
|||
* [LINGYUN.Linq.Dynamic.Queryable](../LINGYUN.Linq.Dynamic.Queryable/README.md) |
|||
* [LINGYUN.Abp.Dynamic.Queryable.Application](../LINGYUN.Abp.Dynamic.Queryable.Application/README.md) |
|||
* [LINGYUN.Abp.Dynamic.Queryable.Application.Contracts](../LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/README.md) |
|||
@ -0,0 +1,58 @@ |
|||
# LINGYUN.Linq.Dynamic.Queryable |
|||
|
|||
A basic library for dynamic querying, extending Linq to dynamically build expression trees. |
|||
|
|||
## Features |
|||
|
|||
* Support for dynamic query condition building |
|||
* Support for various comparison operators: equal, not equal, greater than, less than, greater than or equal, less than or equal, contains, not contains, starts with, not starts with, ends with, not ends with, etc. |
|||
* Support for dynamic type conversion and null value handling |
|||
* Support for dynamic querying of enum types |
|||
|
|||
## Configuration and Usage |
|||
|
|||
The module can be referenced as needed, providing extensions only for Linq. |
|||
|
|||
### Basic Usage |
|||
|
|||
```csharp |
|||
// Create dynamic query parameter |
|||
var parameter = new DynamicParamter |
|||
{ |
|||
Field = "Name", |
|||
Comparison = DynamicComparison.Equal, |
|||
Value = "test" |
|||
}; |
|||
|
|||
// Create query condition |
|||
var queryable = new DynamicQueryable |
|||
{ |
|||
Paramters = new List<DynamicParamter> { parameter } |
|||
}; |
|||
|
|||
// Apply to Expression |
|||
Expression<Func<TEntity, bool>> condition = e => true; |
|||
condition = condition.DynamicQuery(queryable); |
|||
|
|||
// Query using the condition |
|||
var result = await repository.Where(condition).ToListAsync(); |
|||
``` |
|||
|
|||
### Supported Comparison Operators |
|||
|
|||
* `Equal` - Equals |
|||
* `NotEqual` - Not equals |
|||
* `LessThan` - Less than |
|||
* `LessThanOrEqual` - Less than or equal to |
|||
* `GreaterThan` - Greater than |
|||
* `GreaterThanOrEqual` - Greater than or equal to |
|||
* `Contains` - Contains |
|||
* `NotContains` - Does not contain |
|||
* `StartsWith` - Starts with |
|||
* `NotStartsWith` - Does not start with |
|||
* `EndsWith` - Ends with |
|||
* `NotEndsWith` - Does not end with |
|||
|
|||
## Related Links |
|||
|
|||
* [LINGYUN.Abp.Dynamic.Queryable.Application](../LINGYUN.Abp.Dynamic.Queryable.Application/README.EN.md) |
|||
Loading…
Reference in new issue