diff --git a/aspnet-core/LINGYUN.MicroService.All.sln b/aspnet-core/LINGYUN.MicroService.All.sln index d3f477df8..21a4ff369 100644 --- a/aspnet-core/LINGYUN.MicroService.All.sln +++ b/aspnet-core/LINGYUN.MicroService.All.sln @@ -125,8 +125,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TestsBase", "te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.BlobStoring.Aliyun.Tests", "tests\LINGYUN.Abp.BlobStoring.Aliyun.Tests\LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj", "{C8A00439-5B8D-4923-8FAA-AB75E2A786ED}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Aliyun.Authorization", "modules\common\LINGYUN.Abp.Aliyun.Authorization\LINGYUN.Abp.Aliyun.Authorization.csproj", "{F3AE9617-983D-4940-B5EB-35E3580C0B0F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.MessageService.Application.Contracts", "modules\message\LINGYUN.Abp.MessageService.Application.Contracts\LINGYUN.Abp.MessageService.Application.Contracts.csproj", "{31B03DCB-ED12-4412-867A-61E347D40D8C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.MessageService.Application", "modules\message\LINGYUN.Abp.MessageService.Application\LINGYUN.Abp.MessageService.Application.csproj", "{AB984240-EF03-416F-A9B2-F5CF169E04B7}" @@ -465,10 +463,6 @@ Global {C8A00439-5B8D-4923-8FAA-AB75E2A786ED}.Debug|Any CPU.Build.0 = Debug|Any CPU {C8A00439-5B8D-4923-8FAA-AB75E2A786ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {C8A00439-5B8D-4923-8FAA-AB75E2A786ED}.Release|Any CPU.Build.0 = Release|Any CPU - {F3AE9617-983D-4940-B5EB-35E3580C0B0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F3AE9617-983D-4940-B5EB-35E3580C0B0F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F3AE9617-983D-4940-B5EB-35E3580C0B0F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F3AE9617-983D-4940-B5EB-35E3580C0B0F}.Release|Any CPU.Build.0 = Release|Any CPU {31B03DCB-ED12-4412-867A-61E347D40D8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {31B03DCB-ED12-4412-867A-61E347D40D8C}.Debug|Any CPU.Build.0 = Debug|Any CPU {31B03DCB-ED12-4412-867A-61E347D40D8C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -773,10 +767,9 @@ Global {F595CB9F-B117-4D62-A1AE-48599927DB36} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} {5CF403B2-47C9-4E4E-8856-0294BDD64884} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} {8A22674D-151D-474E-8C99-9D991C0D8297} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} - {059473BA-FAF9-405F-9985-33DDCA2E9F0D} = {8AC72641-30D3-4ACF-89FA-808FADC55C2E} + {059473BA-FAF9-405F-9985-33DDCA2E9F0D} = {14CDBAD1-10C8-464A-B445-1F727C988010} {B39B5FB6-E7B9-4A13-8FFA-FC7FEED4371B} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} {C8A00439-5B8D-4923-8FAA-AB75E2A786ED} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F} - {F3AE9617-983D-4940-B5EB-35E3580C0B0F} = {14CDBAD1-10C8-464A-B445-1F727C988010} {31B03DCB-ED12-4412-867A-61E347D40D8C} = {3CDBA2A6-DC8A-48C5-8A6C-AF207394B43D} {AB984240-EF03-416F-A9B2-F5CF169E04B7} = {3CDBA2A6-DC8A-48C5-8A6C-AF207394B43D} {EBBBBD00-74B5-49CB-8C24-4FD7C2ECC415} = {3CDBA2A6-DC8A-48C5-8A6C-AF207394B43D} diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln index 8d06dfc9e..28916cf62 100644 --- a/aspnet-core/LINGYUN.MicroService.Common.sln +++ b/aspnet-core/LINGYUN.MicroService.Common.sln @@ -17,8 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.Sign EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.SignalR.JwtToken", "modules\common\LINGYUN.Abp.AspNetCore.SignalR\LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj", "{304D06E6-41EC-4DCB-AEAE-DBEEC75F9ADC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Aliyun.Authorization", "modules\common\LINGYUN.Abp.Aliyun.Authorization\LINGYUN.Abp.Aliyun.Authorization.csproj", "{58777534-1AEF-4D1B-807C-1070D6CB1D48}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.BackgroundJobs", "modules\common\LINGYUN.Abp.BackgroundJobs\LINGYUN.Abp.BackgroundJobs.csproj", "{FFC21AA5-8DCF-4514-95F0-9A1D428095F8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.BackgroundJobs.Hangfire", "modules\common\LINGYUN.Abp.BackgroundJobs.Hangfire\LINGYUN.Abp.BackgroundJobs.Hangfire.csproj", "{492710E6-EEF5-4390-A474-8FB2412ECBE5}" @@ -95,7 +93,23 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WeChat.SettingM EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.WeChat.MiniProgram", "modules\wechat\LINGYUN.Abp.Notifications.WeChat.MiniProgram\LINGYUN.Abp.Notifications.WeChat.MiniProgram.csproj", "{D119C919-230B-4614-9A06-98586635DBFC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Core", "modules\common\LINGYUN.Abp.Core\LINGYUN.Abp.Core.csproj", "{A7A28D6C-6EDB-4615-8899-7DE1D435B750}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Core", "modules\common\LINGYUN.Abp.Core\LINGYUN.Abp.Core.csproj", "{A7A28D6C-6EDB-4615-8899-7DE1D435B750}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Aliyun", "modules\cloud-aliyun\LINGYUN.Abp.Aliyun\LINGYUN.Abp.Aliyun.csproj", "{17A8455F-D413-4664-AEFA-1ECAE9ED4B19}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{B86C21A4-73B7-471E-B73A-B4B905EC9435}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TestsBase", "tests\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj", "{3BAA3D38-96C2-4C4C-B790-AE2997BFDE25}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.BlobStoring.Aliyun.Tests", "tests\LINGYUN.Abp.BlobStoring.Aliyun.Tests\LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj", "{2E35CB93-2E9C-4EE1-845F-72A40271648E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "console", "console", "{8D2AD50B-DD4B-48A2-88EC-0E8E8236D883}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Encryption.Console", "modules\console\LINGYUN.Abp.Encryption.Console\LINGYUN.Abp.Encryption.Console.csproj", "{8FB74B18-CA5C-4DC3-8DFA-600133A05712}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Aliyun.Tests", "tests\LINGYUN.Abp.Aliyun.Tests\LINGYUN.Abp.Aliyun.Tests.csproj", "{3DBF0975-B09D-49CA-9AF8-69175EDB9D52}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Sms.Aliyun.Tests", "tests\LINGYUN.Abp.Sms.Aliyun.Tests\LINGYUN.Abp.Sms.Aliyun.Tests.csproj", "{93DD5A05-B67A-4E11-BB56-F6B4E7F1489C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -123,10 +137,6 @@ Global {304D06E6-41EC-4DCB-AEAE-DBEEC75F9ADC}.Debug|Any CPU.Build.0 = Debug|Any CPU {304D06E6-41EC-4DCB-AEAE-DBEEC75F9ADC}.Release|Any CPU.ActiveCfg = Release|Any CPU {304D06E6-41EC-4DCB-AEAE-DBEEC75F9ADC}.Release|Any CPU.Build.0 = Release|Any CPU - {58777534-1AEF-4D1B-807C-1070D6CB1D48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {58777534-1AEF-4D1B-807C-1070D6CB1D48}.Debug|Any CPU.Build.0 = Debug|Any CPU - {58777534-1AEF-4D1B-807C-1070D6CB1D48}.Release|Any CPU.ActiveCfg = Release|Any CPU - {58777534-1AEF-4D1B-807C-1070D6CB1D48}.Release|Any CPU.Build.0 = Release|Any CPU {FFC21AA5-8DCF-4514-95F0-9A1D428095F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FFC21AA5-8DCF-4514-95F0-9A1D428095F8}.Debug|Any CPU.Build.0 = Debug|Any CPU {FFC21AA5-8DCF-4514-95F0-9A1D428095F8}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -255,6 +265,30 @@ Global {A7A28D6C-6EDB-4615-8899-7DE1D435B750}.Debug|Any CPU.Build.0 = Debug|Any CPU {A7A28D6C-6EDB-4615-8899-7DE1D435B750}.Release|Any CPU.ActiveCfg = Release|Any CPU {A7A28D6C-6EDB-4615-8899-7DE1D435B750}.Release|Any CPU.Build.0 = Release|Any CPU + {17A8455F-D413-4664-AEFA-1ECAE9ED4B19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17A8455F-D413-4664-AEFA-1ECAE9ED4B19}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17A8455F-D413-4664-AEFA-1ECAE9ED4B19}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17A8455F-D413-4664-AEFA-1ECAE9ED4B19}.Release|Any CPU.Build.0 = Release|Any CPU + {3BAA3D38-96C2-4C4C-B790-AE2997BFDE25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3BAA3D38-96C2-4C4C-B790-AE2997BFDE25}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3BAA3D38-96C2-4C4C-B790-AE2997BFDE25}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3BAA3D38-96C2-4C4C-B790-AE2997BFDE25}.Release|Any CPU.Build.0 = Release|Any CPU + {2E35CB93-2E9C-4EE1-845F-72A40271648E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E35CB93-2E9C-4EE1-845F-72A40271648E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E35CB93-2E9C-4EE1-845F-72A40271648E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E35CB93-2E9C-4EE1-845F-72A40271648E}.Release|Any CPU.Build.0 = Release|Any CPU + {8FB74B18-CA5C-4DC3-8DFA-600133A05712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8FB74B18-CA5C-4DC3-8DFA-600133A05712}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8FB74B18-CA5C-4DC3-8DFA-600133A05712}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8FB74B18-CA5C-4DC3-8DFA-600133A05712}.Release|Any CPU.Build.0 = Release|Any CPU + {3DBF0975-B09D-49CA-9AF8-69175EDB9D52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DBF0975-B09D-49CA-9AF8-69175EDB9D52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DBF0975-B09D-49CA-9AF8-69175EDB9D52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DBF0975-B09D-49CA-9AF8-69175EDB9D52}.Release|Any CPU.Build.0 = Release|Any CPU + {93DD5A05-B67A-4E11-BB56-F6B4E7F1489C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {93DD5A05-B67A-4E11-BB56-F6B4E7F1489C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {93DD5A05-B67A-4E11-BB56-F6B4E7F1489C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {93DD5A05-B67A-4E11-BB56-F6B4E7F1489C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -266,7 +300,6 @@ Global {824CB367-383B-48B2-972D-33923438A9A0} = {B91F26C5-B148-4094-B5F1-71E5F945DBED} {E9AEC9D6-1FE7-4B00-BAC5-2C3D4B63CCA2} = {E2E7A062-0ABB-41B4-8220-60228446D2C2} {304D06E6-41EC-4DCB-AEAE-DBEEC75F9ADC} = {E2E7A062-0ABB-41B4-8220-60228446D2C2} - {58777534-1AEF-4D1B-807C-1070D6CB1D48} = {7F18BCA5-35BD-41FB-8EFF-801B56E5E414} {FFC21AA5-8DCF-4514-95F0-9A1D428095F8} = {086BE5BE-8594-4DA7-8819-935FEF76DABD} {492710E6-EEF5-4390-A474-8FB2412ECBE5} = {086BE5BE-8594-4DA7-8819-935FEF76DABD} {CCF1EB86-29BD-4531-BB27-C9111CC67570} = {7F18BCA5-35BD-41FB-8EFF-801B56E5E414} @@ -306,6 +339,13 @@ Global {D0717513-2CEE-4AD5-A1DA-A08EA5DE6DD6} = {22C61434-D29A-4376-AD56-F5089F3E617A} {D119C919-230B-4614-9A06-98586635DBFC} = {22C61434-D29A-4376-AD56-F5089F3E617A} {A7A28D6C-6EDB-4615-8899-7DE1D435B750} = {086BE5BE-8594-4DA7-8819-935FEF76DABD} + {17A8455F-D413-4664-AEFA-1ECAE9ED4B19} = {7F18BCA5-35BD-41FB-8EFF-801B56E5E414} + {3BAA3D38-96C2-4C4C-B790-AE2997BFDE25} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} + {2E35CB93-2E9C-4EE1-845F-72A40271648E} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} + {8D2AD50B-DD4B-48A2-88EC-0E8E8236D883} = {02EA4E78-5891-43BC-944F-3E52FEE032E4} + {8FB74B18-CA5C-4DC3-8DFA-600133A05712} = {8D2AD50B-DD4B-48A2-88EC-0E8E8236D883} + {3DBF0975-B09D-49CA-9AF8-69175EDB9D52} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} + {93DD5A05-B67A-4E11-BB56-F6B4E7F1489C} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8} diff --git a/aspnet-core/LINGYUN.MicroService.Platform.sln b/aspnet-core/LINGYUN.MicroService.Platform.sln index cfcf24033..4d6f304f3 100644 --- a/aspnet-core/LINGYUN.MicroService.Platform.sln +++ b/aspnet-core/LINGYUN.MicroService.Platform.sln @@ -39,6 +39,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tenants", "tenants", "{8CDB EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.MultiTenancy", "modules\tenants\LINGYUN.Abp.MultiTenancy\LINGYUN.Abp.MultiTenancy.csproj", "{CF0EBF60-EDC7-47FF-BCD7-C2B16407B590}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CCEFF583-4EEE-433F-8568-9E64166B41FE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.TestsBase", "tests\LINGYUN.Abp.TestBase\LINGYUN.Abp.TestsBase.csproj", "{FC3E5BA0-C650-4EA2-8400-0A864D0EFEAC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.EntityFrameworkCore.Tests", "tests\LINGYUN.Abp.EntityFrameworkCore.Tests\LINGYUN.Abp.EntityFrameworkCore.Tests.csproj", "{B2C0271C-3FE6-4C45-B162-4DE00E542A55}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Platform.EntityFrameworkCore.Tests", "tests\LINGYUN.Platform.EntityFrameworkCore.Tests\LINGYUN.Platform.EntityFrameworkCore.Tests.csproj", "{263C49A9-34B9-449B-ABBC-D328210C023D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Platform.Domain.Tests", "tests\LINGYUN.Platform.Domain.Tests\LINGYUN.Platform.Domain.Tests.csproj", "{C60A06F2-0F4C-483F-BE2B-B103F0D726CE}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -97,6 +107,22 @@ Global {CF0EBF60-EDC7-47FF-BCD7-C2B16407B590}.Debug|Any CPU.Build.0 = Debug|Any CPU {CF0EBF60-EDC7-47FF-BCD7-C2B16407B590}.Release|Any CPU.ActiveCfg = Release|Any CPU {CF0EBF60-EDC7-47FF-BCD7-C2B16407B590}.Release|Any CPU.Build.0 = Release|Any CPU + {FC3E5BA0-C650-4EA2-8400-0A864D0EFEAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC3E5BA0-C650-4EA2-8400-0A864D0EFEAC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC3E5BA0-C650-4EA2-8400-0A864D0EFEAC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC3E5BA0-C650-4EA2-8400-0A864D0EFEAC}.Release|Any CPU.Build.0 = Release|Any CPU + {B2C0271C-3FE6-4C45-B162-4DE00E542A55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2C0271C-3FE6-4C45-B162-4DE00E542A55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2C0271C-3FE6-4C45-B162-4DE00E542A55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2C0271C-3FE6-4C45-B162-4DE00E542A55}.Release|Any CPU.Build.0 = Release|Any CPU + {263C49A9-34B9-449B-ABBC-D328210C023D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {263C49A9-34B9-449B-ABBC-D328210C023D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {263C49A9-34B9-449B-ABBC-D328210C023D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {263C49A9-34B9-449B-ABBC-D328210C023D}.Release|Any CPU.Build.0 = Release|Any CPU + {C60A06F2-0F4C-483F-BE2B-B103F0D726CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C60A06F2-0F4C-483F-BE2B-B103F0D726CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C60A06F2-0F4C-483F-BE2B-B103F0D726CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C60A06F2-0F4C-483F-BE2B-B103F0D726CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -118,6 +144,10 @@ Global {C616C167-E5DF-4141-98BE-F98C58890122} = {C7D0EB39-3418-4A7C-AD94-FAB76F023E88} {8CDB2F58-9541-4FB2-8A37-079C5E6A1689} = {15BDA03E-DE8E-46E4-96A8-CA3F2872E812} {CF0EBF60-EDC7-47FF-BCD7-C2B16407B590} = {8CDB2F58-9541-4FB2-8A37-079C5E6A1689} + {FC3E5BA0-C650-4EA2-8400-0A864D0EFEAC} = {CCEFF583-4EEE-433F-8568-9E64166B41FE} + {B2C0271C-3FE6-4C45-B162-4DE00E542A55} = {CCEFF583-4EEE-433F-8568-9E64166B41FE} + {263C49A9-34B9-449B-ABBC-D328210C023D} = {CCEFF583-4EEE-433F-8568-9E64166B41FE} + {C60A06F2-0F4C-483F-BE2B-B103F0D726CE} = {CCEFF583-4EEE-433F-8568-9E64166B41FE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {03D3B66F-8926-4C00-B7AB-A21761EC859E} diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj index 5af03b5ac..c7b9a6dcc 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application.Contracts/LINGYUN.Abp.Account.Application.Contracts.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj index 76f881c40..74eb6ad56 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN.Abp.Account.Application.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN.Abp.Account.Domain.Shared.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN.Abp.Account.Domain.Shared.csproj index a112fa029..f780f22ba 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN.Abp.Account.Domain.Shared.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain.Shared/LINGYUN.Abp.Account.Domain.Shared.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN.Abp.Account.Domain.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN.Abp.Account.Domain.csproj index 39eb53e30..131db7a6e 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN.Abp.Account.Domain.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Domain/LINGYUN.Abp.Account.Domain.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj index fa41d5931..72231cea6 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.HttpApi/LINGYUN.Abp.Account.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/LINGYUN.Abp.Account.Web.csproj b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/LINGYUN.Abp.Account.Web.csproj index e09839e0c..79d80c06d 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/LINGYUN.Abp.Account.Web.csproj +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web/LINGYUN.Abp.Account.Web.csproj @@ -29,9 +29,9 @@ - - - + + + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN.ApiGateway.Application.Contracts.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN.ApiGateway.Application.Contracts.csproj index 33cd29545..377c06860 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN.ApiGateway.Application.Contracts.csproj +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application.Contracts/LINGYUN.ApiGateway.Application.Contracts.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN.ApiGateway.Application.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN.ApiGateway.Application.csproj index 8d12cf4e8..9770e4101 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN.ApiGateway.Application.csproj +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN.ApiGateway.Application.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/AggregateReRouteAppService.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/AggregateReRouteAppService.cs index 77b125687..b9de682e7 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/AggregateReRouteAppService.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/AggregateReRouteAppService.cs @@ -15,8 +15,7 @@ namespace LINGYUN.ApiGateway.Ocelot [Authorize(ApiGatewayPermissions.AggregateRoute.Default)] public class AggregateReRouteAppService : ApiGatewayApplicationServiceBase, IAggregateReRouteAppService { - private IDistributedEventBus _eventBus; - protected IDistributedEventBus DistributedEventBus => LazyGetRequiredService(ref _eventBus); + protected IDistributedEventBus DistributedEventBus => LazyServiceProvider.LazyGetRequiredService(); private readonly IAggregateReRouteRepository _aggregateReRouteRepository; diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationAppService.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationAppService.cs index 3e795b7c2..25043cc1c 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationAppService.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationAppService.cs @@ -11,8 +11,7 @@ namespace LINGYUN.ApiGateway.Ocelot [Authorize(ApiGatewayPermissions.Global.Default)] public class GlobalConfigurationAppService : ApiGatewayApplicationServiceBase, IGlobalConfigurationAppService { - private IDistributedEventBus _eventBus; - protected IDistributedEventBus DistributedEventBus => LazyGetRequiredService(ref _eventBus); + protected IDistributedEventBus DistributedEventBus => LazyServiceProvider.LazyGetRequiredService(); private readonly IRouteGroupChecker _routeGroupChecker; private readonly IGlobalConfigRepository _globalConfigRepository; diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/ReRouteAppService.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/ReRouteAppService.cs index eb69995cc..3c0f9b466 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/ReRouteAppService.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/ReRouteAppService.cs @@ -10,8 +10,7 @@ namespace LINGYUN.ApiGateway.Ocelot [Authorize(ApiGatewayPermissions.Route.Default)] public class ReRouteAppService : ApiGatewayApplicationServiceBase, IReRouteAppService { - private IDistributedEventBus _eventBus; - protected IDistributedEventBus DistributedEventBus => LazyGetRequiredService(ref _eventBus); + protected IDistributedEventBus DistributedEventBus => LazyServiceProvider.LazyGetRequiredService(); private readonly IRouteGroupChecker _routeGroupChecker; private readonly IReRouteRepository _reRouteRepository; diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs index 91fb2b0a1..bb5d3ceea 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Application/LINGYUN/ApiGateway/Ocelot/RouteGroupAppService.cs @@ -10,8 +10,7 @@ namespace LINGYUN.ApiGateway.Ocelot [Authorize(ApiGatewayPermissions.RouteGroup.Default)] public class RouteGroupAppService : ApiGatewayApplicationServiceBase, IRouteGroupAppService { - private IDataFilter _dataFilter; - protected IDataFilter DataFilter => LazyGetRequiredService(ref _dataFilter); + protected IDataFilter DataFilter => LazyServiceProvider.LazyGetRequiredService(); protected IRouteGroupRepository RouterRepository { get; } public RouteGroupAppService( diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN.ApiGateway.Domain.Shared.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN.ApiGateway.Domain.Shared.csproj index 811736e63..769a43349 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN.ApiGateway.Domain.Shared.csproj +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain.Shared/LINGYUN.ApiGateway.Domain.Shared.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain/LINGYUN.ApiGateway.Domain.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain/LINGYUN.ApiGateway.Domain.csproj index 6e20cad47..6931853e7 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain/LINGYUN.ApiGateway.Domain.csproj +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.Domain/LINGYUN.ApiGateway.Domain.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN.ApiGateway.EntityFrameworkCore.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN.ApiGateway.EntityFrameworkCore.csproj index 6167ff624..7feeb1ba6 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN.ApiGateway.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN.ApiGateway.EntityFrameworkCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreAggregateReRouteRepository.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreAggregateReRouteRepository.cs index 1320dda17..8c5ee4121 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreAggregateReRouteRepository.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreAggregateReRouteRepository.cs @@ -17,23 +17,25 @@ namespace LINGYUN.ApiGateway.Ocelot public async Task AggregateReRouteNameExistsAsync(string name) { - return await DbSet.AnyAsync(ar => ar.Name.Equals(name)); + return await (await GetDbSetAsync()).AnyAsync(ar => ar.Name.Equals(name)); } public async Task GetByRouteIdAsync(long routeId) { - return await WithDetails().Where(ar => ar.ReRouteId.Equals(routeId)).FirstOrDefaultAsync(); + return await (await WithDetailsAsync()) + .Where(ar => ar.ReRouteId.Equals(routeId)).FirstOrDefaultAsync(); } public async Task> GetByAppIdAsync(string appId) { - return await WithDetails().Where(ar => ar.AppId.Equals(appId)).ToListAsync(); + return await (await WithDetailsAsync()) + .Where(ar => ar.AppId.Equals(appId)).ToListAsync(); } public async Task<(List routes, long total)> GetPagedListAsync(string appId, string filter = "", string sorting = "", int skipCount = 1, int maxResultCount = 100) { - var resultReRoutes = await WithDetails() + var resultReRoutes = await (await WithDetailsAsync()) .Where(ar => ar.AppId.Equals(appId)) .WhereIf(!filter.IsNullOrWhiteSpace(), ar => ar.ReRouteKeys.Contains(filter) || ar.UpstreamHost.Contains(filter) || ar.UpstreamPathTemplate.Contains(filter)) @@ -41,7 +43,7 @@ namespace LINGYUN.ApiGateway.Ocelot .EfPageBy(skipCount, maxResultCount) .ToListAsync(); - var total = await GetQueryable() + var total = await (await GetQueryableAsync()) .Where(ar => ar.AppId.Equals(appId)) .WhereIf(!filter.IsNullOrWhiteSpace(), ar => ar.ReRouteKeys.Contains(filter) || ar.UpstreamHost.Contains(filter) || ar.UpstreamPathTemplate.Contains(filter)).LongCountAsync(); diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreDynamicReRouteRepository.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreDynamicReRouteRepository.cs index f8afc828b..ffa1a3cfa 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreDynamicReRouteRepository.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreDynamicReRouteRepository.cs @@ -17,12 +17,17 @@ namespace LINGYUN.ApiGateway.Ocelot public async Task GetByItemIdAsync(int itemId) { - return await GetQueryable().Where(x => x.DynamicReRouteId.Equals(itemId)).FirstOrDefaultAsync(); + return await (await GetQueryableAsync()).Where(x => x.DynamicReRouteId.Equals(itemId)).FirstOrDefaultAsync(); } public async Task> GetByAppIdAsync(string appId) { - return await WithDetails().Where(x => x.AppId.Equals(appId)).ToListAsync(); + return await (await WithDetailsAsync()).Where(x => x.AppId.Equals(appId)).ToListAsync(); + } + + public override async Task> WithDetailsAsync() + { + return await WithDetailsAsync(x => x.RateLimitRule); ; } public override IQueryable WithDetails() diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreGlobalConfigRepository.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreGlobalConfigRepository.cs index afbb87ea1..a721da01c 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreGlobalConfigRepository.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreGlobalConfigRepository.cs @@ -19,7 +19,7 @@ namespace LINGYUN.ApiGateway.Ocelot public async Task GetByItemIdAsync(long itemId) { - var globalConfiguration = await WithDetails().Where(x => x.ItemId.Equals(itemId)).FirstOrDefaultAsync(); + var globalConfiguration = await (await WithDetailsAsync()).Where(x => x.ItemId.Equals(itemId)).FirstOrDefaultAsync(); if(globalConfiguration == null) { throw new EntityNotFoundException(typeof(GlobalConfiguration)); @@ -29,7 +29,7 @@ namespace LINGYUN.ApiGateway.Ocelot public async Task GetByAppIdAsync(string appId) { - return await WithDetails() + return await (await WithDetailsAsync()) .Where(g => g.AppId.Equals(appId)) .FirstOrDefaultAsync(); } @@ -37,13 +37,13 @@ namespace LINGYUN.ApiGateway.Ocelot public virtual async Task<(List Globals, long TotalCount)> GetPagedListAsync(string filter = "", string sorting = "", int skipCount = 1, int maxResultCount = 10) { - var globals = await WithDetails() + var globals = await (await WithDetailsAsync()) .WhereIf(!filter.IsNullOrWhiteSpace(), g => g.AppId.Contains(filter) || g.BaseUrl.Contains(filter) || g.DownstreamScheme.Contains(filter)) .OrderBy(g => sorting ?? g.BaseUrl) .EfPageBy(skipCount, maxResultCount) .ToListAsync(); - var total = await GetQueryable() + var total = await (await GetQueryableAsync()) .WhereIf(!filter.IsNullOrWhiteSpace(), g => g.AppId.Contains(filter) || g.BaseUrl.Contains(filter) || g.DownstreamScheme.Contains(filter)) .LongCountAsync(); @@ -51,6 +51,16 @@ namespace LINGYUN.ApiGateway.Ocelot return ValueTuple.Create(globals, total); } + public override async Task> WithDetailsAsync() + { + return await WithDetailsAsync( + x => x.HttpHandlerOptions, + x => x.LoadBalancerOptions, + x => x.QoSOptions, + x => x.RateLimitOptions, + x => x.ServiceDiscoveryProvider); + } + public override IQueryable WithDetails() { return WithDetails( diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreReRouteRepository.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreReRouteRepository.cs index 116374712..f3c4df428 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreReRouteRepository.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreReRouteRepository.cs @@ -19,19 +19,19 @@ namespace LINGYUN.ApiGateway.Ocelot public async Task GetByNameAsync(string routeName) { - var reRoute = await WithDetails().Where(x => x.ReRouteName.Equals(routeName)).FirstOrDefaultAsync(); + var reRoute = await (await WithDetailsAsync()).Where(x => x.ReRouteName.Equals(routeName)).FirstOrDefaultAsync(); return reRoute ?? throw new EntityNotFoundException(typeof(ReRoute), routeName); } public async Task GetByReRouteIdAsync(long routeId) { - var reRoute = await WithDetails().Where(x => x.ReRouteId.Equals(routeId)).FirstOrDefaultAsync(); + var reRoute = await (await WithDetailsAsync()).Where(x => x.ReRouteId.Equals(routeId)).FirstOrDefaultAsync(); return reRoute ?? throw new EntityNotFoundException(typeof(ReRoute), routeId); } public async Task> GetByAppIdAsync(string appId) { - return await WithDetails() + return await (await WithDetailsAsync()) .Where(r => r.AppId.Equals(appId)) .ToListAsync(); } @@ -39,7 +39,7 @@ namespace LINGYUN.ApiGateway.Ocelot public async Task<(List routes, long total)> GetPagedListAsync(string appId, string filter = "", string sorting = "", int skipCount = 1, int maxResultCount = 100) { - var resultReRoutes = await WithDetails() + var resultReRoutes = await (await WithDetailsAsync()) .Where(r => r.AppId.Equals(appId)) .WhereIf(!filter.IsNullOrWhiteSpace(), r => r.ReRouteName.Contains(filter) || r.DownstreamHostAndPorts.Contains(filter) || r.ServiceName.Contains(filter)) @@ -47,7 +47,7 @@ namespace LINGYUN.ApiGateway.Ocelot .EfPageBy(skipCount, maxResultCount) .ToListAsync(); - var total = await GetQueryable() + var total = await (await GetQueryableAsync()) .Where(r => r.AppId.Equals(appId)) .WhereIf(!filter.IsNullOrWhiteSpace(), r => r.ReRouteName.Contains(filter) || r.DownstreamHostAndPorts.Contains(filter) || r.ServiceName.Contains(filter)) @@ -58,20 +58,21 @@ namespace LINGYUN.ApiGateway.Ocelot public async Task RemoveAsync(CancellationToken cancellationToken = default(CancellationToken)) { - var entityType = DbContext.Model.FindEntityType(typeof(ReRoute)); + var dbContext = await GetDbContextAsync(); + var entityType = dbContext.Model.FindEntityType(typeof(ReRoute)); var tableName = entityType.GetTableName();//.Relational().TableName; var sqlText = $"DELETE FROM @tableName"; var sqlParam = new List { new { tableName } }; // TODO: Test - await DbContext.Database.ExecuteSqlRawAsync(sqlText, sqlParam, cancellationToken); + await dbContext.Database.ExecuteSqlRawAsync(sqlText, sqlParam, cancellationToken); //await DbContext.Database.ExecuteSqlCommandAsync(sqlText, sqlParam, cancellationToken); } - public override IQueryable WithDetails() + public override async Task> WithDetailsAsync() { - return WithDetails( + return await WithDetailsAsync( x => x.AuthenticationOptions, x => x.CacheOptions, x => x.HttpHandlerOptions, @@ -80,5 +81,17 @@ namespace LINGYUN.ApiGateway.Ocelot x => x.RateLimitOptions, x => x.SecurityOptions); } + + public override IQueryable WithDetails() + { + return WithDetails( + x => x.AuthenticationOptions, + x => x.CacheOptions, + x => x.HttpHandlerOptions, + x => x.LoadBalancerOptions, + x => x.QoSOptions, + x => x.RateLimitOptions, + x => x.SecurityOptions); + } } } diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreRouteGroupRepository.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreRouteGroupRepository.cs index 1803cdead..cdaf654fa 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreRouteGroupRepository.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.EntityFrameworkCore/LINGYUN/ApiGateway/Ocelot/EfCoreRouteGroupRepository.cs @@ -18,24 +18,25 @@ namespace LINGYUN.ApiGateway.Ocelot public virtual async Task> GetActivedAppsAsync() { - return await DbSet.Select(g => new RouteGroupAppKey(g.AppId, g.AppName)).ToArrayAsync(); + return await (await GetDbSetAsync()).Select(g => new RouteGroupAppKey(g.AppId, g.AppName)).ToArrayAsync(); } public virtual async Task GetByAppIdAsync(string appId) { - var routeGroup = await DbSet.Where(g => g.AppId.Equals(appId)).FirstOrDefaultAsync(); + var routeGroup = await (await GetDbSetAsync()).Where(g => g.AppId.Equals(appId)).FirstOrDefaultAsync(); return routeGroup ?? throw new EntityNotFoundException(typeof(RouteGroup), appId); } public virtual async Task<(List Routers, long TotalCount)> GetPagedListAsync(string filter = "", string sorting = "", int skipCount = 1, int maxResultCount = 10) { - var groups = await DbSet + var dbSet = await GetDbSetAsync(); + var groups = await dbSet .WhereIf(!filter.IsNullOrWhiteSpace(), g => g.AppId.Contains(filter) || g.AppName.Contains(filter) || g.AppIpAddress.Contains(filter) || g.Description.Contains(filter)) .OrderBy(g => sorting ?? nameof(RouteGroup.AppId)) .EfPageBy(skipCount, maxResultCount) .ToListAsync(); - var toatl = await DbSet + var toatl = await dbSet .WhereIf(!filter.IsNullOrWhiteSpace(), g => g.AppId.Contains(filter) || g.AppName.Contains(filter) || g.AppIpAddress.Contains(filter) || g.Description.Contains(filter)) .LongCountAsync(); diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi.Client/LINGYUN.ApiGateway.HttpApi.Client.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi.Client/LINGYUN.ApiGateway.HttpApi.Client.csproj index 7da50926d..b93c96321 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi.Client/LINGYUN.ApiGateway.HttpApi.Client.csproj +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi.Client/LINGYUN.ApiGateway.HttpApi.Client.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN.ApiGateway.HttpApi.csproj b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN.ApiGateway.HttpApi.csproj index 7369b2659..69f433809 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN.ApiGateway.HttpApi.csproj +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN.ApiGateway.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationController.cs b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationController.cs index 4f86b2ed1..38033b444 100644 --- a/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationController.cs +++ b/aspnet-core/modules/apigateway/LINGYUN.ApiGateway.HttpApi/LINGYUN/ApiGateway/Ocelot/GlobalConfigurationController.cs @@ -1,10 +1,8 @@ -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Authorization.Permissions; -using Volo.Abp.Clients; namespace LINGYUN.ApiGateway.Ocelot { @@ -27,8 +25,6 @@ namespace LINGYUN.ApiGateway.Ocelot [Route("By-AppId/{AppId}")] public async Task GetAsync(GlobalGetByAppIdInputDto input) { - ICurrentClient client = null; - var currentClient = LazyGetRequiredService(ref client); return await GlobalConfigurationAppService.GetAsync(input); } diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN.Abp.Auditing.Application.Contracts.csproj b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN.Abp.Auditing.Application.Contracts.csproj index 4ec07bd27..c8ab1780d 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN.Abp.Auditing.Application.Contracts.csproj +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application.Contracts/LINGYUN.Abp.Auditing.Application.Contracts.csproj @@ -13,11 +13,11 @@ - - - - - + + + + + diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj index da63e6f87..5ef4c2ad6 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.Application/LINGYUN.Abp.Auditing.Application.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj index 0385e2b6e..958056a9e 100644 --- a/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj +++ b/aspnet-core/modules/auditing/LINGYUN.Abp.Auditing.HttpApi/LINGYUN.Abp.Auditing.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj index 331d270b8..8ed96f7d2 100644 --- a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN.Abp.Aliyun.csproj @@ -20,10 +20,11 @@ - - - - + + + + + diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunException.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunException.cs new file mode 100644 index 000000000..510c5a040 --- /dev/null +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunException.cs @@ -0,0 +1,21 @@ +using Microsoft.Extensions.Logging; +using Volo.Abp; +using Volo.Abp.ExceptionHandling; +using Volo.Abp.Logging; + +namespace LINYUN.Abp.Aliyun +{ + public class AbpAliyunException : AbpException, IHasErrorCode, IHasLogLevel + { + public LogLevel LogLevel { get; set; } + + public string Code { get; } + + public AbpAliyunException(string code, string message) + : base(message) + { + Code = code; + LogLevel = LogLevel.Warning; + } + } +} diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunCloudModule.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunModule.cs similarity index 76% rename from aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunCloudModule.cs rename to aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunModule.cs index 80d744bb3..ed462d06a 100644 --- a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunCloudModule.cs +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AbpAliyunModule.cs @@ -1,21 +1,25 @@ using LINYUN.Abp.Aliyun.Localization; +using Volo.Abp.Caching; using Volo.Abp.Json; using Volo.Abp.Localization; using Volo.Abp.Modularity; +using Volo.Abp.Settings; using Volo.Abp.VirtualFileSystem; namespace LINGYUN.Abp.Aliyun { [DependsOn( + typeof(AbpCachingModule), + typeof(AbpSettingsModule), typeof(AbpJsonModule), typeof(AbpLocalizationModule))] - public class AbpAliyunCloudModule : AbpModule + public class AbpAliyunModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { Configure(options => { - options.FileSets.AddEmbedded(); + options.FileSets.AddEmbedded(); }); Configure(options => diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AcsClientFactory.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AcsClientFactory.cs new file mode 100644 index 000000000..277732303 --- /dev/null +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AcsClientFactory.cs @@ -0,0 +1,32 @@ +using Aliyun.Acs.Core; +using Aliyun.Acs.Core.Auth; +using Aliyun.Acs.Core.Profile; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Settings; + +namespace LINYUN.Abp.Aliyun +{ + public class AcsClientFactory : AliyunClientFactory, IAcsClientFactory, ITransientDependency + { + public AcsClientFactory( + ISettingProvider settingProvider, + IDistributedCache cache) + : base(settingProvider, cache) + { + } + + protected override IAcsClient GetClient(string regionId, string accessKeyId, string accessKeySecret) + { + return new DefaultAcsClient( + DefaultProfile.GetProfile(regionId, accessKeyId, accessKeySecret)); + } + + protected override IAcsClient GetSecurityTokenClient(string regionId, string accessKeyId, string accessKeySecret, string securityToken) + { + var profile = DefaultProfile.GetProfile(regionId); + var credentials = new BasicSessionCredentials(accessKeyId, accessKeySecret, securityToken); + return new DefaultAcsClient(profile, credentials); + } + } +} diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AliyunBasicSessionCredentialsCacheItem.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AliyunBasicSessionCredentialsCacheItem.cs new file mode 100644 index 000000000..7d135ce34 --- /dev/null +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AliyunBasicSessionCredentialsCacheItem.cs @@ -0,0 +1,31 @@ +using System; + +namespace LINYUN.Abp.Aliyun +{ + [Serializable] + public class AliyunBasicSessionCredentialsCacheItem + { + private readonly static string _cacheKey; + public static string CacheKey => _cacheKey; + public string AccessKeyId { get; set; } + public string AccessKeySecret { get; set; } + public string SecurityToken { get; set; } + + static AliyunBasicSessionCredentialsCacheItem() + { + _cacheKey = Guid.NewGuid().ToString("N"); + } + + public AliyunBasicSessionCredentialsCacheItem() + { + + } + + public AliyunBasicSessionCredentialsCacheItem(string accessKeyId, string accessKeySecret, string securityToken) + { + AccessKeyId = accessKeyId; + AccessKeySecret = accessKeySecret; + SecurityToken = securityToken; + } + } +} diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AliyunClientFactory.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AliyunClientFactory.cs new file mode 100644 index 000000000..95912462c --- /dev/null +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/AliyunClientFactory.cs @@ -0,0 +1,180 @@ +using Aliyun.Acs.Core; +using Aliyun.Acs.Core.Auth.Sts; +using Aliyun.Acs.Core.Http; +using Aliyun.Acs.Core.Profile; +using LINYUN.Abp.Aliyun.Settings; +using Microsoft.Extensions.Caching.Distributed; +using System; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Caching; +using Volo.Abp.Settings; + +namespace LINYUN.Abp.Aliyun +{ + /// + /// 阿里云通用客户端构建工厂 + /// + /// + public abstract class AliyunClientFactory + { + protected ISettingProvider SettingProvider { get; } + protected IDistributedCache Cache { get; } + public AliyunClientFactory( + ISettingProvider settingProvider, + IDistributedCache cache) + { + Cache = cache; + SettingProvider = settingProvider; + } + + public virtual async Task CreateAsync() + { + var regionId = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.RegionId); + var accessKey = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.AccessKeyId); + var accessKeySecret = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.AccessKeySecret); + + Check.NotNullOrWhiteSpace(regionId, AliyunSettingNames.Authorization.RegionId); + Check.NotNullOrWhiteSpace(accessKey, AliyunSettingNames.Authorization.AccessKeyId); + Check.NotNullOrWhiteSpace(accessKeySecret, AliyunSettingNames.Authorization.AccessKeySecret); + + if (await SettingProvider.IsTrueAsync(AliyunSettingNames.Authorization.UseSecurityTokenService)) + { + var cacheItem = await GetCacheItemAsync(accessKey, accessKeySecret, regionId); + + return GetSecurityTokenClient(regionId, cacheItem.AccessKeyId, cacheItem.AccessKeySecret, cacheItem.SecurityToken); + } + + return GetClient(regionId, accessKey, accessKeySecret); + } + + protected abstract TClient GetClient(string regionId, string accessKeyId, string accessKeySecret); + + protected abstract TClient GetSecurityTokenClient(string regionId, string accessKeyId, string accessKeySecret, string securityToken); + + protected virtual async Task GetCacheItemAsync(string accessKeyId, string accessKeySecret, string regionId) + { + var cacheItem = await Cache.GetAsync(AliyunBasicSessionCredentialsCacheItem.CacheKey); + if (cacheItem == null) + { + var roleArn = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.RamRoleArn); + var roleSession = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.RoleSessionName); + Check.NotNullOrWhiteSpace(roleArn, AliyunSettingNames.Authorization.RamRoleArn); + + var policy = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.Policy); + var durationSeconds = await SettingProvider.GetAsync(AliyunSettingNames.Authorization.DurationSeconds, 3000); + + var profile = DefaultProfile.GetProfile(regionId, accessKeyId, accessKeySecret); + var request = new AssumeRoleRequest + { + AcceptFormat = FormatType.JSON, + RoleArn = roleArn, + RoleSessionName = roleSession, + DurationSeconds = durationSeconds, + Policy = policy.IsNullOrWhiteSpace() ? null : policy + }; + + var client = new DefaultAcsClient(profile); + var response = client.GetAcsResponse(request); + + cacheItem = new AliyunBasicSessionCredentialsCacheItem( + response.Credentials.AccessKeyId, + response.Credentials.AccessKeySecret, + response.Credentials.SecurityToken); + + await Cache.SetAsync( + AliyunBasicSessionCredentialsCacheItem.CacheKey, + cacheItem, + new DistributedCacheEntryOptions + { + AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(durationSeconds - 10) + }); + } + + return cacheItem; + } + } + /// + /// 阿里云通用客户端构建工厂 + /// + /// 客户端类型 + /// 客户端参数类型 + public abstract class AliyunClientFactory + { + protected ISettingProvider SettingProvider { get; } + protected IDistributedCache Cache { get; } + public AliyunClientFactory( + ISettingProvider settingProvider, + IDistributedCache cache) + { + Cache = cache; + SettingProvider = settingProvider; + } + + public virtual async Task CreateAsync(TConfiguration configuration) + { + var regionId = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.RegionId); + var accessKey = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.AccessKeyId); + var accessKeySecret = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.AccessKeySecret); + + Check.NotNullOrWhiteSpace(regionId, AliyunSettingNames.Authorization.RegionId); + Check.NotNullOrWhiteSpace(accessKey, AliyunSettingNames.Authorization.AccessKeyId); + Check.NotNullOrWhiteSpace(accessKeySecret, AliyunSettingNames.Authorization.AccessKeySecret); + + if (await SettingProvider.IsTrueAsync(AliyunSettingNames.Authorization.UseSecurityTokenService)) + { + var cacheItem = await GetCacheItemAsync(accessKey, accessKeySecret, regionId); + + return GetSecurityTokenClient(configuration, regionId, cacheItem.AccessKeyId, cacheItem.AccessKeySecret, cacheItem.SecurityToken); + } + + return GetClient(configuration, regionId, accessKey, accessKeySecret); + } + + protected abstract TClient GetClient(TConfiguration configuration, string regionId, string accessKeyId, string accessKeySecret); + + protected abstract TClient GetSecurityTokenClient(TConfiguration configuration, string regionId, string accessKeyId, string accessKeySecret, string securityToken); + + protected virtual async Task GetCacheItemAsync(string accessKeyId, string accessKeySecret, string regionId) + { + var cacheItem = await Cache.GetAsync(AliyunBasicSessionCredentialsCacheItem.CacheKey); + if (cacheItem == null) + { + var roleArn = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.RamRoleArn); + var roleSession = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.RoleSessionName); + Check.NotNullOrWhiteSpace(roleArn, AliyunSettingNames.Authorization.RamRoleArn); + + var policy = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Authorization.Policy); + var durationSeconds = await SettingProvider.GetAsync(AliyunSettingNames.Authorization.DurationSeconds, 3000); + + var profile = DefaultProfile.GetProfile(regionId, accessKeyId, accessKeySecret); + var request = new AssumeRoleRequest + { + AcceptFormat = FormatType.JSON, + RoleArn = roleArn, + RoleSessionName = roleSession, + DurationSeconds = durationSeconds, + Policy = policy.IsNullOrWhiteSpace() ? null : policy + }; + + var client = new DefaultAcsClient(profile); + var response = client.GetAcsResponse(request); + + cacheItem = new AliyunBasicSessionCredentialsCacheItem( + response.Credentials.AccessKeyId, + response.Credentials.AccessKeySecret, + response.Credentials.SecurityToken); + + await Cache.SetAsync( + AliyunBasicSessionCredentialsCacheItem.CacheKey, + cacheItem, + new DistributedCacheEntryOptions + { + AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(durationSeconds - 10) + }); + } + + return cacheItem; + } + } +} diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/IAcsClientFactory.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/IAcsClientFactory.cs new file mode 100644 index 000000000..fd2b84838 --- /dev/null +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/IAcsClientFactory.cs @@ -0,0 +1,15 @@ +using Aliyun.Acs.Core; +using System.Threading.Tasks; + +namespace LINYUN.Abp.Aliyun +{ + public interface IAcsClientFactory + { + /// + /// 构造一个通用的Acs客户端调用 + /// 通过CommonRequest调用可以不需要集成其他SDK包 + /// + /// + Task CreateAsync(); + } +} diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/en.json b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/en.json index a9c8dcc3f..19cf0fdf0 100644 --- a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/en.json +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/en.json @@ -1,5 +1,23 @@ { "culture": "en", "texts": { + "DisplayName:Authorization": "Authorization", + "Description:Authorization": "Authorization", + "DisplayName:RegionId": "Region Id", + "Description:RegionId": "Region Id", + "DisplayName:AccessKeyId": "AccessKey Id", + "Description:AccessKeyId": "AccessKey Id", + "DisplayName:AccessKeySecret": "AccessKey Secret", + "Description:AccessKeySecret": "AccessKey Secret", + "DisplayName:UseSecurityTokenService": "Use STS Token", + "Description:UseSecurityTokenService": "Use STS Token", + "DisplayName:RamRoleArn": "Ram Role Arn", + "Description:RamRoleArn": "Ram Role Arn", + "DisplayName:RoleSessionName": "Role Session Name", + "Description:RoleSessionName": "Role Session Name", + "DisplayName:DurationSeconds": "Duration Seconds,in seconds", + "Description:DurationSeconds": "Duration Seconds,in seconds", + "DisplayName:Policy": "Policy", + "Description:Policy": "Policy" } } \ No newline at end of file diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json index c5ad81326..20e7c54e4 100644 --- a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json @@ -1,5 +1,23 @@ { "culture": "zh-Hans", "texts": { + "DisplayName:Authorization": "阿里云身份认证凭据", + "Description:Authorization": "阿里云身份认证凭据", + "DisplayName:RegionId": "地域ID", + "Description:RegionId": "正在使用的地域ID", + "DisplayName:AccessKeyId": "AccessKey Id", + "Description:AccessKeyId": "访问密钥标识", + "DisplayName:AccessKeySecret": "AccessKey Secret", + "Description:AccessKeySecret": "访问密钥", + "DisplayName:UseSecurityTokenService": "使用STS Token访问", + "Description:UseSecurityTokenService": "使用STS Token访问", + "DisplayName:RamRoleArn": "角色全局资源描述符", + "Description:RamRoleArn": "格式:acs:ram::$accountID:role/$roleName/$RoleSessionName,详情见阿里云访问控制API", + "DisplayName:RoleSessionName": "角色的临时身份", + "Description:RoleSessionName": "此参数用来区分不同的令牌,可用于用户级别的访问审计", + "DisplayName:DurationSeconds": "过期时间,单位为秒。", + "Description:DurationSeconds": "过期时间最小值为900秒,默认3600秒", + "DisplayName:Policy": "权限策略", + "Description:Policy": "生成STS Token时可以指定一个额外的权限策略,以进一步限制STS Token的权限" } } \ No newline at end of file diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Settings/AliyunSettingNames.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Settings/AliyunSettingNames.cs index 7eb67fe3a..edc985e08 100644 --- a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Settings/AliyunSettingNames.cs +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Settings/AliyunSettingNames.cs @@ -10,10 +10,38 @@ public class Authorization { public const string Prefix = AliyunSettingNames.Prefix + ".Authorization"; - + /// + /// 地域ID + /// + public const string RegionId = Prefix + ".RegionId"; + /// + /// RAM账号的AccessKey ID + /// public const string AccessKeyId = Prefix + ".AccessKeyId"; - + /// + /// RAM账号的AccessKey Secret + /// public const string AccessKeySecret = Prefix + ".AccessKeySecret"; + /// + /// 使用STS Token访问 + /// + public const string UseSecurityTokenService = Prefix + ".UseSecurityTokenService"; + /// + /// 使用RAM子账号的AssumeRole方式访问 + /// + public const string RamRoleArn = Prefix + ".RamRoleArn"; + /// + /// 用户自定义参数。此参数用来区分不同的令牌,可用于用户级别的访问审计 + /// + public const string RoleSessionName = Prefix + ".RoleSessionName"; + /// + /// 过期时间,单位为秒。 + /// + public const string DurationSeconds = Prefix + ".DurationSeconds"; + /// + /// 权限策略。 + /// + public const string Policy = Prefix + ".Policy"; } } } diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs new file mode 100644 index 000000000..2e4f081b4 --- /dev/null +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs @@ -0,0 +1,81 @@ +using LINYUN.Abp.Aliyun.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Settings; + +namespace LINYUN.Abp.Aliyun.Settings +{ + public class AliyunSettingProvider : SettingDefinitionProvider + { + public override void Define(ISettingDefinitionContext context) + { + context.Add(CreateAliyunSettings()); + } + + private SettingDefinition[] CreateAliyunSettings() + { + return new SettingDefinition[] + { + new SettingDefinition( + AliyunSettingNames.Authorization.AccessKeyId, + displayName: L("DisplayName:AccessKeyId"), + description: L("Description:AccessKeyId"), + isVisibleToClients: false, + isEncrypted: true + ), + new SettingDefinition( + AliyunSettingNames.Authorization.AccessKeySecret, + displayName: L("DisplayName:AccessKeySecret"), + description: L("Description:AccessKeySecret"), + isVisibleToClients: false, + isEncrypted: true + ), + new SettingDefinition( + AliyunSettingNames.Authorization.DurationSeconds, + defaultValue: "3000", + displayName: L("DisplayName:DurationSeconds"), + description: L("Description:DurationSeconds"), + isVisibleToClients: false + ), + new SettingDefinition( + AliyunSettingNames.Authorization.Policy, + displayName: L("DisplayName:Policy"), + description: L("Description:Policy"), + isVisibleToClients: false, + isEncrypted: true + ), + new SettingDefinition( + AliyunSettingNames.Authorization.RamRoleArn, + displayName: L("DisplayName:RamRoleArn"), + description: L("Description:RamRoleArn"), + isVisibleToClients: false, + isEncrypted: true + ), + new SettingDefinition( + AliyunSettingNames.Authorization.RegionId, + displayName: L("DisplayName:RegionId"), + description: L("Description:RegionId"), + isVisibleToClients: false + ), + new SettingDefinition( + AliyunSettingNames.Authorization.RoleSessionName, + displayName: L("DisplayName:RoleSessionName"), + description: L("Description:RoleSessionName"), + isVisibleToClients: false, + isEncrypted: true + ), + new SettingDefinition( + AliyunSettingNames.Authorization.UseSecurityTokenService, + defaultValue: true.ToString(), + displayName: L("DisplayName:UseSecurityTokenService"), + description: L("Description:UseSecurityTokenService"), + isVisibleToClients: false + ), + }; + } + + private ILocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/README.md b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/README.md new file mode 100644 index 000000000..6cb396563 --- /dev/null +++ b/aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/README.md @@ -0,0 +1,31 @@ +# LINGYUN.Abp.Aliyun + +阿里云sdk集成 + +参照:https://help.aliyun.com/document_detail/28763.html + +## 配置使用 + +模块按需引用 + +```csharp +[DependsOn(typeof(AbpAliyunModule))] +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字符串 + +## 其他 + +网络因素在高并发下可能会出现预期外的异常,考虑使用二级缓存 diff --git a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN.Abp.Tencent.csproj b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN.Abp.Tencent.csproj index 19704aabf..5f040edac 100644 --- a/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN.Abp.Tencent.csproj +++ b/aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINGYUN.Abp.Tencent.csproj @@ -19,9 +19,9 @@ - - - + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Aliyun.Authorization/LINGYUN.Abp.Aliyun.Authorization.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Aliyun.Authorization/LINGYUN.Abp.Aliyun.Authorization.csproj index 8e68ba218..81fe8585d 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Aliyun.Authorization/LINGYUN.Abp.Aliyun.Authorization.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Aliyun.Authorization/LINGYUN.Abp.Aliyun.Authorization.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj index 3119236d4..32aa5c104 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.Mvc.Validation/LINGYUN.Abp.AspNetCore.Mvc.Validation.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj index cc10d4f34..8aeee0ce1 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json/LINGYUN.Abp.AspNetCore.SignalR.Protocol.Json.csproj @@ -9,7 +9,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj index cbdb05b6b..871acf10b 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.AspNetCore.SignalR/LINGYUN.Abp.AspNetCore.SignalR.JwtToken.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs.Hangfire/LINGYUN.Abp.BackgroundJobs.Hangfire.csproj b/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs.Hangfire/LINGYUN.Abp.BackgroundJobs.Hangfire.csproj index fdeda0876..92fb9cee4 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs.Hangfire/LINGYUN.Abp.BackgroundJobs.Hangfire.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs.Hangfire/LINGYUN.Abp.BackgroundJobs.Hangfire.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs/LINGYUN.Abp.BackgroundJobs.csproj b/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs/LINGYUN.Abp.BackgroundJobs.csproj index 8cd142f6b..acd22f5f3 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs/LINGYUN.Abp.BackgroundJobs.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.BackgroundJobs/LINGYUN.Abp.BackgroundJobs.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN.Abp.BlobStoring.Aliyun.csproj b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN.Abp.BlobStoring.Aliyun.csproj index 5bd8a4d4e..23161cf58 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN.Abp.BlobStoring.Aliyun.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN.Abp.BlobStoring.Aliyun.csproj @@ -10,11 +10,11 @@ - + - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunModule.cs index 8930d080d..3da8694e0 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunModule.cs @@ -1,4 +1,4 @@ -using LINGYUN.Abp.Aliyun.Authorization; +using LINGYUN.Abp.Aliyun; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using System.Collections.Generic; @@ -9,7 +9,7 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun { [DependsOn( typeof(AbpBlobStoringModule), - typeof(AbpAliyunAuthorizationModule))] + typeof(AbpAliyunModule))] public class AbpBlobStoringAliyunModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs index 8499ae806..7a4ba3da7 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/AliyunBlobProvider.cs @@ -1,6 +1,4 @@ using Aliyun.OSS; -using LINGYUN.Abp.Aliyun.Authorization; -using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.IO; @@ -12,25 +10,24 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun { public class AliyunBlobProvider : BlobProviderBase, ITransientDependency { - protected AbpAliyunOptions Options { get; } + protected IOssClientFactory OssClientFactory { get; } protected IAliyunBlobNameCalculator AliyunBlobNameCalculator { get; } public AliyunBlobProvider( - IOptions options, + IOssClientFactory ossClientFactory, IAliyunBlobNameCalculator aliyunBlobNameCalculator) { - Options = options.Value; + OssClientFactory = ossClientFactory; AliyunBlobNameCalculator = aliyunBlobNameCalculator; } public override async Task DeleteAsync(BlobProviderDeleteArgs args) { + var ossClient = await GetOssClientAsync(args); var blobName = AliyunBlobNameCalculator.Calculate(args); - if (await BlobExistsAsync(args, blobName)) + if (await BlobExistsAsync(ossClient, args, blobName)) { - var ossClient = GetOssClient(args); - return ossClient.DeleteObject(GetBucketName(args), blobName).DeleteMarker; } @@ -39,21 +36,22 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun public override async Task ExistsAsync(BlobProviderExistsArgs args) { + var ossClient = await GetOssClientAsync(args); var blobName = AliyunBlobNameCalculator.Calculate(args); - return await BlobExistsAsync(args, blobName); + return await BlobExistsAsync(ossClient, args, blobName); } public override async Task GetOrNullAsync(BlobProviderGetArgs args) { + var ossClient = await GetOssClientAsync(args); var blobName = AliyunBlobNameCalculator.Calculate(args); - if (!await BlobExistsAsync(args, blobName)) + if (!await BlobExistsAsync(ossClient, args, blobName)) { return null; } - var ossClient = GetOssClient(args); var ossObject = ossClient.GetObject(GetBucketName(args), blobName); var memoryStream = new MemoryStream(); await ossObject.Content.CopyToAsync(memoryStream); @@ -62,20 +60,20 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun public override async Task SaveAsync(BlobProviderSaveArgs args) { + var ossClient = await GetOssClientAsync(args); var blobName = AliyunBlobNameCalculator.Calculate(args); var configuration = args.Configuration.GetAliyunConfiguration(); // 先检查Bucket if (configuration.CreateBucketIfNotExists) { - await CreateBucketIfNotExists(args, configuration.CreateBucketReferer); + await CreateBucketIfNotExists(ossClient, args, configuration.CreateBucketReferer); } var bucketName = GetBucketName(args); - var ossClient = GetOssClient(args); // 是否已存在 - if (await BlobExistsAsync(args, blobName)) + if (await BlobExistsAsync(ossClient, args, blobName)) { // 是否覆盖 if (!args.OverrideExisting) @@ -92,18 +90,17 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun ossClient.PutObject(bucketName, blobName, args.BlobStream); } - protected virtual OssClient GetOssClient(BlobProviderArgs args) + protected virtual async Task GetOssClientAsync(BlobProviderArgs args) { var configuration = args.Configuration.GetAliyunConfiguration(); - var ossClient = new OssClient(configuration.Endpoint, Options.AccessKeyId, Options.AccessKeySecret); + var ossClient = await OssClientFactory.CreateAsync(configuration); return ossClient; } - protected virtual async Task CreateBucketIfNotExists(BlobProviderArgs args, IList refererList = null) + protected virtual async Task CreateBucketIfNotExists(IOss ossClient, BlobProviderArgs args, IList refererList = null) { - if (! await BucketExistsAsync(args)) + if (! await BucketExistsAsync(ossClient, args)) { - var ossClient = GetOssClient(args); var bucketName = GetBucketName(args); var request = new CreateBucketRequest(bucketName) @@ -124,10 +121,9 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun } } - private async Task BlobExistsAsync(BlobProviderArgs args, string blobName) + private async Task BlobExistsAsync(IOss ossClient, BlobProviderArgs args, string blobName) { - var ossClient = GetOssClient(args); - var bucketExists = await BucketExistsAsync(args); + var bucketExists = await BucketExistsAsync(ossClient, args); if (bucketExists) { var objectExists = ossClient.DoesObjectExist(GetBucketName(args), blobName); @@ -137,9 +133,8 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun return false; } - private Task BucketExistsAsync(BlobProviderArgs args) + private Task BucketExistsAsync(IOss ossClient, BlobProviderArgs args) { - var ossClient = GetOssClient(args); var bucketExists = ossClient.DoesBucketExist(GetBucketName(args)); return Task.FromResult(bucketExists); diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/IOssClientFactory.cs b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/IOssClientFactory.cs new file mode 100644 index 000000000..6299df543 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/IOssClientFactory.cs @@ -0,0 +1,15 @@ +using Aliyun.OSS; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.BlobStoring.Aliyun +{ + public interface IOssClientFactory + { + /// + /// 通过配置信息构建Oss客户端调用 + /// + /// + /// + Task CreateAsync(AliyunBlobProviderConfiguration configuration); + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/OssClientFactory.cs b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/OssClientFactory.cs new file mode 100644 index 000000000..2446c3269 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/LINGYUN/Abp/BlobStoring/Aliyun/OssClientFactory.cs @@ -0,0 +1,50 @@ +using Aliyun.OSS; +using LINYUN.Abp.Aliyun; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Settings; + +namespace LINGYUN.Abp.BlobStoring.Aliyun +{ + public class OssClientFactory : AliyunClientFactory, IOssClientFactory, ITransientDependency + { + public OssClientFactory( + ISettingProvider settingProvider, + IDistributedCache cache) + : base(settingProvider, cache) + { + } + /// + /// 普通方式构建Oss客户端 + /// + /// + /// + /// + /// + /// + protected override IOss GetClient(AliyunBlobProviderConfiguration configuration, string regionId, string accessKeyId, string accessKeySecret) + { + return new OssClient( + configuration.Endpoint, + accessKeyId, + accessKeySecret); + } + /// + /// 通过用户安全令牌构建Oss客户端 + /// + /// + /// + /// + /// + /// + /// + protected override IOss GetSecurityTokenClient(AliyunBlobProviderConfiguration configuration, string regionId, string accessKeyId, string accessKeySecret, string securityToken) + { + return new OssClient( + configuration.Endpoint, + accessKeyId, + accessKeySecret, + securityToken); + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/README.md b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/README.md index 13f724716..7973666c7 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/README.md +++ b/aspnet-core/modules/common/LINGYUN.Abp.BlobStoring.Aliyun/README.md @@ -4,17 +4,13 @@ abp框架对象存储提供者**IBlobProvider**的阿里云实现 ## 配置使用 -模块按需引用,需要引用阿里云公共基础认证模块 +模块按需引用 事先定义**appsettings.json**文件 ```json { "Aliyun": { - "Auth": { - "AccessKeyId": "你的阿里云访问标识", - "AccessKeySecret": "你的阿里云访问密钥" - }, "OSS": { "BucketName": "你定义的BucketName", "Endpoint": "http://oss-cn-shanghai.aliyuncs.com", diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Core/LINGYUN.Abp.Core.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Core/LINGYUN.Abp.Core.csproj index c401a03a8..5732d8950 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Core/LINGYUN.Abp.Core.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Core/LINGYUN.Abp.Core.csproj @@ -9,7 +9,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock.Redis/LINGYUN.Abp.DistributedLock.Redis.csproj b/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock.Redis/LINGYUN.Abp.DistributedLock.Redis.csproj index fbab62171..e0168d93a 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock.Redis/LINGYUN.Abp.DistributedLock.Redis.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.DistributedLock.Redis/LINGYUN.Abp.DistributedLock.Redis.csproj @@ -12,7 +12,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Domain.Entities.Events/LINGYUN.Abp.Domain.Entities.Events.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Domain.Entities.Events/LINGYUN.Abp.Domain.Entities.Events.csproj index f774d6845..dc14f71ef 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Domain.Entities.Events/LINGYUN.Abp.Domain.Entities.Events.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Domain.Entities.Events/LINGYUN.Abp.Domain.Entities.Events.csproj @@ -6,7 +6,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj index 9931fc8cf..5275c8214 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.EventBus.CAP/LINGYUN.Abp.EventBus.CAP.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN.Abp.ExceptionHandling.Emailing.csproj b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN.Abp.ExceptionHandling.Emailing.csproj index d80b7d190..77104e773 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN.Abp.ExceptionHandling.Emailing.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Emailing/LINGYUN.Abp.ExceptionHandling.Emailing.csproj @@ -22,7 +22,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj index 1aa5e28c2..0880cbdfc 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling.Notifications/LINGYUN.Abp.ExceptionHandling.Notifications.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj index 35677d9c4..281d2f6ee 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.ExceptionHandling/LINGYUN.Abp.ExceptionHandling.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation.Redis/LINGYUN.Abp.Features.LimitValidation.Redis.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation.Redis/LINGYUN.Abp.Features.LimitValidation.Redis.csproj index fdf75a99c..aa58d59b2 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation.Redis/LINGYUN.Abp.Features.LimitValidation.Redis.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation.Redis/LINGYUN.Abp.Features.LimitValidation.Redis.csproj @@ -11,7 +11,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN.Abp.Features.LimitValidation.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN.Abp.Features.LimitValidation.csproj index 10038ca04..d302b764f 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN.Abp.Features.LimitValidation.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Features.LimitValidation/LINGYUN.Abp.Features.LimitValidation.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.MySqlStorage/LINGYUN.Abp.Hangfire.Storage.MySql.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.MySqlStorage/LINGYUN.Abp.Hangfire.Storage.MySql.csproj index 5aab1de28..919cff642 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.MySqlStorage/LINGYUN.Abp.Hangfire.Storage.MySql.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.MySqlStorage/LINGYUN.Abp.Hangfire.Storage.MySql.csproj @@ -9,7 +9,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/LINGYUN.Abp.Hangfire.Storage.SqlServer.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/LINGYUN.Abp.Hangfire.Storage.SqlServer.csproj index dfc4b7f3f..890b504a9 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/LINGYUN.Abp.Hangfire.Storage.SqlServer.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/LINGYUN.Abp.Hangfire.Storage.SqlServer.csproj @@ -9,7 +9,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj index 7d1c7f46e..453be1a8c 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.IM.SignalR/LINGYUN.Abp.IM.SignalR.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj index 6305b1d28..d26a007cd 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.IM/LINGYUN.Abp.IM.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.IdentityModel/LINGYUN.Abp.IdentityModel.csproj b/aspnet-core/modules/common/LINGYUN.Abp.IdentityModel/LINGYUN.Abp.IdentityModel.csproj index 09bed6604..877ed855e 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.IdentityModel/LINGYUN.Abp.IdentityModel.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.IdentityModel/LINGYUN.Abp.IdentityModel.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Amap/LINGYUN.Abp.Location.Amap.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location.Amap/LINGYUN.Abp.Location.Amap.csproj index cb6989441..0e1f1adbd 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location.Amap/LINGYUN.Abp.Location.Amap.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Amap/LINGYUN.Abp.Location.Amap.csproj @@ -17,9 +17,9 @@ - - - + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj index 557ecae61..748a3d54e 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj @@ -20,9 +20,9 @@ - - - + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj index 92cde904a..ca16f0cbe 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj @@ -20,9 +20,9 @@ - - - + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj index 10276192d..5d9485e92 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Location/LINGYUN.Abp.Location.csproj @@ -9,7 +9,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj index a2aeb7dab..84f8d27b4 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN.Abp.Notifications.SignalR.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/Hubs/NotificationsHub.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/Hubs/NotificationsHub.cs index 2259961b2..978c8ce6d 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/Hubs/NotificationsHub.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.SignalR/LINGYUN/Abp/Notifications/SignalR/Hubs/NotificationsHub.cs @@ -12,8 +12,7 @@ namespace LINGYUN.Abp.Notifications.SignalR.Hubs [Authorize] public class NotificationsHub : OnlineClientHubBase { - private INotificationStore _notificationStore; - protected INotificationStore NotificationStore => LazyGetRequiredService(ref _notificationStore); + protected INotificationStore NotificationStore => LazyServiceProvider.LazyGetRequiredService(); protected override async Task OnClientConnectedAsync(IOnlineClient client) { diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Sms/LINGYUN.Abp.Notifications.Sms.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Sms/LINGYUN.Abp.Notifications.Sms.csproj index 238177037..f9424ce39 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Sms/LINGYUN.Abp.Notifications.Sms.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications.Sms/LINGYUN.Abp.Notifications.Sms.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj index 380c62697..829638224 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN.Abp.Notifications.csproj @@ -8,9 +8,9 @@ - - - + + + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN.Abp.RealTime.SignalR.csproj b/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN.Abp.RealTime.SignalR.csproj index 491547548..1ec93e1d5 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN.Abp.RealTime.SignalR.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN.Abp.RealTime.SignalR.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN/Abp/RealTime/SignalR/Hubs/OnlineClientHubBase.cs b/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN/Abp/RealTime/SignalR/Hubs/OnlineClientHubBase.cs index 6701cd9cd..7d92182ca 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN/Abp/RealTime/SignalR/Hubs/OnlineClientHubBase.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.RealTime.SignalR/LINGYUN/Abp/RealTime/SignalR/Hubs/OnlineClientHubBase.cs @@ -9,11 +9,8 @@ namespace LINGYUN.Abp.RealTime.SignalR { public abstract class OnlineClientHubBase : AbpHub, IClient { - private IWebClientInfoProvider _webClientInfoProvider; - protected IWebClientInfoProvider WebClientInfoProvider => LazyGetRequiredService(ref _webClientInfoProvider); - - private IOnlineClientManager _onlineClientManager; - protected IOnlineClientManager OnlineClientManager => LazyGetRequiredService(ref _onlineClientManager); + protected IWebClientInfoProvider WebClientInfoProvider => LazyServiceProvider.LazyGetRequiredService(); + protected IOnlineClientManager OnlineClientManager => LazyServiceProvider.LazyGetRequiredService(); public override async Task OnConnectedAsync() { diff --git a/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj b/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj index 8e68ba218..81fe8585d 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.RealTime/LINGYUN.Abp.RealTime.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj index f21a00115..9d679e2d4 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Rules/LINGYUN.Abp.Rules.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Settings/LINGYUN.Abp.Settings.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Settings/LINGYUN.Abp.Settings.csproj index 2e45cbad6..d08a1f029 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Settings/LINGYUN.Abp.Settings.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Settings/LINGYUN.Abp.Settings.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN.Abp.Sms.Aliyun.csproj b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN.Abp.Sms.Aliyun.csproj index 59e8c7874..8c5ee9c87 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN.Abp.Sms.Aliyun.csproj +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN.Abp.Sms.Aliyun.csproj @@ -19,14 +19,11 @@ - - - - + - + diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AbpAliyunSmsModule.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AbpAliyunSmsModule.cs index cad4c903a..fa606577f 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AbpAliyunSmsModule.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AbpAliyunSmsModule.cs @@ -1,7 +1,6 @@ -using LINGYUN.Abp.Aliyun.Authorization; +using LINGYUN.Abp.Aliyun; +using LINYUN.Abp.Aliyun.Localization; using LINYUN.Abp.Sms.Aliyun.Localization; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Json; using Volo.Abp.Localization; using Volo.Abp.Modularity; using Volo.Abp.Sms; @@ -10,17 +9,12 @@ using Volo.Abp.VirtualFileSystem; namespace LINYUN.Abp.Sms.Aliyun { [DependsOn( - typeof(AbpSmsModule), - typeof(AbpJsonModule), - typeof(AbpLocalizationModule), - typeof(AbpAliyunAuthorizationModule))] + typeof(AbpSmsModule), + typeof(AbpAliyunModule))] public class AbpAliyunSmsModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - var configuration = context.Services.GetConfiguration(); - Configure(configuration.GetSection("Aliyun:Sms")); - Configure(options => { options.FileSets.AddEmbedded(); @@ -30,6 +24,7 @@ namespace LINYUN.Abp.Sms.Aliyun { options.Resources .Add("en") + .AddBaseTypes(typeof(AliyunResource)) .AddVirtualJson("/LINYUN/Abp/Sms/Aliyun/Localization/Resources"); }); } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsException.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsException.cs index 9b8795eed..7e80ff3bd 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsException.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsException.cs @@ -1,28 +1,12 @@ -using Microsoft.Extensions.Logging; -using Volo.Abp; -using Volo.Abp.ExceptionHandling; -using Volo.Abp.Localization; -using Volo.Abp.Logging; +using LINYUN.Abp.Aliyun; namespace LINYUN.Abp.Sms.Aliyun { - public class AliyunSmsException : AbpException, IHasErrorCode, ILocalizeErrorMessage, IHasLogLevel + public class AliyunSmsException : AbpAliyunException { public AliyunSmsException(string code, string message) - :base(message) + :base(code, message) { - Code = code; - LogLevel = LogLevel.Warning; - } - - public LogLevel LogLevel { get; set; } - - public string Code { get; } - - public string LocalizeMessage(LocalizationContext context) - { - return AliyunSmsResponse.GetErrorMessage(Code, Message) - .Localize(context.LocalizerFactory); } } } diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs deleted file mode 100644 index 19f3e04a4..000000000 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsOptions.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace LINYUN.Abp.Sms.Aliyun -{ - public class AliyunSmsOptions - { - /// - /// 区域Id - /// - public string RegionId { get; set; } = "default"; - /// - /// 阿里云sms服务域名 - /// - public string Domain { get; set; } = "dysmsapi.aliyuncs.com"; - /// - /// 调用方法名称 - /// - public string ActionName { get; set; } = "SendSms"; - /// - /// 默认版本号 - /// - public string Version { get; set; } = "2017-05-25"; - /// - /// 默认签名 - /// - public string DefaultSignName { get; set; } - /// - /// 默认短信模板号 - /// - public string DefaultTemplateCode { get; set; } - /// - /// 开发人员号码,当应用处于开发模式时,默认所有信息都会发送到此号码 - /// - public string DeveloperPhoneNumber { get; set; } = "13800138000"; - /// - /// 展示错误给客户端 - /// - public bool VisableErrorToClient { get; set; } = false; - } -} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs index 51d1df128..695eb9d80 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs @@ -1,19 +1,17 @@ using Aliyun.Acs.Core; using Aliyun.Acs.Core.Exceptions; using Aliyun.Acs.Core.Http; -using Aliyun.Acs.Core.Profile; -using LINGYUN.Abp.Aliyun.Authorization; -using LINYUN.Abp.Sms.Aliyun.Localization; +using LINYUN.Abp.Aliyun; +using LINYUN.Abp.Sms.Aliyun.Settings; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Localization; -using Microsoft.Extensions.Options; using System; using System.Text; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.DependencyInjection; using Volo.Abp.Json; +using Volo.Abp.Settings; using Volo.Abp.Sms; namespace LINYUN.Abp.Sms.Aliyun @@ -22,69 +20,71 @@ namespace LINYUN.Abp.Sms.Aliyun [ExposeServices(typeof(ISmsSender), typeof(AliyunSmsSender))] public class AliyunSmsSender : ISmsSender { - protected AbpAliyunOptions AuthOptions { get; } - protected AliyunSmsOptions Options { get; } protected IJsonSerializer JsonSerializer { get; } - protected IHostEnvironment Environment { get; } + protected ISettingProvider SettingProvider { get; } protected IServiceProvider ServiceProvider { get; } + protected IAcsClientFactory AcsClientFactory { get; } public AliyunSmsSender( - IHostEnvironment environment, IJsonSerializer jsonSerializer, + ISettingProvider settingProvider, IServiceProvider serviceProvider, - IOptions options, - IOptions authOptions) + IAcsClientFactory acsClientFactory) { - Options = options.Value; - AuthOptions = authOptions.Value; - - Environment = environment; JsonSerializer = jsonSerializer; + SettingProvider = settingProvider; ServiceProvider = serviceProvider; + AcsClientFactory = acsClientFactory; } - public Task SendAsync(SmsMessage smsMessage) + public virtual async Task SendAsync(SmsMessage smsMessage) { + var domain = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.Domain); + var action = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.ActionName); + var version = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.Version); + + Check.NotNullOrWhiteSpace(domain, AliyunSmsSettingNames.Sms.Domain); + Check.NotNullOrWhiteSpace(action, AliyunSmsSettingNames.Sms.ActionName); + Check.NotNullOrWhiteSpace(version, AliyunSmsSettingNames.Sms.Version); + CommonRequest request = new CommonRequest { Method = MethodType.POST, - Domain = Options.Domain, - Action = Options.ActionName, - Version = Options.Version + Domain = domain, + Action = action, + Version = version }; - TryAddTemplateCode(request, smsMessage); - TryAddSignName(request, smsMessage); - TryAddSendPhone(request, smsMessage); + await TryAddTemplateCodeAsync(request, smsMessage); + await TryAddSignNameAsync(request, smsMessage); + await TryAddSendPhoneAsync(request, smsMessage); + TryAddTemplateParam(request, smsMessage); try { - IClientProfile profile = DefaultProfile.GetProfile(Options.RegionId, AuthOptions.AccessKeyId, AuthOptions.AccessKeySecret); - IAcsClient client = new DefaultAcsClient(profile); + var client = await AcsClientFactory.CreateAsync(); CommonResponse response = client.GetCommonResponse(request); var responseContent = Encoding.Default.GetString(response.HttpResponse.Content); var aliyunResponse = JsonSerializer.Deserialize(responseContent); if (!aliyunResponse.IsSuccess()) { - if (Options.VisableErrorToClient) + if (await SettingProvider.IsTrueAsync(AliyunSmsSettingNames.Sms.VisableErrorToClient)) { - throw new AliyunSmsException(aliyunResponse.Code, aliyunResponse.Message); + throw new UserFriendlyException(aliyunResponse.Code, aliyunResponse.Message); } - throw new AbpException($"Text message sending failed, code:{aliyunResponse.Code}, message:{aliyunResponse.Message}!"); + throw new AliyunSmsException(aliyunResponse.Code, $"Text message sending failed, code:{aliyunResponse.Code}, message:{aliyunResponse.Message}!"); } } catch(ServerException se) { - throw new AbpException("Sending text messages to aliyun server is abnormal", se); + throw new AliyunSmsException(se.ErrorCode, $"Sending text messages to aliyun server is abnormal,type: {se.ErrorType}, error: {se.ErrorMessage}"); } catch(ClientException ce) { - throw new AbpException("A client exception occurred in sending SMS messages", ce); + throw new AliyunSmsException(ce.ErrorCode, $"A client exception occurred in sending SMS messages,type: {ce.ErrorType}, error: {ce.ErrorMessage}"); } - - return Task.CompletedTask; } - private void TryAddTemplateCode(CommonRequest request, SmsMessage smsMessage) + private async Task TryAddTemplateCodeAsync(CommonRequest request, SmsMessage smsMessage) { if (smsMessage.Properties.TryGetValue("TemplateCode", out object template) && template != null) { @@ -93,12 +93,13 @@ namespace LINYUN.Abp.Sms.Aliyun } else { - Check.NotNullOrWhiteSpace(Options.DefaultTemplateCode, nameof(Options.DefaultTemplateCode)); - request.AddQueryParameters("TemplateCode", Options.DefaultTemplateCode); + var defaultTemplateCode = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultTemplateCode); + Check.NotNullOrWhiteSpace(defaultTemplateCode, "TemplateCode"); + request.AddQueryParameters("TemplateCode", defaultTemplateCode); } } - private void TryAddSignName(CommonRequest request, SmsMessage smsMessage) + private async Task TryAddSignNameAsync(CommonRequest request, SmsMessage smsMessage) { if (smsMessage.Properties.TryGetValue("SignName", out object signName) && signName != null) { @@ -107,21 +108,23 @@ namespace LINYUN.Abp.Sms.Aliyun } else { - Check.NotNullOrWhiteSpace(Options.DefaultSignName, nameof(Options.DefaultSignName)); - request.AddQueryParameters("SignName", Options.DefaultSignName); + var defaultSignName = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultSignName); + Check.NotNullOrWhiteSpace(defaultSignName, "SignName"); + request.AddQueryParameters("SignName", defaultSignName); } } - private void TryAddSendPhone(CommonRequest request, SmsMessage smsMessage) + private async Task TryAddSendPhoneAsync(CommonRequest request, SmsMessage smsMessage) { - if (Environment.IsDevelopment()) + if (smsMessage.PhoneNumber.IsNullOrWhiteSpace()) { + var defaultPhoneNumber = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultPhoneNumber); // check phone number length... Check.NotNullOrWhiteSpace( - Options.DeveloperPhoneNumber, - nameof(Options.DeveloperPhoneNumber), + defaultPhoneNumber, + AliyunSmsSettingNames.Sms.DefaultPhoneNumber, maxLength: 11, minLength: 11); - request.AddQueryParameters("PhoneNumbers", Options.DeveloperPhoneNumber); + request.AddQueryParameters("PhoneNumbers", defaultPhoneNumber); } else { diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Localization/Resources/zh-Hans.json b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Localization/Resources/zh-Hans.json index f2ba1b6a5..61a23fb63 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Localization/Resources/zh-Hans.json @@ -1,6 +1,20 @@ { "culture": "zh-Hans", "texts": { + "DisplayName:ActionName": "阿里云身份认证凭据", + "Description:ActionName": "阿里云身份认证凭据", + "DisplayName:DefaultSignName": "地域ID", + "Description:DefaultSignName": "正在使用的地域ID", + "DisplayName:DefaultTemplateCode": "AccessKey Id", + "Description:DefaultTemplateCode": "访问密钥标识", + "DisplayName:DeveloperPhoneNumber": "AccessKey Secret", + "Description:DeveloperPhoneNumber": "访问密钥", + "DisplayName:Domain": "阿里云sms服务域名", + "Description:Domain": "使用STS Token访问", + "DisplayName:Version": "角色全局资源描述符", + "Description:Version": "格式:acs:ram::$accountID:role/$roleName/$RoleSessionName,详情见阿里云访问控制API", + "DisplayName:RoleSessionName": "角色全局资源描述符", + "Description:RoleSessionName": "格式:acs:ram::$accountID:role/$roleName/$RoleSessionName,详情见阿里云访问控制API", "SendMessageFailed": "发送短信错误:{0}", "SMS_SIGNATURE_SCENE_ILLEGAL": "短信所使用签名场景非法", "DENY_IP_RANGE": "源IP地址所在的地区被禁用", diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingNames.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingNames.cs new file mode 100644 index 000000000..8496a3c75 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingNames.cs @@ -0,0 +1,43 @@ +using LINYUN.Abp.Aliyun.Settings; + +namespace LINYUN.Abp.Sms.Aliyun.Settings +{ + public static class AliyunSmsSettingNames + { + /// + /// 短信服务 + /// + public class Sms + { + public const string Prefix = AliyunSettingNames.Prefix + ".Sms"; + /// + /// 阿里云sms服务域名 + /// + public const string Domain = Prefix + ".Domain"; + /// + /// 调用方法名称 + /// + public const string ActionName = Prefix + ".ActionName"; + /// + /// 默认版本号 + /// + public const string Version = Prefix + ".Version"; + /// + /// 默认签名 + /// + public const string DefaultSignName = Prefix + ".DefaultSignName"; + /// + /// 默认短信模板号 + /// + public const string DefaultTemplateCode = Prefix + ".DefaultTemplateCode"; + /// + /// 默认号码 + /// + public const string DefaultPhoneNumber = Prefix + ".DefaultPhoneNumber"; + /// + /// 展示错误给客户端 + /// + public const string VisableErrorToClient = Prefix + ".VisableErrorToClient"; + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingProvider.cs b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingProvider.cs new file mode 100644 index 000000000..f575101f1 --- /dev/null +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingProvider.cs @@ -0,0 +1,74 @@ +using LINYUN.Abp.Aliyun.Localization; +using Volo.Abp.Localization; +using Volo.Abp.Settings; + +namespace LINYUN.Abp.Sms.Aliyun.Settings +{ + public class AliyunSmsSettingProvider : SettingDefinitionProvider + { + public override void Define(ISettingDefinitionContext context) + { + context.Add(CreateAliyunSettings()); + } + + private SettingDefinition[] CreateAliyunSettings() + { + return new SettingDefinition[] + { + new SettingDefinition( + AliyunSmsSettingNames.Sms.ActionName, + defaultValue: "SendSms", + displayName: L("DisplayName:ActionName"), + description: L("Description:ActionName"), + isVisibleToClients: false + ), + new SettingDefinition( + AliyunSmsSettingNames.Sms.DefaultSignName, + displayName: L("DisplayName:DefaultSignName"), + description: L("Description:DefaultSignName"), + isVisibleToClients: false, + isEncrypted: true + ), + new SettingDefinition( + AliyunSmsSettingNames.Sms.DefaultTemplateCode, + displayName: L("DisplayName:DefaultTemplateCode"), + description: L("Description:DefaultTemplateCode"), + isVisibleToClients: false, + isEncrypted: true + ), + new SettingDefinition( + AliyunSmsSettingNames.Sms.DefaultPhoneNumber, + displayName: L("DisplayName:DefaultPhoneNumber"), + description: L("Description:DefaultPhoneNumber"), + isVisibleToClients: false + ), + new SettingDefinition( + AliyunSmsSettingNames.Sms.Domain, + defaultValue: "dysmsapi.aliyuncs.com", + displayName: L("DisplayName:Domain"), + description: L("Description:Domain"), + isVisibleToClients: false + ), + new SettingDefinition( + AliyunSmsSettingNames.Sms.Version, + defaultValue: "2017-05-25", + displayName: L("DisplayName:Version"), + description: L("Description:Version"), + isVisibleToClients: false + ), + new SettingDefinition( + AliyunSmsSettingNames.Sms.VisableErrorToClient, + defaultValue: false.ToString(), + displayName: L("DisplayName:VisableErrorToClient"), + description: L("Description:VisableErrorToClient"), + isVisibleToClients: false + ) + }; + } + + private ILocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/README.md b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/README.md index 110feb919..d3377eda8 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/README.md +++ b/aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/README.md @@ -4,30 +4,7 @@ abp框架短信发送接口**ISmsSender**的阿里云实现 ## 配置使用 -模块按需引用,需要引用阿里云公共基础认证模块 - -事先定义**appsettings.json**文件 - -```json -{ - "Aliyun": { - "Auth": { - "AccessKeyId": "你的阿里云访问标识", - "AccessKeySecret": "你的阿里云访问密钥" - }, - "Sms": { - "RegionId": "cn-hangzhou", - "Domain": "dysmsapi.aliyuncs.com", - "Version": "2017-05-25", - "DefaultSignName": "你的阿里云短信签名,SmsMessage.Properties[SignName]不存在则使用DefaultSignName", - "DefaultTemplateCode": "你的阿里云短信模板,SmsMessage.Properties[TemplateCode]不存在则使用DefaultTemplateCode", - "DeveloperPhoneNumber": "这是用于在开发模式下的短信号码,用于统一接收短信", - "VisableErrorToClient": true - } - } -} - -``` +模块按需引用 ```csharp [DependsOn(typeof(AbpAliyunSmsModule))] @@ -35,4 +12,17 @@ public class YouProjectModule : AbpModule { // other } -``` \ No newline at end of file +``` +## 配置项说明 + +* AliyunSettingNames.Sms.Domain 可选,阿里云sms服务域名,默认 dysmsapi.aliyuncs.com +* AliyunSettingNames.Sms.ActionName 必须,调用方法名称,默认 SendSms +* AliyunSettingNames.Sms.Version 必须,R默认版本号,默认 2017-05-25 +* AliyunSettingNames.Sms.DefaultSignName 可选,默认签名,当用户调用未传递签名时,默认使用的短信签名 +* AliyunSettingNames.Sms.DefaultTemplateCode 可选,默认短信模板号,,当用户调用未传递短信模板时,默认使用的短信模板 +* AliyunSettingNames.Sms.DefaultPhoneNumber 可选,默认发送号码,当用户调用未传递接收者号码时,默认使用的接收人号码 +* AliyunSettingNames.Sms.VisableErrorToClient 可选,展示错误给客户端,当调用短信接口出现错误时,是否返回错误明细给客户端,默认 false + +## 其他 + +网络因素在高并发下可能会出现预期外的异常,考虑使用二级缓存 diff --git a/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/AbpEncryptionConsoleModule.cs b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/AbpEncryptionConsoleModule.cs new file mode 100644 index 000000000..9f4f8ed21 --- /dev/null +++ b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/AbpEncryptionConsoleModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Modularity; +using Volo.Abp.Security; + +namespace LINGYUN.Abp.Encryption.Console +{ + [DependsOn( + typeof(AbpSecurityModule))] + public class AbpEncryptionConsoleModule : AbpModule + { + + } +} diff --git a/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/LINGYUN.Abp.Encryption.Console.csproj b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/LINGYUN.Abp.Encryption.Console.csproj new file mode 100644 index 000000000..29ae0498b --- /dev/null +++ b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/LINGYUN.Abp.Encryption.Console.csproj @@ -0,0 +1,12 @@ + + + + Exe + netcoreapp3.1 + + + + + + + diff --git a/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/Program.cs b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/Program.cs new file mode 100644 index 000000000..f5daec401 --- /dev/null +++ b/aspnet-core/modules/console/LINGYUN.Abp.Encryption.Console/Program.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using System; +using Volo.Abp; +using Volo.Abp.Security.Encryption; +using static System.Console; + +namespace LINGYUN.Abp.Encryption.Console +{ + class Program + { + static void Main(string[] args) + { + WriteLine("Hello World!"); + + var application = AbpApplicationFactory.Create(); + + application.Initialize(); + + WriteLine("D:解密 E:加密"); + + var opt = ReadLine(); + bool en = false; + if ("E".Equals(opt, StringComparison.InvariantCultureIgnoreCase)) + { + en = true; + WriteLine("请输入需要加密的字符串"); + } + else + { + WriteLine("请输入需要解密的字符串"); + } + + var sourceChr = ReadLine(); + var encryptionService = application.ServiceProvider.GetRequiredService(); + WriteLine(en ? encryptionService.Encrypt(sourceChr) : encryptionService.Decrypt(sourceChr)); + + application.Shutdown(); + + ReadKey(); + } + } +} diff --git a/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN.Abp.FeatureManagement.Client.csproj b/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN.Abp.FeatureManagement.Client.csproj index 776c89510..879e66df9 100644 --- a/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN.Abp.FeatureManagement.Client.csproj +++ b/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN.Abp.FeatureManagement.Client.csproj @@ -13,8 +13,8 @@ - - + + diff --git a/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN/Abp/FeatureManagement/Client/ClientFeatureManagementProvider.cs b/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN/Abp/FeatureManagement/Client/ClientFeatureManagementProvider.cs index 477b41cbe..7a3d08f4a 100644 --- a/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN/Abp/FeatureManagement/Client/ClientFeatureManagementProvider.cs +++ b/aspnet-core/modules/features/LINGYUN.Abp.FeatureManagement.Client/LINGYUN/Abp/FeatureManagement/Client/ClientFeatureManagementProvider.cs @@ -1,4 +1,5 @@ using LINGYUN.Abp.Features.Client; +using System.Threading.Tasks; using Volo.Abp.Clients; using Volo.Abp.DependencyInjection; using Volo.Abp.FeatureManagement; @@ -20,14 +21,15 @@ namespace LINGYUN.Abp.FeatureManagement.Client CurrentClient = currentClient; } - protected override string NormalizeProviderKey(string providerKey) + + protected override Task NormalizeProviderKeyAsync(string providerKey) { if (providerKey != null) { - return providerKey; + base.NormalizeProviderKeyAsync(providerKey); } - return CurrentClient.Id; + return Task.FromResult(CurrentClient.Id); } } } diff --git a/aspnet-core/modules/features/LINGYUN.Abp.Features.Client/LINGYUN.Abp.Features.Client.csproj b/aspnet-core/modules/features/LINGYUN.Abp.Features.Client/LINGYUN.Abp.Features.Client.csproj index 6f544ae74..a14dea1e4 100644 --- a/aspnet-core/modules/features/LINGYUN.Abp.Features.Client/LINGYUN.Abp.Features.Client.csproj +++ b/aspnet-core/modules/features/LINGYUN.Abp.Features.Client/LINGYUN.Abp.Features.Client.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Application.Contracts/LINGYUN.Abp.FileManagement.Application.Contracts.csproj b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Application.Contracts/LINGYUN.Abp.FileManagement.Application.Contracts.csproj index 35aa0c87e..029cba6fd 100644 --- a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Application.Contracts/LINGYUN.Abp.FileManagement.Application.Contracts.csproj +++ b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Application.Contracts/LINGYUN.Abp.FileManagement.Application.Contracts.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain.Shared/LINGYUN.Abp.FileManagement.Domain.Shared.csproj b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain.Shared/LINGYUN.Abp.FileManagement.Domain.Shared.csproj index dc41aa331..03eadc873 100644 --- a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain.Shared/LINGYUN.Abp.FileManagement.Domain.Shared.csproj +++ b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain.Shared/LINGYUN.Abp.FileManagement.Domain.Shared.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain/LINGYUN.Abp.FileManagement.Domain.csproj b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain/LINGYUN.Abp.FileManagement.Domain.csproj index de0d82219..c7a67d189 100644 --- a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain/LINGYUN.Abp.FileManagement.Domain.csproj +++ b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.Domain/LINGYUN.Abp.FileManagement.Domain.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.HttpApi/LINGYUN.Abp.FileManagement.HttpApi.csproj b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.HttpApi/LINGYUN.Abp.FileManagement.HttpApi.csproj index 060fced9e..66266371b 100644 --- a/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.HttpApi/LINGYUN.Abp.FileManagement.HttpApi.csproj +++ b/aspnet-core/modules/file-management/LINGYUN.Abp.FileManagement.HttpApi/LINGYUN.Abp.FileManagement.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN.Abp.Identity.Application.Contracts.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN.Abp.Identity.Application.Contracts.csproj index e24a4dd43..2888c5374 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN.Abp.Identity.Application.Contracts.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN.Abp.Identity.Application.Contracts.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN.Abp.Identity.Application.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN.Abp.Identity.Application.csproj index 068bfe272..5e5e70002 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN.Abp.Identity.Application.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN.Abp.Identity.Application.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN.Abp.Identity.Domain.Shared.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN.Abp.Identity.Domain.Shared.csproj index 23ac9f397..dc5289416 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN.Abp.Identity.Domain.Shared.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain.Shared/LINGYUN.Abp.Identity.Domain.Shared.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN.Abp.Identity.Domain.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN.Abp.Identity.Domain.csproj index c6061d689..85c5dc7a2 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN.Abp.Identity.Domain.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN.Abp.Identity.Domain.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj index 1973553ea..56bff19ab 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN.Abp.Identity.EntityFrameworkCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs index 3af41a808..3ec97058d 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityRoleRepository.cs @@ -1,5 +1,4 @@ using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; using System; using System.Collections.Generic; using System.Linq; @@ -26,7 +25,7 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - return await DbSet.IncludeDetails(includeDetails) + return await (await GetDbSetAsync()).IncludeDetails(includeDetails) .Where(role => roleIds.Contains(role.Id)) .ToListAsync(GetCancellationToken(cancellationToken)); } @@ -36,8 +35,9 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore bool includeDetails = false, CancellationToken cancellationToken = default) { - var query = from roleOU in DbContext.Set() - join ou in DbContext.OrganizationUnits.IncludeDetails(includeDetails) on roleOU.OrganizationUnitId equals ou.Id + var dbContext = await GetDbContextAsync(); + var query = from roleOU in dbContext.Set() + join ou in dbContext.OrganizationUnits.IncludeDetails(includeDetails) on roleOU.OrganizationUnitId equals ou.Id where roleOU.RoleId == id select ou; @@ -48,8 +48,8 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore List organizationUnitIds, CancellationToken cancellationToken = default) { - var query = from roleOu in DbContext.Set() - join user in DbSet on roleOu.RoleId equals user.Id + var query = from roleOu in (await GetDbContextAsync()).Set() + join user in (await GetDbSetAsync()) on roleOu.RoleId equals user.Id where organizationUnitIds.Contains(roleOu.OrganizationUnitId) select user; return await query.ToListAsync(GetCancellationToken(cancellationToken)); @@ -59,8 +59,8 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore Guid organizationUnitId, CancellationToken cancellationToken = default) { - var query = from roleOu in DbContext.Set() - join user in DbSet on roleOu.RoleId equals user.Id + var query = from roleOu in (await GetDbContextAsync()).Set() + join user in (await GetDbSetAsync()) on roleOu.RoleId equals user.Id where roleOu.OrganizationUnitId == organizationUnitId select user; return await query.ToListAsync(GetCancellationToken(cancellationToken)); @@ -70,9 +70,10 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore string code, CancellationToken cancellationToken = default) { - var query = from roleOU in DbContext.Set() - join user in DbSet on roleOU.RoleId equals user.Id - join ou in DbContext.Set() on roleOU.OrganizationUnitId equals ou.Id + var dbContext = await GetDbContextAsync(); + var query = from roleOU in dbContext.Set() + join user in (await GetDbSetAsync()) on roleOU.RoleId equals user.Id + join ou in dbContext.Set() on roleOU.OrganizationUnitId equals ou.Id where ou.Code.StartsWith(code) select user; return await query.ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs index 87ab1bec6..27daf74df 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.EntityFrameworkCore/LINGYUN/Abp/Identity/EntityFrameworkCore/EfCoreIdentityUserRepository.cs @@ -24,7 +24,7 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore string phoneNumber, CancellationToken cancellationToken = default) { - return await DbSet.IncludeDetails(false) + return await (await GetDbSetAsync()).IncludeDetails(false) .AnyAsync(user => user.PhoneNumber == phoneNumber, GetCancellationToken(cancellationToken)); } @@ -33,7 +33,7 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore string phoneNumber, CancellationToken cancellationToken = default) { - return await DbSet.IncludeDetails(false) + return await (await GetDbSetAsync()).IncludeDetails(false) .AnyAsync(user => user.PhoneNumber == phoneNumber && user.PhoneNumberConfirmed, GetCancellationToken(cancellationToken)); } @@ -42,7 +42,7 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore string normalizedEmail, CancellationToken cancellationToken = default) { - return await DbSet.IncludeDetails(false) + return await (await GetDbSetAsync()).IncludeDetails(false) .AnyAsync(user => user.NormalizedEmail == normalizedEmail && user.EmailConfirmed, GetCancellationToken(cancellationToken)); } @@ -53,7 +53,7 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore bool includeDetails = false, CancellationToken cancellationToken = default) { - return await DbSet.IncludeDetails(includeDetails) + return await (await GetDbSetAsync()).IncludeDetails(includeDetails) .Where(user => user.PhoneNumber == phoneNumber && user.PhoneNumberConfirmed == isConfirmed) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } @@ -64,7 +64,7 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - return await DbSet.IncludeDetails(includeDetails) + return await (await GetDbSetAsync()).IncludeDetails(includeDetails) .Where(user => userIds.Contains(user.Id)) .ToListAsync(GetCancellationToken(cancellationToken)); } @@ -78,8 +78,9 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - var query = from userOU in DbContext.Set() - join ou in DbContext.OrganizationUnits.IncludeDetails(includeDetails) on userOU.OrganizationUnitId equals ou.Id + var dbContext = await GetDbContextAsync(); + var query = from userOU in dbContext.Set() + join ou in dbContext.OrganizationUnits.IncludeDetails(includeDetails) on userOU.OrganizationUnitId equals ou.Id where userOU.UserId == id select ou; @@ -95,8 +96,9 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - var query = from userOu in DbContext.Set() - join user in DbSet on userOu.UserId equals user.Id + var dbContext = await GetDbContextAsync(); + var query = from userOu in dbContext.Set() + join user in (await GetDbSetAsync()) on userOu.UserId equals user.Id where userOu.OrganizationUnitId == organizationUnitId select user; return await query @@ -115,8 +117,9 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - var query = from userOu in DbContext.Set() - join user in DbSet on userOu.UserId equals user.Id + var dbContext = await GetDbContextAsync(); + var query = from userOu in dbContext.Set() + join user in (await GetDbSetAsync()) on userOu.UserId equals user.Id where userOu.OrganizationUnitId == organizationUnitId select user; return await query @@ -134,8 +137,9 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - var query = from userOu in DbContext.Set() - join user in DbSet on userOu.UserId equals user.Id + var dbContext = await GetDbContextAsync(); + var query = from userOu in dbContext.Set() + join user in (await GetDbSetAsync()) on userOu.UserId equals user.Id where organizationUnitIds.Contains(userOu.OrganizationUnitId) select user; return await query @@ -154,8 +158,9 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - var query = from userOu in DbContext.Set() - join user in DbSet on userOu.UserId equals user.Id + var dbContext = await GetDbContextAsync(); + var query = from userOu in dbContext.Set() + join user in (await GetDbSetAsync()) on userOu.UserId equals user.Id where organizationUnitIds.Contains(userOu.OrganizationUnitId) select user; return await query @@ -173,9 +178,10 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - var query = from userOu in DbContext.Set() - join user in DbSet on userOu.UserId equals user.Id - join ou in DbContext.Set() on userOu.OrganizationUnitId equals ou.Id + var dbContext = await GetDbContextAsync(); + var query = from userOu in dbContext.Set() + join user in (await GetDbSetAsync()) on userOu.UserId equals user.Id + join ou in dbContext.Set() on userOu.OrganizationUnitId equals ou.Id where ou.Code.StartsWith(code) select user; return await query @@ -194,9 +200,10 @@ namespace LINGYUN.Abp.Identity.EntityFrameworkCore CancellationToken cancellationToken = default ) { - var query = from userOu in DbContext.Set() - join user in DbSet on userOu.UserId equals user.Id - join ou in DbContext.Set() on userOu.OrganizationUnitId equals ou.Id + var dbContext = await GetDbContextAsync(); + var query = from userOu in dbContext.Set() + join user in (await GetDbSetAsync()) on userOu.UserId equals user.Id + join ou in dbContext.Set() on userOu.OrganizationUnitId equals ou.Id where ou.Code.StartsWith(code) select user; return await query diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi.Client/LINGYUN.Abp.Identity.HttpApi.Client.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi.Client/LINGYUN.Abp.Identity.HttpApi.Client.csproj index d2ad8e5f6..5f86ecf27 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi.Client/LINGYUN.Abp.Identity.HttpApi.Client.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi.Client/LINGYUN.Abp.Identity.HttpApi.Client.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj index baf87b29c..44b4ae0c1 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.HttpApi/LINGYUN.Abp.Identity.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.PermissionManagement.Domain.Identity/LINGYUN.Abp.PermissionManagement.Domain.Identity.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.PermissionManagement.Domain.Identity/LINGYUN.Abp.PermissionManagement.Domain.Identity.csproj index a5ca9a0e7..57172469d 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.PermissionManagement.Domain.Identity/LINGYUN.Abp.PermissionManagement.Domain.Identity.csproj +++ b/aspnet-core/modules/identity/LINGYUN.Abp.PermissionManagement.Domain.Identity/LINGYUN.Abp.PermissionManagement.Domain.Identity.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN.Abp.IdentityServer.Application.Contracts.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN.Abp.IdentityServer.Application.Contracts.csproj index db6211c62..d14df26a6 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN.Abp.IdentityServer.Application.Contracts.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application.Contracts/LINGYUN.Abp.IdentityServer.Application.Contracts.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj index 866340bd7..6b37495dd 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN.Abp.IdentityServer.Application.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN/Abp/IdentityServer/AbpIdentityServerAppServiceBase.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN/Abp/IdentityServer/AbpIdentityServerAppServiceBase.cs index 1f4387577..212ca6f99 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN/Abp/IdentityServer/AbpIdentityServerAppServiceBase.cs +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Application/LINGYUN/Abp/IdentityServer/AbpIdentityServerAppServiceBase.cs @@ -7,8 +7,7 @@ namespace LINGYUN.Abp.IdentityServer { public abstract class AbpIdentityServerAppServiceBase : ApplicationService { - private IPermissionChecker _permissionChecker; - protected IPermissionChecker PermissionChecker => LazyGetRequiredService(ref _permissionChecker); + protected IPermissionChecker PermissionChecker => LazyServiceProvider.LazyGetRequiredService(); protected AbpIdentityServerAppServiceBase() { LocalizationResource = typeof(AbpIdentityServerResource); diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj index ffbcc2dcc..aa240f97c 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN.Abp.IdentityServer.Domain.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN/Abp/IdentityServer/ApiScopes/IApiScopeRepository.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN/Abp/IdentityServer/ApiScopes/IApiScopeRepository.cs deleted file mode 100644 index b62176e12..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Domain/LINGYUN/Abp/IdentityServer/ApiScopes/IApiScopeRepository.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; - -namespace LINGYUN.Abp.IdentityServer.ApiScopes -{ - public interface IApiScopeRepository : Volo.Abp.IdentityServer.ApiScopes.IApiScopeRepository - { - Task GetCountAsync( - string filter = null, - CancellationToken cancellationToken = default - ); - } -} diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj index 4e0b8a84f..3e01887a6 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/ApiResources/EfCoreApiResourceRepository.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/ApiResources/EfCoreApiResourceRepository.cs index 97f964b96..536323d76 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/ApiResources/EfCoreApiResourceRepository.cs +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/ApiResources/EfCoreApiResourceRepository.cs @@ -26,7 +26,7 @@ namespace LINGYUN.Abp.IdentityServer.ApiResources public virtual async Task> GetNamesAsync(CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Select(x => x.Name) .Distinct() .ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/ApiScopes/EfCoreApiScopeRepository.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/ApiScopes/EfCoreApiScopeRepository.cs deleted file mode 100644 index ec374a637..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/ApiScopes/EfCoreApiScopeRepository.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.IdentityServer.ApiScopes; -using Volo.Abp.IdentityServer.EntityFrameworkCore; - -namespace LINGYUN.Abp.IdentityServer.ApiScopes -{ - [Dependency(ServiceLifetime.Transient)] - [ExposeServices( - typeof(IApiScopeRepository), - typeof(ApiScopeRepository), - typeof(Volo.Abp.IdentityServer.ApiScopes.IApiScopeRepository))] - public class EfCoreApiScopeRepository : ApiScopeRepository, IApiScopeRepository - { - public EfCoreApiScopeRepository(IDbContextProvider dbContextProvider) - : base(dbContextProvider) - { - } - - public virtual async Task GetCountAsync( - string filter = null, - CancellationToken cancellationToken = default) - { - return await DbSet - .WhereIf(!filter.IsNullOrWhiteSpace(), x => - x.Name.Contains(filter) || x.DisplayName.Contains(filter) || x.Description.Contains(filter)) - .CountAsync(GetCancellationToken(cancellationToken)); - } - } -} diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/Grants/EfCorePersistentGrantRepository.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/Grants/EfCorePersistentGrantRepository.cs index fd7bbead5..ac64cb3a4 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/Grants/EfCorePersistentGrantRepository.cs +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/Grants/EfCorePersistentGrantRepository.cs @@ -27,7 +27,7 @@ namespace LINGYUN.Abp.IdentityServer.Grants public virtual async Task GetCountAsync(string subjectId = null, string filter = null, CancellationToken cancellation = default) { - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId.Equals(subjectId)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Type.Contains(filter) || x.ClientId.Contains(filter) || x.Key.Contains(filter)) @@ -36,7 +36,7 @@ namespace LINGYUN.Abp.IdentityServer.Grants public virtual async Task> GetListAsync(string subjectId = null, string filter = null, string sorting = "CreationTime", int skipCount = 1, int maxResultCount = 10, CancellationToken cancellation = default) { - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(!subjectId.IsNullOrWhiteSpace(), x => x.SubjectId.Equals(subjectId)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Type.Contains(filter) || x.ClientId.Contains(filter) || x.Key.Contains(filter)) diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/IdentityResources/EfCoreIdentityResourceRepository.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/IdentityResources/EfCoreIdentityResourceRepository.cs index ea7b5c9a7..1046ffa37 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/IdentityResources/EfCoreIdentityResourceRepository.cs +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.EntityFrameworkCore/LINGYUN/Abp/IdentityServer/IdentityResources/EfCoreIdentityResourceRepository.cs @@ -26,7 +26,7 @@ namespace LINGYUN.Abp.IdentityServer.IdentityResources public virtual async Task> GetNamesAsync(CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Select(x => x.Name) .Distinct() .ToListAsync(GetCancellationToken(cancellationToken)); diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj index d1eab35e5..123b992c7 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.HttpApi/LINGYUN.Abp.IdentityServer.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj index 68530becc..5fe1ab6bd 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.SmsValidator/LINGYUN.Abp.IdentityServer.SmsValidator.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat/LINGYUN.Abp.IdentityServer.WeChat.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat/LINGYUN.Abp.IdentityServer.WeChat.csproj index 879b4377d..0a35a847e 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat/LINGYUN.Abp.IdentityServer.WeChat.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChat/LINGYUN.Abp.IdentityServer.WeChat.csproj @@ -13,7 +13,7 @@ - + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN.Abp.IdentityServer.WeChatValidator.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN.Abp.IdentityServer.WeChatValidator.csproj index 1a51d50f8..c1cd2b4f4 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN.Abp.IdentityServer.WeChatValidator.csproj +++ b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.WeChatValidator/LINGYUN.Abp.IdentityServer.WeChatValidator.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj index f50af2e01..ad07b4683 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application.Contracts/LINGYUN.Abp.MessageService.Application.Contracts.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN.Abp.MessageService.Application.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN.Abp.MessageService.Application.csproj index 49fa05a5c..5c637f6a4 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN.Abp.MessageService.Application.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN.Abp.MessageService.Application.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs index 8883332ec..c6933a947 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Application/LINGYUN/Abp/MessageService/Chat/ChatAppService.cs @@ -11,8 +11,7 @@ namespace LINGYUN.Abp.MessageService.Chat { public class ChatAppService : ApplicationService, IChatAppService { - private IMessageSender _messageSender; - protected IMessageSender MessageSender => LazyGetRequiredService(ref _messageSender); + protected IMessageSender MessageSender => LazyServiceProvider.LazyGetRequiredService(); private readonly IUserGroupStore _userGroupStore; private readonly IMessageStore _messageStore; @@ -127,7 +126,7 @@ namespace LINGYUN.Abp.MessageService.Chat public virtual async Task SendMessageAsync(ChatMessage input) { // TODO:向其他租户发送消息? - input.TenantId = input.TenantId ?? CurrentTenant.Id; + input.TenantId ??= CurrentTenant.Id; await MessageSender.SendMessageAsync(input); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj index 74846aee4..790353043 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain.Shared/LINGYUN.Abp.MessageService.Domain.Shared.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN.Abp.MessageService.Domain.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN.Abp.MessageService.Domain.csproj index f549fe7a8..9e348ae96 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN.Abp.MessageService.Domain.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN.Abp.MessageService.Domain.csproj @@ -18,11 +18,11 @@ - - - - - + + + + + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj index 51d0dd571..f8156ac6d 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs index 1a8a69d3b..aa6d6c13b 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs @@ -27,7 +27,7 @@ namespace LINGYUN.Abp.MessageService.Chat long id, CancellationToken cancellationToken = default) { - return await DbContext.Set() + return await (await GetDbContextAsync()).Set() .Where(x => x.MessageId.Equals(id)) .AsNoTracking() .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -44,7 +44,7 @@ namespace LINGYUN.Abp.MessageService.Chat CancellationToken cancellationToken = default) { sorting = reverse ? sorting + " desc" : sorting; - var groupMessages = await DbContext.Set() + var groupMessages = await (await GetDbContextAsync()).Set() .Distinct() .Where(x => x.GroupId.Equals(groupId)) .WhereIf(type != null, x => x.Type.Equals(type)) @@ -63,7 +63,7 @@ namespace LINGYUN.Abp.MessageService.Chat MessageType? type = null, CancellationToken cancellationToken = default) { - var groupMessagesCount = await DbContext.Set() + var groupMessagesCount = await (await GetDbContextAsync()).Set() .Distinct() .Where(x => x.GroupId.Equals(groupId)) .WhereIf(type != null, x => x.Type.Equals(type)) @@ -84,7 +84,7 @@ namespace LINGYUN.Abp.MessageService.Chat CancellationToken cancellationToken = default) { sorting = reverse ? sorting + " desc" : sorting; - var groupMessages = await DbContext.Set() + var groupMessages = await (await GetDbContextAsync()).Set() .Distinct() .Where(x => x.GroupId.Equals(groupId) && x.CreatorId.Equals(sendUserId)) .WhereIf(type != null, x => x.Type.Equals(type)) @@ -104,7 +104,7 @@ namespace LINGYUN.Abp.MessageService.Chat MessageType? type = null, CancellationToken cancellationToken = default) { - var groupMessagesCount = await DbContext.Set() + var groupMessagesCount = await (await GetDbContextAsync()).Set() .Where(x => x.GroupId.Equals(groupId) && x.CreatorId.Equals(sendUserId)) .WhereIf(type != null, x => x.Type.Equals(type)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter)) @@ -118,7 +118,7 @@ namespace LINGYUN.Abp.MessageService.Chat MessageType? type = null, CancellationToken cancellationToken = default) { - return await DbContext.Set() + return await (await GetDbContextAsync()).Set() .Where(x => x.GroupId.Equals(groupId)) .WhereIf(type != null, x => x.Type.Equals(type)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter)) @@ -132,7 +132,7 @@ namespace LINGYUN.Abp.MessageService.Chat MessageType? type = null, CancellationToken cancellationToken = default) { - return await DbContext.Set() + return await (await GetDbContextAsync()).Set() .Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) || x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId)) .WhereIf(type != null, x => x.Type.Equals(type)) @@ -144,7 +144,7 @@ namespace LINGYUN.Abp.MessageService.Chat long id, CancellationToken cancellationToken = default) { - return await DbContext.Set() + return await (await GetDbContextAsync()).Set() .Where(x => x.MessageId.Equals(id)) .AsNoTracking() .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -160,7 +160,8 @@ namespace LINGYUN.Abp.MessageService.Chat sorting ??= nameof(LastChatMessage.SendTime); sorting = reverse ? sorting + " DESC" : sorting; - var groupMsgQuery = DbContext.Set() + var dbContext = await GetDbContextAsync(); + var groupMsgQuery = dbContext.Set() .Where(msg => msg.ReceiveUserId == userId || msg.CreatorId == userId) .GroupBy(msg => new { msg.CreatorId, msg.ReceiveUserId }) .Select(msg => new @@ -170,7 +171,7 @@ namespace LINGYUN.Abp.MessageService.Chat MessageId = msg.Max(x => x.MessageId) }); - var userMessageQuery = from msg in DbContext.Set() + var userMessageQuery = from msg in dbContext.Set() join gMsg in groupMsgQuery on msg.MessageId equals gMsg.MessageId select new LastChatMessage @@ -204,7 +205,7 @@ namespace LINGYUN.Abp.MessageService.Chat { sorting ??= nameof(UserMessage.MessageId); sorting = reverse ? sorting + " desc" : sorting; - var userMessages = await DbContext.Set() + var userMessages = await (await GetDbContextAsync()).Set() .Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) || x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId)) .WhereIf(type != null, x => x.Type.Equals(type)) @@ -224,7 +225,7 @@ namespace LINGYUN.Abp.MessageService.Chat MessageType? type = null, CancellationToken cancellationToken = default) { - var userMessagesCount = await DbContext.Set() + var userMessagesCount = await (await GetDbContextAsync()).Set() .Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) || x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId)) .WhereIf(type != null, x => x.Type.Equals(type)) @@ -238,7 +239,7 @@ namespace LINGYUN.Abp.MessageService.Chat GroupMessage groupMessage, CancellationToken cancellationToken = default) { - await DbContext.Set() + await (await GetDbContextAsync()).Set() .AddAsync(groupMessage, GetCancellationToken(cancellationToken)); } @@ -246,7 +247,7 @@ namespace LINGYUN.Abp.MessageService.Chat UserMessage userMessage, CancellationToken cancellationToken = default) { - await DbContext.Set() + await (await GetDbContextAsync()).Set() .AddAsync(userMessage, GetCancellationToken(cancellationToken)); } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs index ff63e0edd..637df17ef 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatCardRepository.cs @@ -22,14 +22,14 @@ namespace LINGYUN.Abp.MessageService.Chat public virtual async Task CheckUserIdExistsAsync(Guid userId, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .AnyAsync(ucc => ucc.UserId == userId, GetCancellationToken(cancellationToken)); } public virtual async Task GetMemberAsync(Guid findUserId, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Where(ucc => ucc.UserId == findUserId) .Select(ucc => ucc.ToUserCard()) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -37,7 +37,7 @@ namespace LINGYUN.Abp.MessageService.Chat public virtual async Task GetMemberCountAsync(string findUserName = "", int? startAge = null, int? endAge = null, Sex? sex = null, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName)) .WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value) .WhereIf(endAge.HasValue, ucc => ucc.Age <= endAge.Value) @@ -49,7 +49,7 @@ namespace LINGYUN.Abp.MessageService.Chat { sorting ??= nameof(UserChatCard.UserId); sorting = reverse ? sorting + " desc" : sorting; - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(!findUserName.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(findUserName)) .WhereIf(startAge.HasValue, ucc => ucc.Age >= startAge.Value) .WhereIf(endAge.HasValue, ucc => ucc.Age <= endAge.Value) diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs index d03fe28c3..7cd10cc41 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatFriendRepository.cs @@ -22,7 +22,7 @@ namespace LINGYUN.Abp.MessageService.Chat public virtual async Task FindByUserFriendIdAsync(Guid userId, Guid friendId, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Where(ucf => ucf.UserId == userId && ucf.FrientId == friendId) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } @@ -34,9 +34,10 @@ namespace LINGYUN.Abp.MessageService.Chat CancellationToken cancellationToken = default) { sorting = reverse ? sorting + " DESC" : sorting; - - var userFriendQuery = from ucf in DbContext.Set() - join ucc in DbContext.Set() + + var dbContext = await GetDbContextAsync(); + var userFriendQuery = from ucf in dbContext.Set() + join ucc in dbContext.Set() // on ucf.FrientId equals ucc.UserId // 查询双向好友的 on ucf.UserId equals ucc.UserId where ucf.UserId == userId && ucf.Status == UserFriendStatus.Added @@ -66,8 +67,9 @@ namespace LINGYUN.Abp.MessageService.Chat public virtual async Task GetMemberAsync(Guid userId, Guid friendId, CancellationToken cancellationToken = default) { - var userFriendQuery = from ucf in DbContext.Set() - join ucc in DbContext.Set() + var dbContext = await GetDbContextAsync(); + var userFriendQuery = from ucf in dbContext.Set() + join ucc in dbContext.Set() on ucf.FrientId equals ucc.UserId where ucf.UserId == userId && ucf.FrientId == friendId && ucf.Status == UserFriendStatus.Added select new UserFriend @@ -96,12 +98,14 @@ namespace LINGYUN.Abp.MessageService.Chat public virtual async Task> GetMembersAsync(Guid userId, string filter = "", string sorting = nameof(UserChatFriend.UserId), bool reverse = false, int skipCount = 0, int maxResultCount = 10, CancellationToken cancellationToken = default) { sorting = reverse ? sorting + " desc" : sorting; + + var dbContext = await GetDbContextAsync(); // 过滤用户资料 - var userChatCardQuery = DbContext.Set() + var userChatCardQuery = dbContext.Set() .WhereIf(!filter.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(filter) || ucc.NickName.Contains(filter)); // 过滤好友资料 - var userChatFriendQuery = DbContext.Set() + var userChatFriendQuery = dbContext.Set() .Where(ucf => ucf.Status == UserFriendStatus.Added) .WhereIf(!filter.IsNullOrWhiteSpace(), ucf => ucf.RemarkName.Contains(filter)); @@ -141,11 +145,12 @@ namespace LINGYUN.Abp.MessageService.Chat int maxResultCount = 10, CancellationToken cancellationToken = default) { - var userReceiveMsgQuery = DbContext.Set() + var dbContext = await GetDbContextAsync(); + var userReceiveMsgQuery = dbContext.Set() .Where(um => um.ReceiveUserId == userId); - var userFriendQuery = from ucf in DbContext.Set() - join ucc in DbContext.Set() + var userFriendQuery = from ucf in dbContext.Set() + join ucc in dbContext.Set() on ucf.FrientId equals ucc.UserId join um in userReceiveMsgQuery on ucc.UserId equals um.CreatorId @@ -177,10 +182,11 @@ namespace LINGYUN.Abp.MessageService.Chat public virtual async Task GetMembersCountAsync(Guid userId, string filter = "", CancellationToken cancellationToken = default) { - var userChatCardQuery = DbContext.Set() + var dbContext = await GetDbContextAsync(); + var userChatCardQuery = dbContext.Set() .WhereIf(!filter.IsNullOrWhiteSpace(), ucc => ucc.UserName.Contains(filter) || ucc.NickName.Contains(filter)); - var userChatFriendQuery = DbContext.Set() + var userChatFriendQuery = dbContext.Set() .Where(ucf => ucf.Status == UserFriendStatus.Added) .WhereIf(!filter.IsNullOrWhiteSpace(), ucf => ucf.RemarkName.Contains(filter)); @@ -199,14 +205,14 @@ namespace LINGYUN.Abp.MessageService.Chat Guid frientId, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .AnyAsync(ucf => ucf.UserId == userId && ucf.FrientId == frientId && ucf.Status == UserFriendStatus.Added, GetCancellationToken(cancellationToken)); } public virtual async Task IsAddedAsync(Guid userId, Guid frientId, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .AnyAsync(ucf => ucf.UserId == userId && ucf.FrientId == frientId, GetCancellationToken(cancellationToken)); } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatSettingRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatSettingRepository.cs index bfc4563c7..a1a64f6ed 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatSettingRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreUserChatSettingRepository.cs @@ -21,14 +21,15 @@ namespace LINGYUN.Abp.MessageService.Chat public async Task FindByUserIdAsync(Guid userId, CancellationToken cancellationToken = default) { - return await DbSet.Where(x => x.UserId.Equals(userId)) + return await (await GetDbSetAsync()).Where(x => x.UserId.Equals(userId)) .AsNoTracking() .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } public async Task UserHasOpendImAsync(Guid userId, CancellationToken cancellationToken = default) { - return await DbSet.AnyAsync(x => x.UserId.Equals(userId), GetCancellationToken(cancellationToken)); + return await (await GetDbSetAsync()) + .AnyAsync(x => x.UserId.Equals(userId), GetCancellationToken(cancellationToken)); } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs index 0a3a5ec85..dc1fac73a 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreGroupRepository.cs @@ -24,7 +24,7 @@ namespace LINGYUN.Abp.MessageService.Group long id, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Where(x => x.GroupId.Equals(id)) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } @@ -33,10 +33,11 @@ namespace LINGYUN.Abp.MessageService.Group long id, CancellationToken cancellationToken = default) { - var groupAdmins = await (from gp in DbContext.Set() - join ucg in DbContext.Set() + var dbContext = await GetDbContextAsync(); + var groupAdmins = await (from gp in dbContext.Set() + join ucg in dbContext.Set() on gp.GroupId equals ucg.GroupId - join ugc in DbContext.Set() + join ugc in dbContext.Set() on ucg.UserId equals ugc.UserId where ugc.IsAdmin select ugc) @@ -49,7 +50,7 @@ namespace LINGYUN.Abp.MessageService.Group Guid formUserId, CancellationToken cancellationToken = default) { - var userHasBlack = await DbContext.Set() + var userHasBlack = await (await GetDbContextAsync()).Set() .AnyAsync(x => x.GroupId.Equals(id) && x.ShieldUserId.Equals(formUserId), GetCancellationToken(cancellationToken)); return userHasBlack; } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreUserChatGroupRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreUserChatGroupRepository.cs index 46cb100ad..39635bc6d 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreUserChatGroupRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Group/EfCoreUserChatGroupRepository.cs @@ -28,12 +28,13 @@ namespace LINGYUN.Abp.MessageService.Group Guid userId, CancellationToken cancellationToken = default) { - var cardQuery = from gp in DbContext.Set() - join ucg in DbContext.Set() + var dbContext = await GetDbContextAsync(); + var cardQuery = from gp in dbContext.Set() + join ucg in dbContext.Set() on gp.GroupId equals ucg.GroupId - join ugc in DbContext.Set() + join ugc in dbContext.Set() on ucg.UserId equals ugc.UserId - join uc in DbContext.Set() + join uc in dbContext.Set() on ugc.UserId equals uc.UserId where gp.GroupId == groupId && ugc.UserId == userId select new GroupUserCard @@ -67,12 +68,14 @@ namespace LINGYUN.Abp.MessageService.Group { sorting ??= nameof(UserChatCard.UserId); sorting = reverse ? sorting + " desc" : sorting; - var cardQuery = from gp in DbContext.Set() - join ucg in DbContext.Set() + + var dbContext = await GetDbContextAsync(); + var cardQuery = from gp in dbContext.Set() + join ucg in dbContext.Set() on gp.GroupId equals ucg.GroupId - join ugc in DbContext.Set() + join ugc in dbContext.Set() on ucg.UserId equals ugc.UserId - join uc in DbContext.Set() + join uc in dbContext.Set() on ugc.UserId equals uc.UserId where gp.GroupId == groupId select new GroupUserCard @@ -102,12 +105,13 @@ namespace LINGYUN.Abp.MessageService.Group long groupId, CancellationToken cancellationToken = default) { - var cardQuery = from gp in DbContext.Set() - join ucg in DbContext.Set() + var dbContext = await GetDbContextAsync(); + var cardQuery = from gp in dbContext.Set() + join ucg in dbContext.Set() on gp.GroupId equals ucg.GroupId - join ugc in DbContext.Set() + join ugc in dbContext.Set() on ucg.UserId equals ugc.UserId - join uc in DbContext.Set() + join uc in dbContext.Set() on ugc.UserId equals uc.UserId where gp.GroupId == groupId select ucg; @@ -121,7 +125,7 @@ namespace LINGYUN.Abp.MessageService.Group Guid userId, CancellationToken cancellationToken = default) { - return await DbContext.Set() + return await (await GetDbContextAsync()).Set() .AnyAsync(ucg => ucg.GroupId == groupId && ucg.UserId == userId, GetCancellationToken(cancellationToken)); } @@ -130,8 +134,9 @@ namespace LINGYUN.Abp.MessageService.Group Guid userId, CancellationToken cancellationToken = default) { - var groupQuery = from gp in DbContext.Set() - join ucg in DbContext.Set() + var dbContext = await GetDbContextAsync(); + var groupQuery = from gp in dbContext.Set() + join ucg in dbContext.Set() on gp.GroupId equals ucg.GroupId where ucg.UserId.Equals(userId) group ucg by new diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs index 310956eae..b6cc1d0ae 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs @@ -23,22 +23,23 @@ namespace LINGYUN.Abp.MessageService.Notifications int batchCount, CancellationToken cancellationToken = default) { - var batchDeleteNoticeWithIds = await DbSet + var dbSet = await GetDbSetAsync(); + var batchDeleteNoticeWithIds = await dbSet .Where(x => x.ExpirationTime <= DateTime.Now) .Take(batchCount) .Select(x => new Notification(x.Id)) .AsNoTracking() .ToArrayAsync(GetCancellationToken(cancellationToken)); - DbSet.AttachRange(batchDeleteNoticeWithIds); - DbSet.RemoveRange(batchDeleteNoticeWithIds); + dbSet.AttachRange(batchDeleteNoticeWithIds); + dbSet.RemoveRange(batchDeleteNoticeWithIds); } public async Task GetByIdAsync( long notificationId, CancellationToken cancellationToken = default) { - return await DbSet.Where(x => x.NotificationId.Equals(notificationId)) + return await (await GetDbSetAsync()).Where(x => x.NotificationId.Equals(notificationId)) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs index 2d410e561..6464527aa 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreUserNotificationRepository.cs @@ -27,7 +27,7 @@ namespace LINGYUN.Abp.MessageService.Notifications long notificationId, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .AnyAsync(x => x.NotificationId.Equals(notificationId) && x.UserId.Equals(userId), GetCancellationToken(cancellationToken)); } @@ -36,7 +36,7 @@ namespace LINGYUN.Abp.MessageService.Notifications IEnumerable userNotifications, CancellationToken cancellationToken = default) { - await DbSet.AddRangeAsync(userNotifications, GetCancellationToken(cancellationToken)); + await (await GetDbSetAsync()).AddRangeAsync(userNotifications, GetCancellationToken(cancellationToken)); } public virtual async Task GetByIdAsync( @@ -44,7 +44,7 @@ namespace LINGYUN.Abp.MessageService.Notifications long notificationId, CancellationToken cancellationToken = default) { - var userNofitication = await DbSet + var userNofitication = await (await GetDbSetAsync()) .Where(x => x.NotificationId.Equals(notificationId) && x.UserId.Equals(userId)) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -57,12 +57,13 @@ namespace LINGYUN.Abp.MessageService.Notifications int maxResultCount = 10, CancellationToken cancellationToken = default) { - var userNotifilerQuery = DbContext.Set() + var dbContext = await GetDbContextAsync(); + var userNotifilerQuery = dbContext.Set() .Where(x => x.UserId == userId) .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); var notifilerQuery = from un in userNotifilerQuery - join n in DbContext.Set() + join n in dbContext.Set() on un.NotificationId equals n.NotificationId select n; @@ -79,12 +80,13 @@ namespace LINGYUN.Abp.MessageService.Notifications NotificationReadState? readState = null, CancellationToken cancellationToken = default) { - var userNotifilerQuery = DbContext.Set() + var dbContext = await GetDbContextAsync(); + var userNotifilerQuery = dbContext.Set() .Where(x => x.UserId == userId) .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); var notifilerQuery = from un in userNotifilerQuery - join n in DbContext.Set() + join n in dbContext.Set() on un.NotificationId equals n.NotificationId select n; @@ -108,13 +110,13 @@ namespace LINGYUN.Abp.MessageService.Notifications sorting ??= nameof(Notification.CreationTime); sorting = reverse ? sorting + " DESC" : sorting; - - var userNotifilerQuery = DbContext.Set() + var dbContext = await GetDbContextAsync(); + var userNotifilerQuery = dbContext.Set() .Where(x => x.UserId == userId) .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); var notifilerQuery = from un in userNotifilerQuery - join n in DbContext.Set() + join n in dbContext.Set() on un.NotificationId equals n.NotificationId select n; diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs index 7a613198b..1f187299d 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Subscriptions/EfCoreUserSubscribeRepository.cs @@ -21,12 +21,12 @@ namespace LINGYUN.Abp.MessageService.Subscriptions { } - public async Task> GetUserSubscribesAsync( + public virtual async Task> GetUserSubscribesAsync( string notificationName, IEnumerable userIds = null, CancellationToken cancellationToken = default) { - var userSubscribes = await DbSet + var userSubscribes = await (await GetDbSetAsync()) .Distinct() .Where(x => x.NotificationName.Equals(notificationName)) .WhereIf(userIds != null, x => userIds.Contains(x.UserId)) @@ -36,12 +36,12 @@ namespace LINGYUN.Abp.MessageService.Subscriptions return userSubscribes; } - public async Task GetUserSubscribeAsync( + public virtual async Task GetUserSubscribeAsync( string notificationName, Guid userId, CancellationToken cancellationToken = default) { - var userSubscribe = await DbSet + var userSubscribe = await (await GetDbSetAsync()) .Where(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName)) .AsNoTracking() .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -49,11 +49,11 @@ namespace LINGYUN.Abp.MessageService.Subscriptions return userSubscribe; } - public async Task> GetUserSubscribesAsync( + public virtual async Task> GetUserSubscribesAsync( Guid userId, CancellationToken cancellationToken = default) { - var userSubscribeNames = await DbSet + var userSubscribeNames = await (await GetDbSetAsync()) .Distinct() .Where(x => x.UserId.Equals(userId)) .Select(x => x.NotificationName) @@ -62,11 +62,11 @@ namespace LINGYUN.Abp.MessageService.Subscriptions return userSubscribeNames; } - public async Task> GetUserSubscribesByNameAsync( + public virtual async Task> GetUserSubscribesByNameAsync( string userName, CancellationToken cancellationToken = default) { - var userSubscribeNames = await DbSet + var userSubscribeNames = await (await GetDbSetAsync()) .Distinct() .Where(x => x.UserName.Equals(userName)) .AsNoTracking() @@ -75,11 +75,11 @@ namespace LINGYUN.Abp.MessageService.Subscriptions return userSubscribeNames; } - public async Task> GetUserSubscribesAsync( + public virtual async Task> GetUserSubscribesAsync( string notificationName, CancellationToken cancellationToken = default) { - var subscribeUsers = await DbSet + var subscribeUsers = await (await GetDbSetAsync()) .Distinct() .Where(x => x.NotificationName.Equals(notificationName)) .Select(x => x.UserId) @@ -88,28 +88,27 @@ namespace LINGYUN.Abp.MessageService.Subscriptions return subscribeUsers; } - public async Task InsertUserSubscriptionAsync( + public virtual async Task InsertUserSubscriptionAsync( IEnumerable userSubscribes, CancellationToken cancellationToken = default) { - await DbSet.AddRangeAsync(userSubscribes, GetCancellationToken(cancellationToken)); + await (await GetDbSetAsync()).AddRangeAsync(userSubscribes, GetCancellationToken(cancellationToken)); } - public async Task DeleteUserSubscriptionAsync( + public virtual async Task DeleteUserSubscriptionAsync( string notificationName, CancellationToken cancellationToken = default) { - var userSubscribes = await DbSet.Where(x => x.NotificationName.Equals(notificationName)) + var userSubscribes = await (await GetDbSetAsync()).Where(x => x.NotificationName.Equals(notificationName)) .ToListAsync(GetCancellationToken(cancellationToken)); - DbSet.RemoveRange(userSubscribes); + (await GetDbSetAsync()).RemoveRange(userSubscribes); } - public Task DeleteUserSubscriptionAsync( + public virtual async Task DeleteUserSubscriptionAsync( IEnumerable userSubscribes, CancellationToken cancellationToken = default) { - DbSet.RemoveRange(userSubscribes); - return Task.CompletedTask; + await DeleteManyAsync(userSubscribes); } public virtual async Task DeleteUserSubscriptionAsync( @@ -122,12 +121,12 @@ namespace LINGYUN.Abp.MessageService.Subscriptions GetCancellationToken(cancellationToken)); } - public async Task UserSubscribeExistsAysnc( + public virtual async Task UserSubscribeExistsAysnc( string notificationName, Guid userId, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .AnyAsync(x => x.UserId.Equals(userId) && x.NotificationName.Equals(notificationName), GetCancellationToken(cancellationToken)); } @@ -139,7 +138,7 @@ namespace LINGYUN.Abp.MessageService.Subscriptions int maxResultCount = 10, CancellationToken cancellationToken = default) { - var userSubscribes = await DbSet + var userSubscribes = await (await GetDbSetAsync()) .Distinct() .Where(x => x.UserId.Equals(userId)) .OrderBy(sorting ?? nameof(UserSubscribe.Id)) @@ -154,7 +153,7 @@ namespace LINGYUN.Abp.MessageService.Subscriptions Guid userId, CancellationToken cancellationToken = default) { - var userSubscribedCount = await DbSet + var userSubscribedCount = await (await GetDbSetAsync()) .Distinct() .Where(x => x.UserId.Equals(userId)) .LongCountAsync(GetCancellationToken(cancellationToken)); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi.Client/LINGYUN.Abp.MessageService.HttpApi.Client.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi.Client/LINGYUN.Abp.MessageService.HttpApi.Client.csproj index 00819fc84..a22b863ee 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi.Client/LINGYUN.Abp.MessageService.HttpApi.Client.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi.Client/LINGYUN.Abp.MessageService.HttpApi.Client.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj index 54820c15e..efed61de9 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.HttpApi/LINGYUN.Abp.MessageService.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain/LINGYUN.Abp.PermissionManagement.Domain.csproj b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain/LINGYUN.Abp.PermissionManagement.Domain.csproj index 966050cb1..53ae029f6 100644 --- a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain/LINGYUN.Abp.PermissionManagement.Domain.csproj +++ b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain/LINGYUN.Abp.PermissionManagement.Domain.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj index 4b61d89b0..19f8552ca 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Application.Contracts/LINGYUN.Platform.Application.Contracts.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj index e5ef89e26..b5516ebfb 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain.Shared/LINGYUN.Platform.Domain.Shared.csproj @@ -18,7 +18,7 @@ - + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj index d034c158e..d6afff7e4 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/BlobStoring/BlobStoringManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/BlobStoring/BlobStoringManager.cs index 7059caab7..424daf440 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/BlobStoring/BlobStoringManager.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/BlobStoring/BlobStoringManager.cs @@ -11,11 +11,8 @@ namespace LINGYUN.Platform.BlobStoring { public class BlobStoringManager : DomainService { - private IBlobRepository _blobRepository; - protected IBlobRepository BlobRepository => LazyGetRequiredService(ref _blobRepository); - - private IBlobContainerRepository _containerRepository; - protected IBlobContainerRepository ContainerRepository => LazyGetRequiredService(ref _containerRepository); + protected IBlobRepository BlobRepository => LazyServiceProvider.LazyGetRequiredService(); + protected IBlobContainerRepository ContainerRepository => LazyServiceProvider.LazyGetRequiredService(); protected IBlobContainerFactory BlobContainerFactory { get; } protected IBlobContainerConfigurationProvider BlobContainerConfigurationProvider { get; } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataDictionaryDataSeeder.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataDictionaryDataSeeder.cs index cbcaabbef..747a2f986 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataDictionaryDataSeeder.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Datas/DataDictionaryDataSeeder.cs @@ -3,18 +3,22 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Platform.Datas { public class DataDictionaryDataSeeder : IDataDictionaryDataSeeder, ITransientDependency { + protected ICurrentTenant CurrentTenant { get; } protected IGuidGenerator GuidGenerator { get; } protected IDataRepository DataRepository { get; } public DataDictionaryDataSeeder( + ICurrentTenant currentTenant, IGuidGenerator guidGenerator, IDataRepository dataRepository) { + CurrentTenant = currentTenant; GuidGenerator = guidGenerator; DataRepository = dataRepository; } @@ -28,23 +32,26 @@ namespace LINGYUN.Platform.Datas Guid? tenantId = null, CancellationToken cancellationToken = default) { - var data = await DataRepository.FindByNameAsync(name, cancellationToken: cancellationToken); - - if (data == null) + using (CurrentTenant.Change(tenantId)) { - data = new Data( - GuidGenerator.Create(), - name, - code, - displayName, - description, - parentId, - tenantId); + var data = await DataRepository.FindByNameAsync(name, cancellationToken: cancellationToken); - data = await DataRepository.InsertAsync(data); - } + if (data == null) + { + data = new Data( + GuidGenerator.Create(), + name, + code, + displayName, + description, + parentId, + tenantId); - return data; + data = await DataRepository.InsertAsync(data); + } + + return data; + } } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IRoleMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IRoleMenuRepository.cs index 816c24924..39021a203 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IRoleMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IRoleMenuRepository.cs @@ -20,9 +20,12 @@ namespace LINGYUN.Platform.Menus string menuName, CancellationToken cancellationToken = default); - Task SetRoleMenusAsync( + Task> GetListByRoleNameAsync( string roleName, - IEnumerable menuIds, + CancellationToken cancellationToken = default); + + Task InsertAsync( + IEnumerable roleMenus, CancellationToken cancellationToken = default); } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserMenuRepository.cs index 28b2c8ced..a9c82b393 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/IUserMenuRepository.cs @@ -20,9 +20,12 @@ namespace LINGYUN.Platform.Menus string menuName, CancellationToken cancellationToken = default); - Task SetMemberMenusAsync( + Task> GetListByUserIdAsync( Guid userId, - IEnumerable menuIds, + CancellationToken cancellationToken = default); + + Task InsertAsync( + IEnumerable userMenus, CancellationToken cancellationToken = default); } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs index a6ef79151..bbbddbd49 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/MenuManager.cs @@ -11,6 +11,8 @@ namespace LINGYUN.Platform.Menus { public class MenuManager : DomainService { + protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService(); + protected IMenuRepository MenuRepository { get; } protected IUserMenuRepository UserMenuRepository { get; } protected IRoleMenuRepository RoleMenuRepository { get; } @@ -68,6 +70,7 @@ namespace LINGYUN.Platform.Menus return menu; } + [UnitOfWork] public virtual async Task UpdateAsync(Menu menu) { await ValidateMenuAsync(menu); @@ -117,27 +120,61 @@ namespace LINGYUN.Platform.Menus } } - public virtual async Task SetUserMenusAsync(Guid userId, IEnumerable menuIds) + public virtual async Task UserHasInMenuAsync(Guid userId, string menuName) { - await UserMenuRepository.SetMemberMenusAsync(userId, menuIds); + var menu = await MenuRepository.FindByNameAsync(menuName); + return false; } - [UnitOfWork] - public virtual async Task SetRoleMenusAsync(string roleName, IEnumerable menuIds) + public virtual async Task SetUserMenusAsync(Guid userId, IEnumerable menuIds) { - await RoleMenuRepository.SetRoleMenusAsync(roleName, menuIds); + using (var unitOfWork = UnitOfWorkManager.Begin()) + { + var userMenus = await UserMenuRepository.GetListByUserIdAsync(userId); + + // 移除不存在的菜单 + // TODO: 升级框架版本解决未能删除不需要菜单的问题 + // userMenus.RemoveAll(x => !menuIds.Contains(x.MenuId)); + var dels = userMenus.Where(x => !menuIds.Contains(x.MenuId)).Select(x => x.Id); + if (dels.Any()) + { + await UserMenuRepository.DeleteManyAsync(dels); + } + + var adds = menuIds.Where(menuId => !userMenus.Any(x => x.MenuId == menuId)); + if (adds.Any()) + { + var addInMenus = adds.Select(menuId => new UserMenu(GuidGenerator.Create(), menuId, userId, CurrentTenant.Id)); + await UserMenuRepository.InsertAsync(addInMenus); + } + + await unitOfWork.SaveChangesAsync(); + } } - protected virtual async Task ValidateMenuAsync(Menu menu) + public virtual async Task SetRoleMenusAsync(string roleName, IEnumerable menuIds) { - var siblings = (await FindChildrenAsync(menu.ParentId)) - .Where(x => x.Id != menu.Id) - .ToList(); - - if (siblings.Any(ou => ou.Name == menu.Name)) + using (var unitOfWork = UnitOfWorkManager.Begin()) { - throw new BusinessException(PlatformErrorCodes.DuplicateMenu) - .WithData("Name", menu.Name); + var roleMenus = await RoleMenuRepository.GetListByRoleNameAsync(roleName); + + // 移除不存在的菜单 + // TODO: 升级框架版本解决未能删除不需要菜单的问题 + // roleMenus.RemoveAll(x => !menuIds.Contains(x.MenuId)); + var dels = roleMenus.Where(x => !menuIds.Contains(x.MenuId)).Select(x => x.Id); + if (dels.Any()) + { + await UserMenuRepository.DeleteManyAsync(dels); + } + + var adds = menuIds.Where(menuId => !roleMenus.Any(x => x.MenuId == menuId)); + if (adds.Any()) + { + var addInMenus = adds.Select(menuId => new RoleMenu(GuidGenerator.Create(), menuId, roleName, CurrentTenant.Id)); + await RoleMenuRepository.InsertAsync(addInMenus); + } + + await unitOfWork.SaveChangesAsync(); } } @@ -187,5 +224,18 @@ namespace LINGYUN.Platform.Menus var menu = await MenuRepository.GetAsync(id); return menu?.Code; } + + protected virtual async Task ValidateMenuAsync(Menu menu) + { + var siblings = (await FindChildrenAsync(menu.ParentId)) + .Where(x => x.Id != menu.Id) + .ToList(); + + if (siblings.Any(x => x.Name == menu.Name)) + { + throw new BusinessException(PlatformErrorCodes.DuplicateMenu) + .WithData("Name", menu.Name); + } + } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/RoleMenu.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/RoleMenu.cs index 7c6c07df1..cf27cbc4f 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/RoleMenu.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/RoleMenu.cs @@ -18,9 +18,11 @@ namespace LINGYUN.Platform.Menus protected RoleMenu() { } public RoleMenu( + Guid id, Guid menuId, string roleName, Guid? tenantId = null) + : base(id) { MenuId = menuId; RoleName = roleName; diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserMenu.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserMenu.cs index ff039ccd5..1777d641b 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserMenu.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Menus/UserMenu.cs @@ -18,9 +18,11 @@ namespace LINGYUN.Platform.Menus protected UserMenu() { } public UserMenu( + Guid id, Guid menuId, Guid userId, Guid? tenantId = null) + : base(id) { MenuId = menuId; UserId = userId; diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDataSeedContributor.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDataSeedContributor.cs index 39552529f..16a965012 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDataSeedContributor.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/PlatformDataSeedContributor.cs @@ -9,11 +9,13 @@ using System.Threading.Tasks; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.Guids; +using Volo.Abp.MultiTenancy; namespace LINGYUN.Platform { public class PlatformDataSeedContributor : IDataSeedContributor, ITransientDependency { + protected ICurrentTenant CurrentTenant { get; } protected IGuidGenerator GuidGenerator { get; } protected IRouteDataSeeder RouteDataSeeder { get; } protected IDataDictionaryDataSeeder DataDictionaryDataSeeder { get; } @@ -21,12 +23,14 @@ namespace LINGYUN.Platform protected ILayoutRepository LayoutRepository { get; } public PlatformDataSeedContributor( + ICurrentTenant currentTenant, IRouteDataSeeder routeDataSeeder, IMenuRepository menuRepository, ILayoutRepository layoutRepository, IGuidGenerator guidGenerator, IDataDictionaryDataSeeder dataDictionaryDataSeeder) { + CurrentTenant = currentTenant; GuidGenerator = guidGenerator; RouteDataSeeder = routeDataSeeder; MenuRepository = menuRepository; @@ -36,23 +40,26 @@ namespace LINGYUN.Platform public virtual async Task SeedAsync(DataSeedContext context) { - var data = await SeedDefaultDataDictionaryAsync(context.TenantId); - // 预置 - var layout = await SeedDefaultLayoutAsync(data); - // 首页 - await SeedHomeMenuAsync(layout, data); - // 管理菜单预置菜单数据 - await SeedAdminMenuAsync(layout, data); - // saas菜单数据 - await SeedSaasMenuAsync(layout, data); - // 身份资源菜单数据 - await SeedIdentityServerMenuAsync(layout, data); - // 审计日志菜单数据 - await SeedAuditingMenuAsync(layout, data); - // 布局容器预置菜单数据 - await SeedContainerMenuAsync(layout, data); - // 网关管理菜单数据 - await SeedApiGatewayMenuAsync(layout, data); + using (CurrentTenant.Change(context.TenantId)) + { + var data = await SeedDefaultDataDictionaryAsync(context.TenantId); + // 预置 + var layout = await SeedDefaultLayoutAsync(data); + // 首页 + await SeedHomeMenuAsync(layout, data); + // 管理菜单预置菜单数据 + await SeedAdminMenuAsync(layout, data); + // saas菜单数据 + await SeedSaasMenuAsync(layout, data); + // 身份资源菜单数据 + await SeedIdentityServerMenuAsync(layout, data); + // 审计日志菜单数据 + await SeedAuditingMenuAsync(layout, data); + // 布局容器预置菜单数据 + await SeedContainerMenuAsync(layout, data); + // 网关管理菜单数据 + await SeedApiGatewayMenuAsync(layout, data); + } } private async Task SeedDefaultDataDictionaryAsync(Guid? tenantId) diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteDataSeeder.cs b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteDataSeeder.cs index f44680e3b..c5ec6a1a7 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteDataSeeder.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN/Platform/Routes/RouteDataSeeder.cs @@ -117,7 +117,7 @@ namespace LINGYUN.Platform.Routes { if (! await RoleMenuRepository.RoleHasInMenuAsync(roleName, menu.Name, cancellationToken)) { - var roleMenu = new RoleMenu(menu.Id, roleName, tenantId); + var roleMenu = new RoleMenu(GuidGenerator.Create(), menu.Id, roleName, tenantId); await RoleMenuRepository.InsertAsync(roleMenu); var childrens = await MenuRepository.GetChildrenAsync(menu.Id); @@ -136,7 +136,7 @@ namespace LINGYUN.Platform.Routes { if (!await UserMenuRepository.UserHasInMenuAsync(userId, menu.Name, cancellationToken)) { - var userMenu = new UserMenu(menu.Id, userId, tenantId); + var userMenu = new UserMenu(GuidGenerator.Create(), menu.Id, userId, tenantId); await UserMenuRepository.InsertAsync(userMenu); var childrens = await MenuRepository.GetChildrenAsync(menu.Id); diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj index 8aacc7f96..6dd220b1d 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN.Platform.EntityFrameworkCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Datas/EfCoreDataRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Datas/EfCoreDataRepository.cs index 92ac26253..28d84c4b7 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Datas/EfCoreDataRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Datas/EfCoreDataRepository.cs @@ -23,7 +23,8 @@ namespace LINGYUN.Platform.Datas bool includeDetails = true, CancellationToken cancellationToken = default) { - return await DbSet + var dbSet = await GetDbSetAsync(); + return await dbSet .IncludeDetails(includeDetails) .Where(x => x.Name == name) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -34,7 +35,8 @@ namespace LINGYUN.Platform.Datas bool includeDetails = false, CancellationToken cancellationToken = default) { - return await DbSet + var dbSet = await GetDbSetAsync(); + return await dbSet .IncludeDetails(includeDetails) .Where(x => x.ParentId == parentId) .ToListAsync(GetCancellationToken(cancellationToken)); @@ -44,7 +46,8 @@ namespace LINGYUN.Platform.Datas string filter = "", CancellationToken cancellationToken = default) { - return await DbSet + var dbSet = await GetDbSetAsync(); + return await dbSet .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Code.Contains(filter) || x.Description.Contains(filter) || x.DisplayName.Contains(filter) || x.Name.Contains(filter)) @@ -61,7 +64,8 @@ namespace LINGYUN.Platform.Datas { sotring ??= nameof(Data.Code); - return await DbSet + var dbSet = await GetDbSetAsync(); + return await dbSet .IncludeDetails(includeDetails) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Code.Contains(filter) || x.Description.Contains(filter) || @@ -71,6 +75,11 @@ namespace LINGYUN.Platform.Datas .ToListAsync(GetCancellationToken(cancellationToken)); } + public override async Task> WithDetailsAsync() + { + return (await GetQueryableAsync()).IncludeDetails(); + } + public override IQueryable WithDetails() { return GetQueryable().IncludeDetails(); diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs index 95b86e43e..9bba7f23b 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs @@ -25,9 +25,9 @@ namespace LINGYUN.Platform.EntityFrameworkCore protected override void OnModelCreating(ModelBuilder builder) { - base.OnModelCreating(builder); - builder.ConfigurePlatform(); + + base.OnModelCreating(builder); } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs index 903dd8e65..4c0c1bada 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Layouts/EfCoreLayoutRepository.cs @@ -23,7 +23,7 @@ namespace LINGYUN.Platform.Layouts bool includeDetails = false, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .IncludeDetails(includeDetails) .Where(x => x.Name == name) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -34,7 +34,7 @@ namespace LINGYUN.Platform.Layouts string filter = "", CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(platformType.HasValue, x => x.PlatformType == platformType.Value) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Name.Contains(filter) || x.DisplayName.Contains(filter) || @@ -55,7 +55,7 @@ namespace LINGYUN.Platform.Layouts sorting ??= nameof(Layout.Name); sorting = reverse ? sorting + " DESC" : sorting; - return await DbSet + return await (await GetDbSetAsync()) .IncludeDetails(includeDetails) .WhereIf(platformType.HasValue, x => x.PlatformType == platformType.Value) .WhereIf(!filter.IsNullOrWhiteSpace(), x => @@ -66,6 +66,11 @@ namespace LINGYUN.Platform.Layouts .ToListAsync(GetCancellationToken(cancellationToken)); } + public override async Task> WithDetailsAsync() + { + return (await GetQueryableAsync()).IncludeDetails(); + } + public override IQueryable WithDetails() { return GetQueryable().IncludeDetails(); diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs index 50186cbb2..04b2bfc78 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreMenuRepository.cs @@ -24,10 +24,10 @@ namespace LINGYUN.Platform.Menus string menuName, CancellationToken cancellationToken = default) { - var menuQuery = DbSet.Where(x => x.Name == menuName); + var menuQuery = (await GetDbSetAsync()).Where(x => x.Name == menuName); return await (from menu in menuQuery - join userMenu in DbContext.Set() + join userMenu in (await GetDbContextAsync()).Set() on menu.Id equals userMenu.MenuId select userMenu) .AnyAsync(x => x.UserId == userId, GetCancellationToken(cancellationToken)); @@ -38,10 +38,10 @@ namespace LINGYUN.Platform.Menus string menuName, CancellationToken cancellationToken = default) { - var menuQuery = DbSet.Where(x => x.Name == menuName); + var menuQuery = (await GetDbSetAsync()).Where(x => x.Name == menuName); return await (from menu in menuQuery - join roleMenu in DbContext.Set() + join roleMenu in (await GetDbContextAsync()).Set() on menu.Id equals roleMenu.MenuId select roleMenu) .AnyAsync(x => x.RoleName == roleName, GetCancellationToken(cancellationToken)); @@ -51,7 +51,7 @@ namespace LINGYUN.Platform.Menus string menuName, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Where(x => x.Name == menuName) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } @@ -60,7 +60,7 @@ namespace LINGYUN.Platform.Menus PlatformType platformType = PlatformType.None, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Where(menu => menu.PlatformType.HasFlag(platformType) && menu.Path == "/") .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); } @@ -70,10 +70,10 @@ namespace LINGYUN.Platform.Menus PlatformType platformType = PlatformType.None, CancellationToken cancellationToken = default) { - var menuQuery = DbSet + var menuQuery = (await GetDbSetAsync()) .Where(menu => menu.PlatformType.HasFlag(platformType)); - var roleMenuQuery = DbContext.Set() + var roleMenuQuery = (await GetDbContextAsync()).Set() .Where(menu => roles.Contains(menu.RoleName)); return await (from menu in menuQuery @@ -91,10 +91,11 @@ namespace LINGYUN.Platform.Menus PlatformType platformType = PlatformType.None, CancellationToken cancellationToken = default) { - var menuQuery = DbSet + var menuQuery = (await GetDbSetAsync()) .Where(menu => menu.PlatformType.HasFlag(platformType)); - var userMenuQuery = from userMenu in DbContext.Set() + var dbContext = await GetDbContextAsync(); + var userMenuQuery = from userMenu in dbContext.Set() join menu in menuQuery on userMenu.MenuId equals menu.Id where userMenu.UserId == userId @@ -102,7 +103,7 @@ namespace LINGYUN.Platform.Menus if (roles != null && roles.Length > 0) { - var roleMenuQuery = from roleMenu in DbContext.Set() + var roleMenuQuery = from roleMenu in dbContext.Set() join menu in menuQuery on roleMenu.MenuId equals menu.Id where roles.Contains(roleMenu.RoleName) @@ -126,7 +127,7 @@ namespace LINGYUN.Platform.Menus CancellationToken cancellationToken = default ) { - return await DbSet + return await (await GetDbSetAsync()) .Where(x => x.ParentId == parentId) .ToListAsync(GetCancellationToken(cancellationToken)); } @@ -137,7 +138,7 @@ namespace LINGYUN.Platform.Menus CancellationToken cancellationToken = default ) { - return await DbSet + return await (await GetDbSetAsync()) .Where(x => x.Code.StartsWith(code) && x.Id != parentId.Value) .ToListAsync(GetCancellationToken(cancellationToken)); } @@ -154,7 +155,7 @@ namespace LINGYUN.Platform.Menus sorting ??= nameof(Menu.Code); sorting = reverse ? sorting + " DESC" : sorting; - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(parentId.HasValue, x => x.ParentId == parentId) .WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId) .WhereIf(platformType.HasValue, menu => menu.PlatformType.HasFlag(platformType.Value)) @@ -173,7 +174,7 @@ namespace LINGYUN.Platform.Menus Guid? layoutId = null, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(parentId.HasValue, x => x.ParentId == parentId) .WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId) .WhereIf(platformType.HasValue, menu => menu.PlatformType.HasFlag(platformType.Value)) @@ -198,7 +199,7 @@ namespace LINGYUN.Platform.Menus sorting ??= nameof(Menu.Code); sorting = reverse ? sorting + " DESC" : sorting; - return await DbSet + return await (await GetDbSetAsync()) .WhereIf(parentId.HasValue, x => x.ParentId == parentId) .WhereIf(layoutId.HasValue, x => x.LayoutId == layoutId) .WhereIf(platformType.HasValue, menu => menu.PlatformType.HasFlag(platformType.Value)) @@ -216,11 +217,12 @@ namespace LINGYUN.Platform.Menus CancellationToken cancellationToken = default ) { - var rolesQuery = await DbContext.Set() + var dbContext = await GetDbContextAsync(); + var rolesQuery = await dbContext.Set() .Where(q => q.MenuId == menu.Id) .ToListAsync(GetCancellationToken(cancellationToken)); - DbContext.Set().RemoveRange(rolesQuery); + dbContext.Set().RemoveRange(rolesQuery); } public virtual async Task RemoveAllMembersAsync( @@ -228,11 +230,17 @@ namespace LINGYUN.Platform.Menus CancellationToken cancellationToken = default ) { - var membersQuery = await DbContext.Set() + var dbContext = await GetDbContextAsync(); + var membersQuery = await dbContext.Set() .Where(q => q.MenuId == menu.Id) .ToListAsync(GetCancellationToken(cancellationToken)); - DbContext.Set().RemoveRange(membersQuery); + dbContext.Set().RemoveRange(membersQuery); + } + + public override async Task> WithDetailsAsync() + { + return (await GetQueryableAsync()).IncludeDetails(); } public override IQueryable WithDetails() diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreRoleMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreRoleMenuRepository.cs index 7c9c8c8f3..aad062254 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreRoleMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreRoleMenuRepository.cs @@ -18,43 +18,31 @@ namespace LINGYUN.Platform.Menus { } + public virtual async Task> GetListByRoleNameAsync(string roleName, CancellationToken cancellationToken = default) + { + return await (await GetDbSetAsync()).Where(x => x.RoleName.Equals(roleName)) + .ToListAsync(GetCancellationToken(cancellationToken)); + } + + public virtual async Task InsertAsync(IEnumerable roleMenus, CancellationToken cancellationToken = default) + { + await (await GetDbSetAsync()).AddRangeAsync(roleMenus, GetCancellationToken(cancellationToken)); + } + public virtual async Task RoleHasInMenuAsync( string roleName, string menuName, CancellationToken cancellationToken = default) { - var menuQuery = DbContext.Set().Where(x => x.Name == menuName); + var menuQuery = (await GetDbContextAsync()).Set().Where(x => x.Name == menuName); return await - (from roleMenu in DbSet + (from roleMenu in (await GetDbSetAsync()) join menu in menuQuery on roleMenu.MenuId equals menu.Id select roleMenu) .AnyAsync(x => x.RoleName == roleName, GetCancellationToken(cancellationToken)); } - - public virtual async Task SetRoleMenusAsync( - string roleName, - IEnumerable menuIds, - CancellationToken cancellationToken = default) - { - var hasInMenus = await DbSet - .Where(x => x.RoleName == roleName) - .ToArrayAsync(GetCancellationToken(cancellationToken)); - - var removes = hasInMenus.Where(x => !menuIds.Contains(x.MenuId)); - if (removes.Any()) - { - DbContext.RemoveRange(removes); - } - - var adds = menuIds.Where(menuId => !hasInMenus.Any(x => x.MenuId == menuId)); - if (adds.Any()) - { - var addInMenus = adds.Select(menuId => new RoleMenu(menuId, roleName, CurrentTenant.Id)); - await DbContext.AddRangeAsync(addInMenus, GetCancellationToken(cancellationToken)); - } - } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserMenuRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserMenuRepository.cs index 5b5f31810..4edf78426 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserMenuRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Menus/EfCoreUserMenuRepository.cs @@ -23,38 +23,31 @@ namespace LINGYUN.Platform.Menus string menuName, CancellationToken cancellationToken = default) { - var menuQuery = DbContext.Set().Where(x => x.Name == menuName); - + var dbContext = await GetDbContextAsync(); return await - (from roleMenu in DbSet - join menu in menuQuery - on roleMenu.MenuId equals menu.Id - select roleMenu) - .AnyAsync(x => x.UserId == userId, + (from userMenu in dbContext.Set() + join menu in dbContext.Set() + on userMenu.MenuId equals menu.Id + where userMenu.UserId.Equals(userId) + select menu) + .AnyAsync( + x => x.Name.Equals(menuName), GetCancellationToken(cancellationToken)); } - public virtual async Task SetMemberMenusAsync( + public virtual async Task> GetListByUserIdAsync( Guid userId, - IEnumerable menuIds, CancellationToken cancellationToken = default) { - var hasInMenus = await DbSet - .Where(x => x.UserId == userId) - .ToArrayAsync(GetCancellationToken(cancellationToken)); - - var removes = hasInMenus.Where(x => !menuIds.Contains(x.MenuId)); - if (removes.Any()) - { - DbContext.RemoveRange(removes); - } + var dbSet = await GetDbSetAsync(); + return await dbSet.Where(x => x.UserId.Equals(userId)) + .ToListAsync(GetCancellationToken(cancellationToken)); + } - var adds = menuIds.Where(menuId => !hasInMenus.Any(x => x.MenuId == menuId)); - if (adds.Any()) - { - var addInMenus = adds.Select(menuId => new UserMenu(menuId, userId, CurrentTenant.Id)); - await DbContext.AddRangeAsync(addInMenus, GetCancellationToken(cancellationToken)); - } + public virtual async Task InsertAsync(IEnumerable userMenus, CancellationToken cancellationToken = default) + { + var dbSet = await GetDbSetAsync(); + await dbSet.AddRangeAsync(userMenus, GetCancellationToken(cancellationToken)); } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs index 16d1831cb..04c8d123d 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/Versions/EfCoreVersionRepository.cs @@ -22,7 +22,7 @@ namespace LINGYUN.Platform.Versions public virtual async Task GetCountAsync(PlatformType platformType, string filter = "", CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Where(x => (platformType | x.PlatformType) == x.PlatformType) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter)) .LongCountAsync(GetCancellationToken(cancellationToken)); @@ -30,7 +30,7 @@ namespace LINGYUN.Platform.Versions public virtual async Task> GetPagedListAsync(PlatformType platformType, string filter = "", string soring = nameof(AppVersion.CreationTime), bool includeDetails = true, int skipCount = 1, int maxResultCount = 10, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .IncludeIf(includeDetails, x => x.Files) .Where(x => (platformType | x.PlatformType) == x.PlatformType) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Version.Contains(filter) || x.Title.Contains(filter)) @@ -43,13 +43,13 @@ namespace LINGYUN.Platform.Versions public virtual async Task ExistsAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .AnyAsync(x => (platformType | x.PlatformType) == x.PlatformType && x.Version.Equals(version), GetCancellationToken(cancellationToken)); } public virtual async Task GetByVersionAsync(PlatformType platformType, string version, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Include(x => x.Files) .Where(x => (platformType | x.PlatformType) == x.PlatformType && x.Version.Equals(version)) .FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); @@ -57,7 +57,7 @@ namespace LINGYUN.Platform.Versions public virtual async Task GetLatestVersionAsync(PlatformType platformType, CancellationToken cancellationToken = default) { - return await DbSet + return await (await GetDbSetAsync()) .Include(x => x.Files) .Where(x => (platformType | x.PlatformType) == x.PlatformType) .OrderBy($"{nameof(AppVersion.CreationTime)} DESC") diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj index 0c1e0ccab..ba6ca54bd 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN.Platform.HttpApi.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformControllerBase.cs b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformControllerBase.cs index 94c25092b..035e709eb 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformControllerBase.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.HttpApi/LINGYUN/Platform/PlatformControllerBase.cs @@ -6,8 +6,7 @@ namespace LINGYUN.Platform { public abstract class PlatformControllerBase : AbpController { - private ISettingProvider _settingProvider; - protected ISettingProvider SettingProvider => LazyGetRequiredService(ref _settingProvider); + protected ISettingProvider SettingProvider => LazyServiceProvider.LazyGetRequiredService(); protected PlatformControllerBase() { diff --git a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application.Contracts/LINGYUN.Abp.RulesManagement.Application.Contracts.csproj b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application.Contracts/LINGYUN.Abp.RulesManagement.Application.Contracts.csproj index b32fdd233..53a6b7071 100644 --- a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application.Contracts/LINGYUN.Abp.RulesManagement.Application.Contracts.csproj +++ b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application.Contracts/LINGYUN.Abp.RulesManagement.Application.Contracts.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application/LINGYUN.Abp.RulesManagement.Application.csproj b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application/LINGYUN.Abp.RulesManagement.Application.csproj index 54f556332..570694f1e 100644 --- a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application/LINGYUN.Abp.RulesManagement.Application.csproj +++ b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Application/LINGYUN.Abp.RulesManagement.Application.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain.Shared/LINGYUN.Abp.RulesManagement.Domain.Shared.csproj b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain.Shared/LINGYUN.Abp.RulesManagement.Domain.Shared.csproj index d593ad86d..08698ab30 100644 --- a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain.Shared/LINGYUN.Abp.RulesManagement.Domain.Shared.csproj +++ b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain.Shared/LINGYUN.Abp.RulesManagement.Domain.Shared.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain/LINGYUN.Abp.RulesManagement.Domain.csproj b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain/LINGYUN.Abp.RulesManagement.Domain.csproj index 61904af63..eb05a08a9 100644 --- a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain/LINGYUN.Abp.RulesManagement.Domain.csproj +++ b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.Domain/LINGYUN.Abp.RulesManagement.Domain.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.EntityFrameworkCore/LINGYUN.Abp.RulesManagement.EntityFrameworkCore.csproj b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.EntityFrameworkCore/LINGYUN.Abp.RulesManagement.EntityFrameworkCore.csproj index f6bc02919..463207d54 100644 --- a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.EntityFrameworkCore/LINGYUN.Abp.RulesManagement.EntityFrameworkCore.csproj +++ b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.EntityFrameworkCore/LINGYUN.Abp.RulesManagement.EntityFrameworkCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi.Client/LINGYUN.Abp.RulesManagement.HttpApi.Client.csproj b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi.Client/LINGYUN.Abp.RulesManagement.HttpApi.Client.csproj index e578b0097..798c4f3d6 100644 --- a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi.Client/LINGYUN.Abp.RulesManagement.HttpApi.Client.csproj +++ b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi.Client/LINGYUN.Abp.RulesManagement.HttpApi.Client.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi/LINGYUN.Abp.RulesManagement.HttpApi.csproj b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi/LINGYUN.Abp.RulesManagement.HttpApi.csproj index e8a802da7..4aa013876 100644 --- a/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi/LINGYUN.Abp.RulesManagement.HttpApi.csproj +++ b/aspnet-core/modules/rules-management/LINGYUN.Abp.RulesManagement.HttpApi/LINGYUN.Abp.RulesManagement.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj index 70870a8e2..fe8b848c9 100644 --- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj +++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN.Abp.SettingManagement.Application.Contracts.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN.Abp.SettingManagement.Application.csproj b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN.Abp.SettingManagement.Application.csproj index ac145738c..1ffec0af5 100644 --- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN.Abp.SettingManagement.Application.csproj +++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN.Abp.SettingManagement.Application.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj index 86c4347cd..4fdda37b3 100644 --- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj +++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.HttpApi/LINGYUN.Abp.SettingManagement.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN.Abp.MultiTenancy.DbFinder.csproj b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN.Abp.MultiTenancy.DbFinder.csproj index 1eae0538d..2645d6892 100644 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN.Abp.MultiTenancy.DbFinder.csproj +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.DbFinder/LINGYUN.Abp.MultiTenancy.DbFinder.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN.Abp.MultiTenancy.RemoteService.csproj b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN.Abp.MultiTenancy.RemoteService.csproj index ac7baf14d..6abd44d92 100644 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN.Abp.MultiTenancy.RemoteService.csproj +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.MultiTenancy.RemoteService/LINGYUN.Abp.MultiTenancy.RemoteService.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application.Contracts/LINGYUN.Abp.TenantManagement.Application.Contracts.csproj b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application.Contracts/LINGYUN.Abp.TenantManagement.Application.Contracts.csproj index 3bb4cb0a9..731771dba 100644 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application.Contracts/LINGYUN.Abp.TenantManagement.Application.Contracts.csproj +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application.Contracts/LINGYUN.Abp.TenantManagement.Application.Contracts.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application/LINGYUN.Abp.TenantManagement.Application.csproj b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application/LINGYUN.Abp.TenantManagement.Application.csproj index dd592ab58..0de337db3 100644 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application/LINGYUN.Abp.TenantManagement.Application.csproj +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.Application/LINGYUN.Abp.TenantManagement.Application.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi.Client/LINGYUN.Abp.TenantManagement.HttpApi.Client.csproj b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi.Client/LINGYUN.Abp.TenantManagement.HttpApi.Client.csproj index c70bd92e7..13353cec6 100644 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi.Client/LINGYUN.Abp.TenantManagement.HttpApi.Client.csproj +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi.Client/LINGYUN.Abp.TenantManagement.HttpApi.Client.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj index 9516d0556..6a0e94151 100644 --- a/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj +++ b/aspnet-core/modules/tenants/LINGYUN.Abp.TenantManagement.HttpApi/LINGYUN.Abp.TenantManagement.HttpApi.csproj @@ -8,7 +8,7 @@ - + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj index 0d3091c37..fb4805ebd 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat.SettingManagement/LINGYUN.Abp.WeChat.SettingManagement.csproj @@ -18,8 +18,8 @@ - - + + diff --git a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj index 60a149e21..52a691d09 100644 --- a/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj +++ b/aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj @@ -18,9 +18,9 @@ - - - + + + diff --git a/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj b/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj index 4f24d7466..2550cfac8 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj +++ b/aspnet-core/services/account/AuthServer.Host/AuthServer.Host.csproj @@ -36,19 +36,19 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/aspnet-core/services/account/AuthServer.Host/Emailing/AccountEmailVerifySender.cs b/aspnet-core/services/account/AuthServer.Host/Emailing/AccountEmailVerifySender.cs index 104bd2227..4131c9945 100644 --- a/aspnet-core/services/account/AuthServer.Host/Emailing/AccountEmailVerifySender.cs +++ b/aspnet-core/services/account/AuthServer.Host/Emailing/AccountEmailVerifySender.cs @@ -1,9 +1,7 @@ using AuthServer.Host.Emailing.Templates; -using LINGYUN.Abp.Account; using Microsoft.Extensions.Localization; using System; using System.Diagnostics; -using System.Text.Encodings.Web; using System.Threading.Tasks; using System.Web; using Volo.Abp.Account.Emailing; @@ -73,7 +71,7 @@ namespace AuthServer.Host.Emailing ); } - private string NormalizeReturnUrl(string returnUrl) + protected override string NormalizeReturnUrl(string returnUrl) { if (returnUrl.IsNullOrEmpty()) { diff --git a/aspnet-core/services/account/AuthServer.Host/package.json b/aspnet-core/services/account/AuthServer.Host/package.json index 0b7e68c89..acdec64d8 100644 --- a/aspnet-core/services/account/AuthServer.Host/package.json +++ b/aspnet-core/services/account/AuthServer.Host/package.json @@ -3,6 +3,6 @@ "name": "auth-identityserver", "private": true, "dependencies": { - "@abp/aspnetcore.mvc.ui.theme.basic": "~4.1.2" + "@abp/aspnetcore.mvc.ui.theme.basic": "~4.2.1" } } \ No newline at end of file diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs index 4114471d0..c8251acc7 100644 --- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs +++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantCreateEventHandler.cs @@ -57,11 +57,11 @@ namespace LINGYUN.Abp.BackendAdmin.EventBus.Handlers // TODO: MySql 批量新增还是一条一条的语句? // await PermissionGrantRepository.GetDbSet().AddRangeAsync(grantPermissions); - var permissionEntityType = PermissionGrantRepository.GetDbContext() - .Model.FindEntityType(typeof(PermissionGrant)); + var dbContext = await PermissionGrantRepository.GetDbContextAsync(); + var permissionEntityType = dbContext.Model.FindEntityType(typeof(PermissionGrant)); var permissionTableName = permissionEntityType.GetTableName(); var batchInsertPermissionSql = string.Empty; - if (PermissionGrantRepository.GetDbContext().Database.IsMySql()) + if (dbContext.Database.IsMySql()) { batchInsertPermissionSql = BuildMySqlBatchInsertScript(permissionTableName, eventData.Id, grantPermissions); } @@ -69,7 +69,7 @@ namespace LINGYUN.Abp.BackendAdmin.EventBus.Handlers { batchInsertPermissionSql = BuildSqlServerBatchInsertScript(permissionTableName, eventData.Id, grantPermissions); } - await PermissionGrantRepository.GetDbContext().Database.ExecuteSqlRawAsync(batchInsertPermissionSql); + await dbContext.Database.ExecuteSqlRawAsync(batchInsertPermissionSql); await unitOfWork.SaveChangesAsync(); } diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs index 3a120c7f1..e020ca134 100644 --- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs +++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/EventBus/Handlers/TenantDeleteEventHandler.cs @@ -44,10 +44,11 @@ namespace LINGYUN.Abp.BackendAdmin.EventBus.Handlers // EfCore MySql 批量删除还是一条一条的语句? // PermissionGrantRepository.GetDbSet().RemoveRange(grantPermissions); - var permissionEntityType = PermissionGrantRepository.GetDbContext().Model.FindEntityType(typeof(PermissionGrant)); + var dbContext = await PermissionGrantRepository.GetDbContextAsync(); + var permissionEntityType = dbContext.Model.FindEntityType(typeof(PermissionGrant)); var permissionTableName = permissionEntityType.GetTableName(); var batchRmovePermissionSql = string.Empty; - if (PermissionGrantRepository.GetDbContext().Database.IsMySql()) + if (dbContext.Database.IsMySql()) { batchRmovePermissionSql = BuildMySqlBatchDeleteScript(permissionTableName, eventData.Entity.Id); } @@ -56,8 +57,7 @@ namespace LINGYUN.Abp.BackendAdmin.EventBus.Handlers batchRmovePermissionSql = BuildSqlServerBatchDeleteScript(permissionTableName, eventData.Entity.Id); } - await PermissionGrantRepository.GetDbContext().Database - .ExecuteSqlRawAsync(batchRmovePermissionSql); + await dbContext.Database.ExecuteSqlRawAsync(batchRmovePermissionSql); await unitOfWork.SaveChangesAsync(); } diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/LINGYUN.Abp.BackendAdmin.HttpApi.Host.csproj b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/LINGYUN.Abp.BackendAdmin.HttpApi.Host.csproj index 82e215d28..89587183d 100644 --- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/LINGYUN.Abp.BackendAdmin.HttpApi.Host.csproj +++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/LINGYUN.Abp.BackendAdmin.HttpApi.Host.csproj @@ -38,24 +38,24 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj index 990e7a421..c9485b424 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/LINGYUN.ApiGateway.Host.csproj @@ -22,13 +22,13 @@ - - - - - - - + + + + + + + diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/LINGYUN.ApiGateway.HttpApi.Host.csproj b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/LINGYUN.ApiGateway.HttpApi.Host.csproj index 3d24daaa0..ba52b15f8 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/LINGYUN.ApiGateway.HttpApi.Host.csproj +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/LINGYUN.ApiGateway.HttpApi.Host.csproj @@ -27,13 +27,13 @@ - - - - - - - + + + + + + + diff --git a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj index eb0d0501a..115338ac2 100644 --- a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj +++ b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/LINGYUN.Abp.IdentityServer4.HttpApi.Host.csproj @@ -36,19 +36,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/LINGYUN.Abp.MessageService.HttpApi.Host.csproj b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/LINGYUN.Abp.MessageService.HttpApi.Host.csproj index f21266093..2e005620e 100644 --- a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/LINGYUN.Abp.MessageService.HttpApi.Host.csproj +++ b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/LINGYUN.Abp.MessageService.HttpApi.Host.csproj @@ -31,14 +31,14 @@ - - - - - - - - + + + + + + + + diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj index 920b05ec9..42351bc48 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/LINGYUN.Platform.HttpApi.Host.csproj @@ -35,19 +35,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj new file mode 100644 index 000000000..b2c6daf85 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj @@ -0,0 +1,18 @@ + + + + net5.0 + + false + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN/Abp/Aliyun/AbpAliyunTestBase.cs b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN/Abp/Aliyun/AbpAliyunTestBase.cs new file mode 100644 index 000000000..6bd428176 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN/Abp/Aliyun/AbpAliyunTestBase.cs @@ -0,0 +1,8 @@ +using LINGYUN.Abp.Tests; + +namespace LINGYUN.Abp.Aliyun +{ + public class AbpAliyunTestBase : AbpTestsBase + { + } +} diff --git a/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN/Abp/Aliyun/AbpAliyunTestModule.cs b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN/Abp/Aliyun/AbpAliyunTestModule.cs new file mode 100644 index 000000000..9dfae1732 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN/Abp/Aliyun/AbpAliyunTestModule.cs @@ -0,0 +1,24 @@ +using LINGYUN.Abp.Tests; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Aliyun +{ + [DependsOn( + typeof(AbpAliyunModule), + typeof(AbpTestsBaseModule))] + public class AbpAliyunTestModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + var configurationOptions = new AbpConfigurationBuilderOptions + { + BasePath = @"D:\Projects\Development\Abp\Aliyun", + EnvironmentName = "Development" + }; + + context.Services.ReplaceConfiguration(ConfigurationHelper.BuildConfiguration(configurationOptions)); + } + } +} diff --git a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj index 5c7c5f750..526c4954d 100644 --- a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests.csproj @@ -12,6 +12,7 @@ + diff --git a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunTestModule.cs b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunTestModule.cs index 4333b987f..ee777eede 100644 --- a/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunTestModule.cs +++ b/aspnet-core/tests/LINGYUN.Abp.BlobStoring.Aliyun.Tests/LINGYUN/Abp/BlobStoring/Aliyun/AbpBlobStoringAliyunTestModule.cs @@ -1,19 +1,20 @@ using Aliyun.OSS; -using LINGYUN.Abp.Tests; +using LINGYUN.Abp.Aliyun; +using LINYUN.Abp.Aliyun.Settings; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using System; using Volo.Abp; using Volo.Abp.Autofac; using Volo.Abp.BlobStoring; using Volo.Abp.Modularity; +using Volo.Abp.Security.Encryption; namespace LINGYUN.Abp.BlobStoring.Aliyun { [DependsOn( typeof(AbpBlobStoringModule), typeof(AbpBlobStoringAliyunModule), - typeof(AbpTestsBaseModule), + typeof(AbpAliyunTestModule), typeof(AbpAutofacModule) )] public class AbpBlobStoringAliyunTestModule : AbpModule @@ -23,25 +24,22 @@ namespace LINGYUN.Abp.BlobStoring.Aliyun private string _accessKeySecret; private string _endPoint; - public override void PreConfigureServices(ServiceConfigurationContext context) - { - var configurationOptions = new AbpConfigurationBuilderOptions - { - BasePath = @"D:\Projects\Development\Abp\BlobStoring\Aliyun", - EnvironmentName = "Development" - }; + private IConfiguration _configuration; - context.Services.ReplaceConfiguration(ConfigurationHelper.BuildConfiguration(configurationOptions)); + public override void ConfigureServices(ServiceConfigurationContext context) + { + _configuration = context.Services.GetConfiguration(); } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void OnApplicationInitialization(ApplicationInitializationContext context) { - var configuration = context.Services.GetConfiguration(); + _endPoint = _configuration[AliyunBlobProviderConfigurationNames.Endpoint]; + _bucketName = _configuration[AliyunBlobProviderConfigurationNames.BucketName]; + + var encryptionService = context.ServiceProvider.GetRequiredService(); - _endPoint = configuration[AliyunBlobProviderConfigurationNames.Endpoint]; - _bucketName = configuration[AliyunBlobProviderConfigurationNames.BucketName]; - _accessKeyId = configuration["Aliyun:Auth:AccessKeyId"]; - _accessKeySecret = configuration["Aliyun:Auth:AccessKeySecret"]; + _accessKeyId = encryptionService.Decrypt(_configuration["Settings:" + AliyunSettingNames.Authorization.AccessKeyId]); + _accessKeySecret = encryptionService.Decrypt(_configuration["Settings:" + AliyunSettingNames.Authorization.AccessKeySecret]); } public override void OnApplicationShutdown(ApplicationShutdownContext context) diff --git a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj index ac979da7f..fdaae14e5 100644 --- a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN.Abp.EntityFrameworkCore.Tests.csproj @@ -6,7 +6,7 @@ - + diff --git a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs index 099e9a89d..cf6b484e4 100644 --- a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs +++ b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs @@ -23,6 +23,10 @@ namespace LINGYUN.Abp.EntityFrameworkCore.Tests { options.Configure(abpDbContextConfigurationContext => { + abpDbContextConfigurationContext.DbContextOptions.EnableDetailedErrors(); + abpDbContextConfigurationContext.DbContextOptions.EnableSensitiveDataLogging(); + abpDbContextConfigurationContext.DbContextOptions.UseEFCoreLogger(); + abpDbContextConfigurationContext.DbContextOptions.UseInMemoryDatabase(databaseName); }); }); diff --git a/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN/Abp/EntityFrameworkCore/EfCoreLoggerFactory.cs b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN/Abp/EntityFrameworkCore/EfCoreLoggerFactory.cs new file mode 100644 index 000000000..6b4a90a6c --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.EntityFrameworkCore.Tests/LINGYUN/Abp/EntityFrameworkCore/EfCoreLoggerFactory.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using System; +using System.Diagnostics; + +namespace LINGYUN.Abp.EntityFrameworkCore.Tests +{ + public class EfCoreLoggerFactory : ILoggerFactory + { + public void AddProvider(ILoggerProvider provider) + { + } + + public ILogger CreateLogger(string categoryName) + { + return new EfCoreLogger(categoryName);//创建EFLogger类的实例 + } + + public void Dispose() + { + + } + } + + public class EfCoreLogger : ILogger + { + private readonly string _categoryName; + + public EfCoreLogger(string categoryName) => this._categoryName = categoryName; + + public bool IsEnabled(LogLevel logLevel) => true; + + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + var logContent = formatter(state, exception); + + Debug.WriteLine(""); + // Console.ForegroundColor = logLevel == LogLevel.Warning || logLevel == LogLevel.Error ? ConsoleColor.Red : ConsoleColor.Green; + Debug.WriteLine(logContent); + } + + public IDisposable BeginScope(TState state) => null; + } + + public static class EFCoreLoggerExtensions + { + public static DbContextOptionsBuilder UseEFCoreLogger(this DbContextOptionsBuilder builder) + { + return builder.UseLoggerFactory(new EfCoreLoggerFactory()); + } + } +} diff --git a/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN.Abp.Sms.Aliyun.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN.Abp.Sms.Aliyun.Tests.csproj new file mode 100644 index 000000000..94651d40f --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN.Abp.Sms.Aliyun.Tests.csproj @@ -0,0 +1,18 @@ + + + + net5.0 + + false + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AbpAliyunSmsTestBase.cs b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AbpAliyunSmsTestBase.cs new file mode 100644 index 000000000..bd7d69da0 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AbpAliyunSmsTestBase.cs @@ -0,0 +1,8 @@ +using LINGYUN.Abp.Tests; + +namespace LINGYUN.Abp.Sms.Aliyun +{ + public class AbpAliyunTestBase : AbpTestsBase + { + } +} diff --git a/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AbpAliyunSmsTestModule.cs b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AbpAliyunSmsTestModule.cs new file mode 100644 index 000000000..5cb689f41 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AbpAliyunSmsTestModule.cs @@ -0,0 +1,13 @@ +using LINGYUN.Abp.Aliyun; +using LINYUN.Abp.Sms.Aliyun; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Sms.Aliyun +{ + [DependsOn( + typeof(AbpAliyunTestModule), + typeof(AbpAliyunSmsModule))] + public class AbpAliyunSmsTestModule : AbpModule + { + } +} diff --git a/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSenderTests.cs b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSenderTests.cs new file mode 100644 index 000000000..4fca262d9 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Abp.Sms.Aliyun.Tests/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSenderTests.cs @@ -0,0 +1,43 @@ +using Microsoft.Extensions.Configuration; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.Sms; +using Xunit; + +namespace LINGYUN.Abp.Sms.Aliyun +{ + public class AliyunSmsSenderTests : AbpAliyunTestBase + { + protected ISmsSender SmsSender { get; } + protected IConfiguration Configuration { get; } + + public AliyunSmsSenderTests() + { + SmsSender = GetRequiredService(); + Configuration = GetRequiredService(); + } + + /// + /// 阿里云短信测试 + /// + /// + /// + [Theory] + [InlineData("123456")] + public async Task Send_Test(string code) + { + var signName = Configuration["Aliyun:Sms:Sender:SignName"]; + var phone = Configuration["Aliyun:Sms:Sender:PhoneNumber"]; + var template = Configuration["Aliyun:Sms:Sender:TemplateCode"]; + + await SmsSender.SendAsync( + signName, + template, + phone, + new Dictionary + { + { "code", code } + }); + } + } +} diff --git a/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj b/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj index bb6270b74..e9732a7bf 100644 --- a/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj @@ -13,10 +13,10 @@ - - - - + + + + diff --git a/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN.Platform.Domain.Tests.csproj b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN.Platform.Domain.Tests.csproj new file mode 100644 index 000000000..91ba94467 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN.Platform.Domain.Tests.csproj @@ -0,0 +1,22 @@ + + + + net5.0 + + false + + + + + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformDomainTestModule.cs b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformDomainTestModule.cs new file mode 100644 index 000000000..4fc231f73 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformDomainTestModule.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Data; +using Volo.Abp.Modularity; +using Volo.Abp.Threading; + +namespace LINGYUN.Platform +{ + [DependsOn( + typeof(PlatformDomainModule) + )] + public class PlatformDomainTestModule : AbpModule + { + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + SeedTestData(context); + } + + private static void SeedTestData(ApplicationInitializationContext context) + { + using (var scope = context.ServiceProvider.CreateScope()) + { + var dataSeeder = scope.ServiceProvider.GetRequiredService(); + AsyncHelper.RunSync(async () => + { + // Ԥ + await dataSeeder.SeedAsync(); + // Ԥ⻧ + await dataSeeder.SeedAsync(PlatformTestsConsts.TenantId); + }); + AsyncHelper.RunSync(async () => + { + await scope.ServiceProvider + .GetRequiredService() + .BuildAsync(); + }); + } + } + } +} diff --git a/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformTestsConsts.cs b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformTestsConsts.cs new file mode 100644 index 000000000..300992990 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformTestsConsts.cs @@ -0,0 +1,17 @@ +using System; + +namespace LINGYUN.Platform +{ + public static class PlatformTestsConsts + { + public static Guid User1Id { get; } = Guid.NewGuid(); + + public static Guid User2Id { get; } = Guid.NewGuid(); + + public static Guid TenantId { get; } = Guid.NewGuid(); + + public static string Role1Name { get; } = "TestRole1"; + + public static string Role2Name { get; } = "TestRole2"; + } +} diff --git a/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformTestsDataBuilder.cs b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformTestsDataBuilder.cs new file mode 100644 index 000000000..6d25dc4fb --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.Domain.Tests/LINGYUN/Platform/PlatformTestsDataBuilder.cs @@ -0,0 +1,65 @@ +using LINGYUN.Platform.Menus; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Uow; + +namespace LINGYUN.Platform +{ + public class PlatformTestsDataBuilder : ITransientDependency + { + private readonly ICurrentTenant _currentTenant; + + private readonly MenuManager _menuManager; + private readonly IMenuRepository _menuRepository; + + public PlatformTestsDataBuilder( + ICurrentTenant currentTenant, + MenuManager menuManager, + IMenuRepository menuRepository) + { + _currentTenant = currentTenant; + + _menuManager = menuManager; + _menuRepository = menuRepository; + } + + [UnitOfWork] + public async Task BuildAsync() + { + var adminMenu = await _menuRepository.FindByNameAsync("admin"); + + var saasMenu = await _menuRepository.FindByNameAsync("saas"); + await SetRoleMenusAsync(PlatformTestsConsts.Role1Name, new Guid[] { saasMenu.Id }); + await SetRoleMenusAsync(PlatformTestsConsts.Role2Name, new Guid[] { adminMenu.Id, saasMenu.Id }); + + await SetUserMenusAsync(PlatformTestsConsts.User1Id, new Guid[] { saasMenu.Id }); + + + using (_currentTenant.Change(PlatformTestsConsts.TenantId)) + { + var tenantAdminMenu = await _menuRepository.FindByNameAsync("admin"); + await SetUserMenusAsync(PlatformTestsConsts.User2Id, new Guid[] { tenantAdminMenu.Id }); + await SetRoleMenusAsync(PlatformTestsConsts.Role1Name, new Guid[] { tenantAdminMenu.Id }); + } + } + + private async Task SetUserMenusAsync(Guid userId, IEnumerable menusIds) + { + await _menuManager + .SetUserMenusAsync( + userId, + menusIds); + } + + private async Task SetRoleMenusAsync(string roleName, IEnumerable menusIds) + { + await _menuManager + .SetRoleMenusAsync( + roleName, + menusIds); + } + } +} diff --git a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN.Platform.EntityFrameworkCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN.Platform.EntityFrameworkCore.Tests.csproj new file mode 100644 index 000000000..fa63d1863 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN.Platform.EntityFrameworkCore.Tests.csproj @@ -0,0 +1,24 @@ + + + + net5.0 + + false + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreTestBase.cs b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreTestBase.cs new file mode 100644 index 000000000..9b4461df1 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreTestBase.cs @@ -0,0 +1,9 @@ +using LINGYUN.Abp.Tests; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + public class PlatformEntityFrameworkCoreTestBase : AbpTestsBase + { + + } +} diff --git a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreTestModule.cs b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreTestModule.cs new file mode 100644 index 000000000..f10539f66 --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/EntityFrameworkCore/PlatformEntityFrameworkCoreTestModule.cs @@ -0,0 +1,14 @@ +using LINGYUN.Abp.EntityFrameworkCore.Tests; +using Volo.Abp.Modularity; + +namespace LINGYUN.Platform.EntityFrameworkCore +{ + [DependsOn( + typeof(PlatformDomainTestModule), + typeof(PlatformEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreTestModule) + )] + public class PlatformEntityFrameworkCoreTestModule : AbpModule + { + } +} diff --git a/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs new file mode 100644 index 000000000..7ec5dd49f --- /dev/null +++ b/aspnet-core/tests/LINGYUN.Platform.EntityFrameworkCore.Tests/LINGYUN/Platform/Menus/EfCoreUserMenuRepositoryTests.cs @@ -0,0 +1,66 @@ +using LINGYUN.Platform.EntityFrameworkCore; +using Shouldly; +using System; +using System.Threading.Tasks; +using Volo.Abp.MultiTenancy; +using Xunit; + +namespace LINGYUN.Platform.Menus +{ + public class EfCoreUserMenuRepositoryTests : PlatformEntityFrameworkCoreTestBase + { + protected ICurrentTenant CurrentTenant { get; } + protected IUserMenuRepository Repository { get; } + protected IMenuRepository MenuRepository { get; } + protected MenuManager MenuManager { get; } + + public EfCoreUserMenuRepositoryTests() + { + MenuManager = GetRequiredService(); + Repository = GetRequiredService(); + MenuRepository = GetRequiredService(); + + CurrentTenant = GetRequiredService(); + } + + [Fact] + public async Task UserHasInMenuAsync_Test() + { + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User1Id, "saas")).ShouldBeTrue(); + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "admin")).ShouldBeFalse(); + + using (CurrentTenant.Change(PlatformTestsConsts.TenantId)) + { + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "admin")).ShouldBeTrue(); + } + } + + [Fact] + public async Task SetMemberMenusAsync_Test() + { + var adminMenu = await MenuRepository.FindByNameAsync("admin"); + var saasMenu = await MenuRepository.FindByNameAsync("saas"); + + await MenuManager.SetUserMenusAsync(PlatformTestsConsts.User1Id, new Guid[] { adminMenu.Id}); + await MenuManager.SetUserMenusAsync(PlatformTestsConsts.User2Id, new Guid[] { adminMenu.Id, saasMenu.Id }); + + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User1Id, "admin")).ShouldBeTrue(); + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "admin")).ShouldBeTrue(); + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "saas")).ShouldBeTrue(); + + using (CurrentTenant.Change(PlatformTestsConsts.TenantId)) + { + // 在租户范围不能查询到宿主数据 + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User1Id, "admin")).ShouldBeFalse(); + + var tenantSaasMenu = await MenuRepository.FindByNameAsync("saas"); + await MenuManager.SetUserMenusAsync(PlatformTestsConsts.User2Id, new Guid[] { tenantSaasMenu.Id }); + + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "admin")).ShouldBeFalse(); + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "saas")).ShouldBeTrue(); + } + // 在租户范围内处理了菜单数据不应该影响到宿主 + (await Repository.UserHasInMenuAsync(PlatformTestsConsts.User2Id, "admin")).ShouldBeTrue(); + } + } +}