From 8876940466607f793eebf039ece71404659b79dc Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Sat, 8 Oct 2022 18:23:47 +0800 Subject: [PATCH] add support dynamic query interface --- aspnet-core/LINGYUN.MicroService.Common.sln | 41 +++++- .../LINGYUN.MicroService.TaskManagement.sln | 30 +++++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++ ...mic.Queryable.Application.Contracts.csproj | 19 +++ ...amicQueryableApplicationContractsModule.cs | 10 ++ .../Queryable/Dto/DynamicParamterDto.cs | 8 ++ .../Dto/GetListByDynamicQueryableInput.cs | 11 ++ .../Queryable/IDynamicQueryableAppService.cs | 19 +++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++ ...N.Abp.Dynamic.Queryable.Application.csproj | 19 +++ .../AbpDynamicQueryableApplicationModule.cs | 11 ++ .../Queryable/AbpDynamicQueryableOptions.cs | 21 ++++ .../Queryable/DynamicQueryableAppService.cs | 74 +++++++++++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++ ...NGYUN.Abp.Dynamic.Queryable.HttpApi.csproj | 19 +++ .../AbpDynamicQueryableHttpApiModule.cs | 18 +++ .../DynamicQueryableControllerBase.cs | 31 +++++ .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++ .../LINGYUN.Linq.Dynamic.Queryable.csproj | 11 ++ .../Dynamic/Queryable/DynamicComparison.cs | 53 ++++++++ .../Linq/Dynamic/Queryable/DynamicLogic.cs | 13 ++ .../Linq/Dynamic/Queryable/DynamicParamter.cs | 13 ++ .../Dynamic/Queryable/DynamicQueryable.cs | 8 ++ .../LINGYUN.Linq.Dynamic.Queryable/README.md | 12 ++ .../Expressions/ObjectQueryableExtensions.cs | 119 ++++++++++++++++++ .../modules/dynamic-queryable/README.md | 20 +++ ...askManagement.Application.Contracts.csproj | 1 + .../IBackgroundJobInfoAppService.cs | 6 +- ...askManagementApplicationContractsModule.cs | 4 +- ...GYUN.Abp.TaskManagement.Application.csproj | 1 + .../BackgroundJobInfoAppService.cs | 30 ++++- .../TaskManagementApplicationModule.cs | 4 +- .../LINGYUN.Abp.TaskManagement.HttpApi.csproj | 1 + .../BackgroundJobInfoController.cs | 9 +- .../TaskManagementHttpApiModule.cs | 2 + ...Service.TaskManagement.HttpApi.Host.csproj | 4 + 40 files changed, 762 insertions(+), 12 deletions(-) create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xml create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xsd create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts.csproj create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationContractsModule.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/DynamicParamterDto.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/GetListByDynamicQueryableInput.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xml create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xsd create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN.Abp.Dynamic.Queryable.Application.csproj create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationModule.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xml create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xsd create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableHttpApiModule.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xml create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xsd create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN.Linq.Dynamic.Queryable.csproj create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicComparison.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicLogic.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicParamter.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicQueryable.cs create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/README.md create mode 100644 aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/System/Linq/Expressions/ObjectQueryableExtensions.cs create mode 100644 aspnet-core/modules/dynamic-queryable/README.md diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln index 1992b26c3..b2d38253a 100644 --- a/aspnet-core/LINGYUN.MicroService.Common.sln +++ b/aspnet-core/LINGYUN.MicroService.Common.sln @@ -274,15 +274,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Http.Client.Wra EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tui-juhe", "tui-juhe", "{A1C75C3E-67D1-4BCE-89BF-44A735909BD5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TuiJuhe", "modules\tui-juhe\LINGYUN.Abp.TuiJuhe\LINGYUN.Abp.TuiJuhe.csproj", "{60143C9C-E539-498A-9DBE-B95E6A8301A5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TuiJuhe", "modules\tui-juhe\LINGYUN.Abp.TuiJuhe\LINGYUN.Abp.TuiJuhe.csproj", "{60143C9C-E539-498A-9DBE-B95E6A8301A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.TuiJuhe", "modules\tui-juhe\LINGYUN.Abp.Notifications.TuiJuhe\LINGYUN.Abp.Notifications.TuiJuhe.csproj", "{C55D9BA0-4AFD-4D18-958B-B53FD3F2FF4F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.TuiJuhe", "modules\tui-juhe\LINGYUN.Abp.Notifications.TuiJuhe\LINGYUN.Abp.Notifications.TuiJuhe.csproj", "{C55D9BA0-4AFD-4D18-958B-B53FD3F2FF4F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.TuiJuhe.Tests", "tests\LINGYUN.Abp.Notifications.TuiJuhe.Tests\LINGYUN.Abp.Notifications.TuiJuhe.Tests.csproj", "{641DF0BA-0E79-441D-B328-FDA288A35CDE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.TuiJuhe.Tests", "tests\LINGYUN.Abp.Notifications.TuiJuhe.Tests\LINGYUN.Abp.Notifications.TuiJuhe.Tests.csproj", "{641DF0BA-0E79-441D-B328-FDA288A35CDE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TuiJuhe.Tests", "tests\LINGYUN.Abp.TuiJuhe.Tests\LINGYUN.Abp.TuiJuhe.Tests.csproj", "{2020EA8D-F276-498D-92D1-94D1E25F8E1A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TuiJuhe.Tests", "tests\LINGYUN.Abp.TuiJuhe.Tests\LINGYUN.Abp.TuiJuhe.Tests.csproj", "{2020EA8D-F276-498D-92D1-94D1E25F8E1A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.TuiJuhe.SettingManagement", "modules\tui-juhe\LINGYUN.Abp.TuiJuhe.SettingManagement\LINGYUN.Abp.TuiJuhe.SettingManagement.csproj", "{2A3DF8B2-4760-41C4-9337-44FEE29B17CD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TuiJuhe.SettingManagement", "modules\tui-juhe\LINGYUN.Abp.TuiJuhe.SettingManagement\LINGYUN.Abp.TuiJuhe.SettingManagement.csproj", "{2A3DF8B2-4760-41C4-9337-44FEE29B17CD}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dynamic-queryable", "dynamic-queryable", "{3975D028-3672-4D23-BF77-B7F4A445D44E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Linq.Dynamic.Queryable", "modules\dynamic-queryable\LINGYUN.Linq.Dynamic.Queryable\LINGYUN.Linq.Dynamic.Queryable.csproj", "{5512A359-80E8-440C-B652-7C96F614DD9E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dynamic.Queryable.Application.Contracts", "modules\dynamic-queryable\LINGYUN.Abp.Dynamic.Queryable.Application.Contracts\LINGYUN.Abp.Dynamic.Queryable.Application.Contracts.csproj", "{6A23EE81-0CA7-4CA7-859D-6ADB669DF0E1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dynamic.Queryable.Application", "modules\dynamic-queryable\LINGYUN.Abp.Dynamic.Queryable.Application\LINGYUN.Abp.Dynamic.Queryable.Application.csproj", "{EC7970DC-A656-46A7-9873-A730FE72B213}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Dynamic.Queryable.HttpApi", "modules\dynamic-queryable\LINGYUN.Abp.Dynamic.Queryable.HttpApi\LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj", "{F515E8FA-449F-4D54-98A7-0F7DF1AA3C94}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -734,6 +744,22 @@ Global {2A3DF8B2-4760-41C4-9337-44FEE29B17CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {2A3DF8B2-4760-41C4-9337-44FEE29B17CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {2A3DF8B2-4760-41C4-9337-44FEE29B17CD}.Release|Any CPU.Build.0 = Release|Any CPU + {5512A359-80E8-440C-B652-7C96F614DD9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5512A359-80E8-440C-B652-7C96F614DD9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5512A359-80E8-440C-B652-7C96F614DD9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5512A359-80E8-440C-B652-7C96F614DD9E}.Release|Any CPU.Build.0 = Release|Any CPU + {6A23EE81-0CA7-4CA7-859D-6ADB669DF0E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A23EE81-0CA7-4CA7-859D-6ADB669DF0E1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A23EE81-0CA7-4CA7-859D-6ADB669DF0E1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A23EE81-0CA7-4CA7-859D-6ADB669DF0E1}.Release|Any CPU.Build.0 = Release|Any CPU + {EC7970DC-A656-46A7-9873-A730FE72B213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EC7970DC-A656-46A7-9873-A730FE72B213}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EC7970DC-A656-46A7-9873-A730FE72B213}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EC7970DC-A656-46A7-9873-A730FE72B213}.Release|Any CPU.Build.0 = Release|Any CPU + {F515E8FA-449F-4D54-98A7-0F7DF1AA3C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F515E8FA-449F-4D54-98A7-0F7DF1AA3C94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F515E8FA-449F-4D54-98A7-0F7DF1AA3C94}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F515E8FA-449F-4D54-98A7-0F7DF1AA3C94}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -875,6 +901,11 @@ Global {641DF0BA-0E79-441D-B328-FDA288A35CDE} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} {2020EA8D-F276-498D-92D1-94D1E25F8E1A} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} {2A3DF8B2-4760-41C4-9337-44FEE29B17CD} = {A1C75C3E-67D1-4BCE-89BF-44A735909BD5} + {3975D028-3672-4D23-BF77-B7F4A445D44E} = {02EA4E78-5891-43BC-944F-3E52FEE032E4} + {5512A359-80E8-440C-B652-7C96F614DD9E} = {3975D028-3672-4D23-BF77-B7F4A445D44E} + {6A23EE81-0CA7-4CA7-859D-6ADB669DF0E1} = {3975D028-3672-4D23-BF77-B7F4A445D44E} + {EC7970DC-A656-46A7-9873-A730FE72B213} = {3975D028-3672-4D23-BF77-B7F4A445D44E} + {F515E8FA-449F-4D54-98A7-0F7DF1AA3C94} = {3975D028-3672-4D23-BF77-B7F4A445D44E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8} diff --git a/aspnet-core/LINGYUN.MicroService.TaskManagement.sln b/aspnet-core/LINGYUN.MicroService.TaskManagement.sln index 6938b9e96..bbf134dbd 100644 --- a/aspnet-core/LINGYUN.MicroService.TaskManagement.sln +++ b/aspnet-core/LINGYUN.MicroService.TaskManagement.sln @@ -70,6 +70,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dapr.Client", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.Core", "modules\common\LINGYUN.Abp.Notifications.Core\LINGYUN.Abp.Notifications.Core.csproj", "{DD51A1AE-830F-4909-A729-7EBC398B17AD}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "exten-plugin", "exten-plugin", "{B38D2141-AC0F-4F4A-9315-4292E3856C15}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Linq.Dynamic.Queryable", "modules\dynamic-queryable\LINGYUN.Linq.Dynamic.Queryable\LINGYUN.Linq.Dynamic.Queryable.csproj", "{3EE8383C-6F25-4BCD-8852-B23D1C864324}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dynamic.Queryable.Application.Contracts", "modules\dynamic-queryable\LINGYUN.Abp.Dynamic.Queryable.Application.Contracts\LINGYUN.Abp.Dynamic.Queryable.Application.Contracts.csproj", "{B54F200C-D648-477B-BE39-B40A1D956F13}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dynamic.Queryable.Application", "modules\dynamic-queryable\LINGYUN.Abp.Dynamic.Queryable.Application\LINGYUN.Abp.Dynamic.Queryable.Application.csproj", "{FEC5FD25-9B26-4245-88D8-7621B26C7C3A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dynamic.Queryable.HttpApi", "modules\dynamic-queryable\LINGYUN.Abp.Dynamic.Queryable.HttpApi\LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj", "{DF963ABB-E713-49E9-A03C-DEB431E369DF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -172,6 +182,22 @@ Global {DD51A1AE-830F-4909-A729-7EBC398B17AD}.Debug|Any CPU.Build.0 = Debug|Any CPU {DD51A1AE-830F-4909-A729-7EBC398B17AD}.Release|Any CPU.ActiveCfg = Release|Any CPU {DD51A1AE-830F-4909-A729-7EBC398B17AD}.Release|Any CPU.Build.0 = Release|Any CPU + {3EE8383C-6F25-4BCD-8852-B23D1C864324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EE8383C-6F25-4BCD-8852-B23D1C864324}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EE8383C-6F25-4BCD-8852-B23D1C864324}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EE8383C-6F25-4BCD-8852-B23D1C864324}.Release|Any CPU.Build.0 = Release|Any CPU + {B54F200C-D648-477B-BE39-B40A1D956F13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B54F200C-D648-477B-BE39-B40A1D956F13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B54F200C-D648-477B-BE39-B40A1D956F13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B54F200C-D648-477B-BE39-B40A1D956F13}.Release|Any CPU.Build.0 = Release|Any CPU + {FEC5FD25-9B26-4245-88D8-7621B26C7C3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FEC5FD25-9B26-4245-88D8-7621B26C7C3A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FEC5FD25-9B26-4245-88D8-7621B26C7C3A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FEC5FD25-9B26-4245-88D8-7621B26C7C3A}.Release|Any CPU.Build.0 = Release|Any CPU + {DF963ABB-E713-49E9-A03C-DEB431E369DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF963ABB-E713-49E9-A03C-DEB431E369DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF963ABB-E713-49E9-A03C-DEB431E369DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF963ABB-E713-49E9-A03C-DEB431E369DF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -201,6 +227,10 @@ Global {2FA23894-E598-4896-A336-3E7C682699D9} = {FA5E30C9-05E3-4E35-AEDD-7DC5534E3A01} {194DAB61-BC3C-4003-BFF0-C87763E7B8B0} = {FA5E30C9-05E3-4E35-AEDD-7DC5534E3A01} {DD51A1AE-830F-4909-A729-7EBC398B17AD} = {18918B94-BB48-48F3-874D-B91B0252440A} + {3EE8383C-6F25-4BCD-8852-B23D1C864324} = {B38D2141-AC0F-4F4A-9315-4292E3856C15} + {B54F200C-D648-477B-BE39-B40A1D956F13} = {B38D2141-AC0F-4F4A-9315-4292E3856C15} + {FEC5FD25-9B26-4245-88D8-7621B26C7C3A} = {B38D2141-AC0F-4F4A-9315-4292E3856C15} + {DF963ABB-E713-49E9-A03C-DEB431E369DF} = {B38D2141-AC0F-4F4A-9315-4292E3856C15} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {E1FD1F4C-D344-408B-97CF-B6F1F6D7D293} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xml b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xsd b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts.csproj b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts.csproj new file mode 100644 index 000000000..700649406 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts.csproj @@ -0,0 +1,19 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationContractsModule.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationContractsModule.cs new file mode 100644 index 000000000..48bce7f70 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationContractsModule.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Application; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +[DependsOn(typeof(AbpDddApplicationContractsModule))] +public class AbpDynamicQueryableApplicationContractsModule : AbpModule +{ + +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/DynamicParamterDto.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/DynamicParamterDto.cs new file mode 100644 index 000000000..93d637c3d --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/DynamicParamterDto.cs @@ -0,0 +1,8 @@ +namespace LINGYUN.Abp.Dynamic.Queryable; + +public class DynamicParamterDto +{ + public string Name { get; set; } + public string Description { get; set; } + public string Type { get; set; } +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/GetListByDynamicQueryableInput.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/GetListByDynamicQueryableInput.cs new file mode 100644 index 000000000..b6a662005 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/Dto/GetListByDynamicQueryableInput.cs @@ -0,0 +1,11 @@ +using LINGYUN.Linq.Dynamic.Queryable; +using System.ComponentModel.DataAnnotations; +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +public class GetListByDynamicQueryableInput : PagedAndSortedResultRequestDto +{ + [Required] + public DynamicQueryable Queryable { get; set; } +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs new file mode 100644 index 000000000..5e75f1617 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application.Contracts/LINGYUN/Abp/Dynamic/Queryable/IDynamicQueryableAppService.cs @@ -0,0 +1,19 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +public interface IDynamicQueryableAppService +{ + /// + /// 获取可用字段列表 + /// + /// + Task> GetAvailableFieldsAsync(); + /// + /// 根据动态条件查询数据 + /// + /// + /// + Task> GetListAsync(GetListByDynamicQueryableInput input); +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xml b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xsd b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN.Abp.Dynamic.Queryable.Application.csproj b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN.Abp.Dynamic.Queryable.Application.csproj new file mode 100644 index 000000000..989e3a141 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN.Abp.Dynamic.Queryable.Application.csproj @@ -0,0 +1,19 @@ + + + + + + + netstandard2.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationModule.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationModule.cs new file mode 100644 index 000000000..09850c636 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableApplicationModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Application; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +[DependsOn( + typeof(AbpDynamicQueryableApplicationContractsModule), + typeof(AbpDddApplicationModule))] +public class AbpDynamicQueryableApplicationModule : AbpModule +{ +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs new file mode 100644 index 000000000..9450db7d9 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableOptions.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using Volo.Abp.Auditing; +using Volo.Abp.MultiTenancy; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +public class AbpDynamicQueryableOptions +{ + public List IgnoreFields { get; } + + public AbpDynamicQueryableOptions() + { + IgnoreFields = new List + { + nameof(IMultiTenant.TenantId), + nameof(IDeletionAuditedObject.IsDeleted), + nameof(IDeletionAuditedObject.DeleterId), + nameof(IDeletionAuditedObject.DeletionTime), + }; + } +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs new file mode 100644 index 000000000..47101f6a4 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.Application/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableAppService.cs @@ -0,0 +1,74 @@ +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +public abstract class DynamicQueryableAppService : ApplicationService, IDynamicQueryableAppService +{ + /// + /// 获取可用字段列表 + /// + /// + public virtual Task> GetAvailableFieldsAsync() + { + var options = LazyServiceProvider.LazyGetRequiredService>().Value; + + var entityType = typeof(TEntity); + var dynamicParamters = new List(); + + var propertyInfos = entityType + .GetProperties() + .Where(p => !options.IgnoreFields.Contains(p.Name)); + + foreach (var propertyInfo in propertyInfos) + { + // 字段本地化描述规则 + // 在本地化文件中定义 DisplayName:PropertyName + var localizedProp = L[$"DisplayName:{propertyInfo.Name}"]; + dynamicParamters.Add( + new DynamicParamterDto + { + Name = propertyInfo.Name, + Type = propertyInfo.PropertyType.FullName, + Description = localizedProp.Value ?? propertyInfo.Name + }); + } + + return Task.FromResult(new ListResultDto(dynamicParamters)); + } + + /// + /// 根据动态条件查询数据 + /// + /// + /// + public async virtual Task> GetListAsync(GetListByDynamicQueryableInput input) + { + Expression> condition = (e) => true; + + condition = condition.DynamicQuery(input.Queryable); + + var totalCount = await GetCountAsync(condition); + var entities = await GetListAsync(condition, input); + + return new PagedResultDto(totalCount, + MapToEntitiesDto(entities)); + } + + protected abstract Task GetCountAsync(Expression> condition); + + protected abstract Task> GetListAsync( + Expression> condition, + PagedAndSortedResultRequestDto pageRequest); + + protected virtual List MapToEntitiesDto(List entities) + { + return ObjectMapper.Map, List>(entities); + } +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xml b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xsd b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj new file mode 100644 index 000000000..887eddbf2 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN.Abp.Dynamic.Queryable.HttpApi.csproj @@ -0,0 +1,19 @@ + + + + + + + net6.0 + + + + + + + + + + + + diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableHttpApiModule.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableHttpApiModule.cs new file mode 100644 index 000000000..531cfb32e --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/AbpDynamicQueryableHttpApiModule.cs @@ -0,0 +1,18 @@ +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +[DependsOn( + typeof(AbpDynamicQueryableApplicationContractsModule), + typeof(AbpAspNetCoreMvcModule))] +public class AbpDynamicQueryableHttpApiModule : AbpModule +{ + public override void PreConfigureServices(ServiceConfigurationContext context) + { + //PreConfigure(mvcBuilder => + //{ + // mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpDynamicQueryableHttpApiModule).Assembly); + //}); + } +} \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs new file mode 100644 index 000000000..17bfe2755 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Abp.Dynamic.Queryable.HttpApi/LINGYUN/Abp/Dynamic/Queryable/DynamicQueryableControllerBase.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.Dynamic.Queryable; + +public abstract class DynamicQueryableControllerBase : AbpControllerBase, IDynamicQueryableAppService +{ + protected IDynamicQueryableAppService DynamicQueryableAppService { get; } + + protected DynamicQueryableControllerBase( + IDynamicQueryableAppService dynamicQueryableAppService) + { + DynamicQueryableAppService = dynamicQueryableAppService; + } + + [HttpGet] + [Route("available-fields")] + public Task> GetAvailableFieldsAsync() + { + return DynamicQueryableAppService.GetAvailableFieldsAsync(); + } + + [HttpPost] + [Route("search")] + public Task> GetListAsync(GetListByDynamicQueryableInput input) + { + return DynamicQueryableAppService.GetListAsync(input); + } +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xml b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xsd b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN.Linq.Dynamic.Queryable.csproj b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN.Linq.Dynamic.Queryable.csproj new file mode 100644 index 000000000..7128b5214 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN.Linq.Dynamic.Queryable.csproj @@ -0,0 +1,11 @@ + + + + + + + netstandard2.0 + + + + diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicComparison.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicComparison.cs new file mode 100644 index 000000000..84f343b42 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicComparison.cs @@ -0,0 +1,53 @@ +namespace LINGYUN.Linq.Dynamic.Queryable; +public enum DynamicComparison +{ + /// + /// 等于 + /// + Equal = 0, + /// + /// 不等于 + /// + NotEqual = 1, + /// + /// 小于 + /// + LessThan = 2, + /// + /// 小于等于 + /// + LessThanOrEqual = 3, + /// + /// 大于 + /// + GreaterThan = 4, + /// + /// 大于等于 + /// + GreaterThanOrEqual = 5, + /// + /// 左包含 + /// + StartsWith = 6, + /// + /// 左不包含 + /// + NotStartsWith = 7, + /// + /// 右包含 + /// + EndsWith = 8, + /// + /// 右不包含 + /// + NotEndsWith = 9, + /// + /// 包含 + /// + Contains = 10, + /// + /// 不包含 + /// + NotContains = 11 +} + diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicLogic.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicLogic.cs new file mode 100644 index 000000000..d94c189f5 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicLogic.cs @@ -0,0 +1,13 @@ +namespace LINGYUN.Linq.Dynamic.Queryable; + +public enum DynamicLogic +{ + /// + /// 且 + /// + And = 0, + /// + /// 或 + /// + Or = 1 +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicParamter.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicParamter.cs new file mode 100644 index 000000000..39827d787 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicParamter.cs @@ -0,0 +1,13 @@ +namespace LINGYUN.Linq.Dynamic.Queryable; + +public class DynamicParamter +{ + public string Filed { get; set; } + + public DynamicLogic Logic { get; set; } = DynamicLogic.And; + + public DynamicComparison Comparison { get; set; } = DynamicComparison.Equal; + + public object Value { get; set; } + public string Type { get; set; } +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicQueryable.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicQueryable.cs new file mode 100644 index 000000000..8742739a8 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/LINGYUN/Linq/Dynamic/Queryable/DynamicQueryable.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace LINGYUN.Linq.Dynamic.Queryable; + +public class DynamicQueryable +{ + public List Paramters { get; set; } = new List(); +} diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/README.md b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/README.md new file mode 100644 index 000000000..5ef0300a2 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/README.md @@ -0,0 +1,12 @@ +# LINGYUN.Linq.Dynamic.Queryable + +动态查询基本库, 扩展Linq, 动态构建表达式树 + +## 配置使用 + +模块按需引用, 只提供针对Linq的扩展 + +```csharp + +``` + diff --git a/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/System/Linq/Expressions/ObjectQueryableExtensions.cs b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/System/Linq/Expressions/ObjectQueryableExtensions.cs new file mode 100644 index 000000000..72b1b5288 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/LINGYUN.Linq.Dynamic.Queryable/System/Linq/Expressions/ObjectQueryableExtensions.cs @@ -0,0 +1,119 @@ +using LINGYUN.Linq.Dynamic.Queryable; +using System.Collections.Generic; +using System.Reflection; + +namespace System.Linq.Expressions; + +public static class ObjectQueryableExtensions +{ + public static Expression DynamicQuery( + this Expression condition, + DynamicQueryable queryable) + { + var typeExpression = condition.Parameters.FirstOrDefault(); + + return BuildExpressions(condition, typeExpression, queryable.Paramters); + } + + private static Expression BuildExpressions( + Expression condition, + Expression typeExpression, + List paramters) + { + var expressions = new Stack(); + foreach (var paramter in paramters) + { + Expression exp = null; + Type propertyType = null; + var leftParamter = Expression.PropertyOrField(typeExpression, paramter.Filed); + if (!string.IsNullOrWhiteSpace(paramter.Type)) + { + propertyType = Type.GetType(paramter.Type, true); + } + else + { + propertyType = (leftParamter.Member as PropertyInfo)?.PropertyType ?? paramter.Value.GetType(); + } + var rightParamter = Expression.Convert(Expression.Constant(paramter.Value), propertyType); + switch (paramter.Comparison) + { + case DynamicComparison.Equal: + exp = Expression.Equal(leftParamter, rightParamter); + break; + case DynamicComparison.NotEqual: + exp = Expression.NotEqual(leftParamter, rightParamter); + break; + case DynamicComparison.LessThan: + exp = Expression.LessThan(leftParamter, rightParamter); + break; + case DynamicComparison.LessThanOrEqual: + exp = Expression.LessThanOrEqual(leftParamter, rightParamter); + break; + case DynamicComparison.GreaterThan: + exp = Expression.GreaterThan(leftParamter, rightParamter); + break; + case DynamicComparison.GreaterThanOrEqual: + exp = Expression.GreaterThanOrEqual(leftParamter, rightParamter); + break; + case DynamicComparison.StartsWith: + exp = Expression.Call( + leftParamter, + typeof(string).GetMethod(nameof(String.StartsWith), new[] { typeof(string) }), + rightParamter); + break; + case DynamicComparison.NotStartsWith: + exp = Expression.Not( + Expression.Call( + leftParamter, + typeof(string).GetMethod(nameof(String.StartsWith), new[] { typeof(string) }), + rightParamter)); + break; + case DynamicComparison.EndsWith: + exp = Expression.Call( + leftParamter, + typeof(string).GetMethod(nameof(String.EndsWith), new[] { typeof(string) }), + rightParamter); + break; + case DynamicComparison.NotEndsWith: + exp = Expression.Not( + Expression.Call( + leftParamter, + typeof(string).GetMethod(nameof(String.EndsWith), new[] { typeof(string) }), + rightParamter)); + break; + case DynamicComparison.Contains: + exp = Expression.Call( + leftParamter, + typeof(string).GetMethod(nameof(String.Contains), new[] { typeof(string) }), + rightParamter); + break; + case DynamicComparison.NotContains: + exp = Expression.Not( + Expression.Call( + leftParamter, + typeof(string).GetMethod(nameof(String.Contains), new[] { typeof(string) }), + rightParamter)); + break; + } + expressions.Push(exp); + + while (expressions.Count > 1) + { + var exp1 = expressions.Pop(); + var exp2 = expressions.Pop(); + + switch (paramter.Logic) + { + case DynamicLogic.And: + expressions.Push(Expression.AndAlso(exp1, exp2)); + break; + case DynamicLogic.Or: + expressions.Push(Expression.Or(exp1, exp2)); + break; + } + } + } + + return Expression.Lambda(expressions.Pop(), condition.Parameters.ToArray()); + } +} diff --git a/aspnet-core/modules/dynamic-queryable/README.md b/aspnet-core/modules/dynamic-queryable/README.md new file mode 100644 index 000000000..7eae71b61 --- /dev/null +++ b/aspnet-core/modules/dynamic-queryable/README.md @@ -0,0 +1,20 @@ +# Dynamic.Queryable + +动态查询支持库, 为以后台服务提供动态查询支持 + +* 应用程序接口定义层引用**LINGYUN.Abp.Dynamic.Queryable.Application.Contracts**模块, 实现**IDynamicQueryableAppService**接口可对外提供动态查询支持 + +* 应用程序接口实现层引用**LINGYUN.Abp.Dynamic.Queryable.Application**模块,继承自**DynamicQueryableAppService**接口,实现**GetCountAsync**与**GetListAsync**方法即可(为仓储层接口提供传递的**Expression>**结构) + +* 控制器层引用**LINGYUN.Abp.Dynamic.Queryable.HttpApi**模块,继承**DynamicQueryableControllerBase**接口,自动公开动态查询接口。 + +## 接口说明 + +* **GetAvailableFieldsAsync**([GET] /{controller}/available-fields): 对外提供可选的属性明细, 默认返回所有字段(不包含已定义的排除字段). + +* **GetListAsync**([POST] /{controller}/search): 根据用户传递的动态条件返回查询结果列表. + +## 配置使用 + +* AbpDynamicQueryableOptions.IgnoreFields: 定义不对用户公开的字段列表,默认排除租户标识、软删除过滤器接口字段. + diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN.Abp.TaskManagement.Application.Contracts.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN.Abp.TaskManagement.Application.Contracts.csproj index 19dfce08a..1dea21dfc 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN.Abp.TaskManagement.Application.Contracts.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN.Abp.TaskManagement.Application.Contracts.csproj @@ -14,6 +14,7 @@ + diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs index bf998224d..d78ec6857 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/IBackgroundJobInfoAppService.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using LINGYUN.Abp.Dynamic.Queryable; +using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; @@ -10,7 +11,8 @@ public interface IBackgroundJobInfoAppService : string, BackgroundJobInfoGetListInput, BackgroundJobInfoCreateDto, - BackgroundJobInfoUpdateDto> + BackgroundJobInfoUpdateDto>, + IDynamicQueryableAppService { Task TriggerAsync(string id); diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/TaskManagementApplicationContractsModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/TaskManagementApplicationContractsModule.cs index 4288d4fdf..742f3aca9 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/TaskManagementApplicationContractsModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application.Contracts/LINGYUN/Abp/TaskManagement/TaskManagementApplicationContractsModule.cs @@ -1,9 +1,11 @@ -using Volo.Abp.Application; +using LINGYUN.Abp.Dynamic.Queryable; +using Volo.Abp.Application; using Volo.Abp.Modularity; namespace LINGYUN.Abp.TaskManagement; [DependsOn(typeof(TaskManagementDomainSharedModule))] +[DependsOn(typeof(AbpDynamicQueryableApplicationContractsModule))] [DependsOn(typeof(AbpDddApplicationContractsModule))] public class TaskManagementApplicationContractsModule : AbpModule { diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN.Abp.TaskManagement.Application.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN.Abp.TaskManagement.Application.csproj index 9fc2c5b64..cb3b81460 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN.Abp.TaskManagement.Application.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN.Abp.TaskManagement.Application.csproj @@ -13,6 +13,7 @@ + diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs index 1911f943f..bc27d1714 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/BackgroundJobInfoAppService.cs @@ -1,9 +1,14 @@ using LINGYUN.Abp.BackgroundTasks; +using LINGYUN.Abp.Dynamic.Queryable; +using LINGYUN.Abp.TaskManagement.Localization; using LINGYUN.Abp.TaskManagement.Permissions; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Options; +using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Dynamic.Core; +using System.Linq.Expressions; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Dtos; @@ -12,7 +17,7 @@ using Volo.Abp.Data; namespace LINGYUN.Abp.TaskManagement; [Authorize(TaskManagementPermissions.BackgroundJobs.Default)] -public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBackgroundJobInfoAppService +public class BackgroundJobInfoAppService : DynamicQueryableAppService, IBackgroundJobInfoAppService { protected AbpBackgroundTasksOptions Options { get; } protected BackgroundJobManager BackgroundJobManager { get; } @@ -29,6 +34,9 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa JobDefinitionManager = jobDefinitionManager; BackgroundJobInfoRepository = backgroundJobInfoRepository; Options = options.Value; + + LocalizationResource = typeof(TaskManagementResource); + ObjectMapperContext = typeof(TaskManagementApplicationModule); } public virtual Task> GetDefinitionsAsync() @@ -351,4 +359,24 @@ public class BackgroundJobInfoAppService : TaskManagementApplicationService, IBa await AuthorizationService.CheckAsync(TaskManagementPermissions.BackgroundJobs.ManageSystemJobs); } } + + protected async override Task GetCountAsync( + Expression> condition) + { + var queryable = await BackgroundJobInfoRepository.GetQueryableAsync(); + + return await AsyncExecuter.CountAsync(queryable.Where(condition)); + } + + protected async override Task> GetListAsync( + Expression> condition, + PagedAndSortedResultRequestDto pageRequest) + { + var queryable = await BackgroundJobInfoRepository.GetQueryableAsync(); + + return await AsyncExecuter.ToListAsync( + queryable.Where(condition) + .PageBy(pageRequest.SkipCount, pageRequest.MaxResultCount) + .OrderBy(pageRequest.Sorting ?? $"{nameof(BackgroundJobInfo.CreationTime)} DESC")); + } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/TaskManagementApplicationModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/TaskManagementApplicationModule.cs index 3bc12d61c..e9beb4275 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/TaskManagementApplicationModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.Application/LINGYUN/Abp/TaskManagement/TaskManagementApplicationModule.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.DependencyInjection; +using LINGYUN.Abp.Dynamic.Queryable; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Application; using Volo.Abp.AutoMapper; using Volo.Abp.Modularity; @@ -6,6 +7,7 @@ using Volo.Abp.Modularity; namespace LINGYUN.Abp.TaskManagement; [DependsOn(typeof(TaskManagementApplicationContractsModule))] +[DependsOn(typeof(AbpDynamicQueryableApplicationModule))] [DependsOn(typeof(TaskManagementDomainModule))] [DependsOn(typeof(AbpDddApplicationModule))] public class TaskManagementApplicationModule : AbpModule diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj index 128b311a8..32c4a92bb 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN.Abp.TaskManagement.HttpApi.csproj @@ -13,6 +13,7 @@ + diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs index 162b6db46..86f722bfb 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/BackgroundJobInfoController.cs @@ -1,4 +1,6 @@ -using LINGYUN.Abp.TaskManagement.Permissions; +using LINGYUN.Abp.Dynamic.Queryable; +using LINGYUN.Abp.TaskManagement.Localization; +using LINGYUN.Abp.TaskManagement.Permissions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; @@ -11,14 +13,17 @@ namespace LINGYUN.Abp.TaskManagement; [Area(TaskManagementRemoteServiceConsts.ModuleName)] [Authorize(TaskManagementPermissions.BackgroundJobs.Default)] [Route($"api/{TaskManagementRemoteServiceConsts.ModuleName}/background-jobs")] -public class BackgroundJobInfoController : TaskManagementController, IBackgroundJobInfoAppService +public class BackgroundJobInfoController : DynamicQueryableControllerBase, IBackgroundJobInfoAppService { protected IBackgroundJobInfoAppService BackgroundJobInfoAppService { get; } public BackgroundJobInfoController( IBackgroundJobInfoAppService backgroundJobInfoAppService) + : base(backgroundJobInfoAppService) { BackgroundJobInfoAppService = backgroundJobInfoAppService; + + LocalizationResource = typeof(TaskManagementResource); } [HttpPost] diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/TaskManagementHttpApiModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/TaskManagementHttpApiModule.cs index 4e9e80094..7ac5bd6ed 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/TaskManagementHttpApiModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.HttpApi/LINGYUN/Abp/TaskManagement/TaskManagementHttpApiModule.cs @@ -1,4 +1,5 @@ using LINGYUN.Abp.BackgroundTasks.Localization; +using LINGYUN.Abp.Dynamic.Queryable; using LINGYUN.Abp.TaskManagement.Localization; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc; @@ -10,6 +11,7 @@ using Volo.Abp.Validation.Localization; namespace LINGYUN.Abp.TaskManagement; [DependsOn(typeof(TaskManagementApplicationContractsModule))] +[DependsOn(typeof(AbpDynamicQueryableHttpApiModule))] [DependsOn(typeof(AbpAspNetCoreMvcModule))] public class TaskManagementHttpApiModule : AbpModule { diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj index d9e3e4e19..5d64b47f8 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj @@ -77,4 +77,8 @@ + + + +