From fa9be364dac5f250d103ff08a248b4d6fdca8b1f Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Fri, 26 Aug 2022 11:43:58 +0800 Subject: [PATCH] feature: add push setting-management --- aspnet-core/LINGYUN.MicroService.Common.sln | 22 ++++-- .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++++++ ...GYUN.Abp.PushPlus.SettingManagement.csproj | 29 ++++++++ .../AbpPushPlusSettingManagementModule.cs | 48 +++++++++++++ .../IPushPlusSettingAppService.cs | 8 +++ .../Localization/Resources/en.json | 7 ++ .../Localization/Resources/zh-Hans.json | 7 ++ .../PushPlusSettingAppService.cs | 67 +++++++++++++++++++ .../PushPlusSettingController.cs | 36 ++++++++++ ...PlusSettingPermissionDefinitionProvider.cs | 24 +++++++ .../PushPlusSettingPermissionNames.cs | 9 +++ ...AbpSettingManagementRemoteServiceConsts.cs | 1 + .../FodyWeavers.xml | 3 + .../FodyWeavers.xsd | 30 +++++++++ ...GYUN.Abp.WxPusher.SettingManagement.csproj | 29 ++++++++ .../AbpWxPusherSettingManagementModule.cs | 48 +++++++++++++ .../IWxPusherSettingAppService.cs | 8 +++ .../Localization/Resources/en.json | 7 ++ .../Localization/Resources/zh-Hans.json | 7 ++ .../WxPusherSettingAppService.cs | 61 +++++++++++++++++ .../WxPusherSettingController.cs | 36 ++++++++++ ...sherSettingPermissionDefinitionProvider.cs | 24 +++++++ .../WxPusherSettingPermissionNames.cs | 9 +++ .../LINGYUN.Abp.WxPusher.csproj | 6 +- .../WxPusher/Localization/Resources/en.json | 5 +- .../Localization/Resources/zh-Hans.json | 5 +- 27 files changed, 559 insertions(+), 10 deletions(-) create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xml create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xsd create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/AbpPushPlusSettingManagementModule.cs create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/IPushPlusSettingAppService.cs create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/en.json create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/zh-Hans.json create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionDefinitionProvider.cs create mode 100644 aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionNames.cs create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xml create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xsd create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/AbpWxPusherSettingManagementModule.cs create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/IWxPusherSettingAppService.cs create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/en.json create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/zh-Hans.json create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingController.cs create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionDefinitionProvider.cs create mode 100644 aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionNames.cs diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln index 0a312b43c..43f6a5e48 100644 --- a/aspnet-core/LINGYUN.MicroService.Common.sln +++ b/aspnet-core/LINGYUN.MicroService.Common.sln @@ -252,13 +252,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.PushPlus.Tests" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wx-pusher", "wx-pusher", "{7862CE70-76EF-4228-A703-C2E2A9704D14}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WxPusher", "modules\wx-pusher\LINGYUN.Abp.WxPusher\LINGYUN.Abp.WxPusher.csproj", "{1A072FF5-1A7E-4F78-B145-1AB873AEB8FF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WxPusher", "modules\wx-pusher\LINGYUN.Abp.WxPusher\LINGYUN.Abp.WxPusher.csproj", "{1A072FF5-1A7E-4F78-B145-1AB873AEB8FF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WxPusher.Tests", "tests\LINGYUN.Abp.WxPusher.Tests\LINGYUN.Abp.WxPusher.Tests.csproj", "{88412E3D-21C8-4FF1-8EB3-84CB74094336}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.WxPusher.Tests", "tests\LINGYUN.Abp.WxPusher.Tests\LINGYUN.Abp.WxPusher.Tests.csproj", "{88412E3D-21C8-4FF1-8EB3-84CB74094336}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Notifications.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Notifications.WxPusher\LINGYUN.Abp.Notifications.WxPusher.csproj", "{F65A8835-C50F-43B0-B54C-196A92E9539F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Notifications.WxPusher\LINGYUN.Abp.Notifications.WxPusher.csproj", "{F65A8835-C50F-43B0-B54C-196A92E9539F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Identity.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Identity.WxPusher\LINGYUN.Abp.Identity.WxPusher.csproj", "{30FA01ED-921A-4E7D-9E83-6719538FB866}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Identity.WxPusher", "modules\wx-pusher\LINGYUN.Abp.Identity.WxPusher\LINGYUN.Abp.Identity.WxPusher.csproj", "{30FA01ED-921A-4E7D-9E83-6719538FB866}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WxPusher.SettingManagement", "modules\wx-pusher\LINGYUN.Abp.WxPusher.SettingManagement\LINGYUN.Abp.WxPusher.SettingManagement.csproj", "{E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.PushPlus.SettingManagement", "modules\pushplus\LINGYUN.Abp.PushPlus.SettingManagement\LINGYUN.Abp.PushPlus.SettingManagement.csproj", "{4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -666,6 +670,14 @@ Global {30FA01ED-921A-4E7D-9E83-6719538FB866}.Debug|Any CPU.Build.0 = Debug|Any CPU {30FA01ED-921A-4E7D-9E83-6719538FB866}.Release|Any CPU.ActiveCfg = Release|Any CPU {30FA01ED-921A-4E7D-9E83-6719538FB866}.Release|Any CPU.Build.0 = Release|Any CPU + {E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36}.Release|Any CPU.Build.0 = Release|Any CPU + {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -795,6 +807,8 @@ Global {88412E3D-21C8-4FF1-8EB3-84CB74094336} = {B86C21A4-73B7-471E-B73A-B4B905EC9435} {F65A8835-C50F-43B0-B54C-196A92E9539F} = {7862CE70-76EF-4228-A703-C2E2A9704D14} {30FA01ED-921A-4E7D-9E83-6719538FB866} = {7862CE70-76EF-4228-A703-C2E2A9704D14} + {E6FDAD7B-4A7F-4CEB-9891-F8FC4E556C36} = {7862CE70-76EF-4228-A703-C2E2A9704D14} + {4CBB4A0C-6D23-44DD-BAF4-49D69ED35839} = {0F5A2591-CE08-4184-A5F3-89F6FB3B2B10} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {06C707C6-02C0-411A-AD3B-2D0E13787CB8} diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xml b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xsd b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj new file mode 100644 index 000000000..304159eae --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN.Abp.PushPlus.SettingManagement.csproj @@ -0,0 +1,29 @@ + + + + + + + net6.0 + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/AbpPushPlusSettingManagementModule.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/AbpPushPlusSettingManagementModule.cs new file mode 100644 index 000000000..225a44678 --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/AbpPushPlusSettingManagementModule.cs @@ -0,0 +1,48 @@ +using LINGYUN.Abp.PushPlus.Localization; +using Localization.Resources.AbpUi; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.PushPlus.SettingManagement +{ + [DependsOn( + typeof(AbpPushPlusModule), + typeof(AbpAspNetCoreMvcModule))] + public class AbpPushPlusSettingManagementModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpPushPlusSettingManagementModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources"); + }); + + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes( + typeof(AbpUiResource) + ); + }); + } + } +} diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/IPushPlusSettingAppService.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/IPushPlusSettingAppService.cs new file mode 100644 index 000000000..83fb33698 --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/IPushPlusSettingAppService.cs @@ -0,0 +1,8 @@ +using LINGYUN.Abp.SettingManagement; + +namespace LINGYUN.Abp.PushPlus.SettingManagement +{ + public interface IPushPlusSettingAppService : IReadonlySettingAppService + { + } +} diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/en.json b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/en.json new file mode 100644 index 000000000..93c87e713 --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/en.json @@ -0,0 +1,7 @@ +{ + "culture": "en", + "texts": { + "Permission:PushPlus": "PushPlus", + "Permission:ManageSetting": "Manage Setting" + } +} \ No newline at end of file diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/zh-Hans.json b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/zh-Hans.json new file mode 100644 index 000000000..07b346adf --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/Localization/Resources/zh-Hans.json @@ -0,0 +1,7 @@ +{ + "culture": "zh-Hans", + "texts": { + "Permission:PushPlus": "PushPlus", + "Permission:ManageSetting": "管理设置" + } +} \ No newline at end of file diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs new file mode 100644 index 000000000..449152ea5 --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingAppService.cs @@ -0,0 +1,67 @@ +using LINGYUN.Abp.SettingManagement; +using LINGYUN.Abp.PushPlus.Localization; +using LINGYUN.Abp.PushPlus.Settings; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.MultiTenancy; +using Volo.Abp.SettingManagement; +using Volo.Abp.Settings; + +namespace LINGYUN.Abp.PushPlus.SettingManagement +{ + public class WxPusherSettingAppService : ApplicationService, IPushPlusSettingAppService + { + protected ISettingManager SettingManager { get; } + protected IPermissionChecker PermissionChecker { get; } + protected ISettingDefinitionManager SettingDefinitionManager { get; } + + public WxPusherSettingAppService( + ISettingManager settingManager, + IPermissionChecker permissionChecker, + ISettingDefinitionManager settingDefinitionManager) + { + SettingManager = settingManager; + PermissionChecker = permissionChecker; + SettingDefinitionManager = settingDefinitionManager; + LocalizationResource = typeof(PushPlusResource); + } + + public async virtual Task GetAllForCurrentTenantAsync() + { + return await GetAllForProviderAsync(TenantSettingValueProvider.ProviderName, CurrentTenant.GetId().ToString()); + } + + public async virtual Task GetAllForGlobalAsync() + { + return await GetAllForProviderAsync(GlobalSettingValueProvider.ProviderName, null); + } + + protected async virtual Task GetAllForProviderAsync(string providerName, string providerKey) + { + var settingGroups = new SettingGroupResult(); + var pushPlusSettingGroup = new SettingGroupDto(L["DisplayName:PushPlus"], L["Description:PushPlus"]); + + if (await PermissionChecker.IsGrantedAsync(PushPlusSettingPermissionNames.ManageSetting)) + { + var securitySetting = pushPlusSettingGroup.AddSetting(L["Security"], L["Security"]); + securitySetting.AddDetail( + SettingDefinitionManager.Get(PushPlusSettingNames.Security.Token), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(PushPlusSettingNames.Security.Token, providerName, providerKey), + ValueType.String, + providerName); + securitySetting.AddDetail( + SettingDefinitionManager.Get(PushPlusSettingNames.Security.SecretKey), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(PushPlusSettingNames.Security.SecretKey, providerName, providerKey), + ValueType.String, + providerName); + } + + settingGroups.AddGroup(pushPlusSettingGroup); + + return settingGroups; + } + } +} diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs new file mode 100644 index 000000000..70ea9750c --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingController.cs @@ -0,0 +1,36 @@ +using LINGYUN.Abp.SettingManagement; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.PushPlus.SettingManagement +{ + [RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)] + [Area(AbpSettingManagementRemoteServiceConsts.ModuleName)] + [Route($"api/{AbpSettingManagementRemoteServiceConsts.ModuleName}/push-plus")] + public class WxPusherSettingController : AbpController, IPushPlusSettingAppService + { + protected IPushPlusSettingAppService Service { get; } + + public WxPusherSettingController( + IPushPlusSettingAppService service) + { + Service = service; + } + + [HttpGet] + [Route("by-current-tenant")] + public async virtual Task GetAllForCurrentTenantAsync() + { + return await Service.GetAllForCurrentTenantAsync(); + } + + [HttpGet] + [Route("by-global")] + public async virtual Task GetAllForGlobalAsync() + { + return await Service.GetAllForGlobalAsync(); + } + } +} diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionDefinitionProvider.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionDefinitionProvider.cs new file mode 100644 index 000000000..45fa68e60 --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionDefinitionProvider.cs @@ -0,0 +1,24 @@ +using LINGYUN.Abp.PushPlus.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.PushPlus.SettingManagement +{ + public class PushPlusSettingPermissionDefinitionProvider : PermissionDefinitionProvider + { + public override void Define(IPermissionDefinitionContext context) + { + var pushPlusGroup = context.AddGroup( + PushPlusSettingPermissionNames.GroupName, + L("Permission:PushPlus")); + + pushPlusGroup.AddPermission( + PushPlusSettingPermissionNames.ManageSetting, L("Permission:ManageSetting")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionNames.cs b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionNames.cs new file mode 100644 index 000000000..c5f9af80d --- /dev/null +++ b/aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus.SettingManagement/LINGYUN/Abp/PushPlus/SettingManagement/PushPlusSettingPermissionNames.cs @@ -0,0 +1,9 @@ +namespace LINGYUN.Abp.PushPlus.SettingManagement +{ + public class PushPlusSettingPermissionNames + { + public const string GroupName = "Abp.PushPlus"; + + public const string ManageSetting = GroupName + ".ManageSetting"; + } +} diff --git a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN/Abp/SettingManagement/AbpSettingManagementRemoteServiceConsts.cs b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN/Abp/SettingManagement/AbpSettingManagementRemoteServiceConsts.cs index 3035f4deb..368a7ffdf 100644 --- a/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN/Abp/SettingManagement/AbpSettingManagementRemoteServiceConsts.cs +++ b/aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN/Abp/SettingManagement/AbpSettingManagementRemoteServiceConsts.cs @@ -2,6 +2,7 @@ { public class AbpSettingManagementRemoteServiceConsts { + public const string ModuleName = "setting-management"; public const string RemoteServiceName = "AbpSettingManagement"; } } \ No newline at end of file diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xml b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xml new file mode 100644 index 000000000..1715698cc --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xsd b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj new file mode 100644 index 000000000..24ac4881b --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN.Abp.WxPusher.SettingManagement.csproj @@ -0,0 +1,29 @@ + + + + + + + net6.0 + + + + + + + + + + + + + + + + + + + + + + diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/AbpWxPusherSettingManagementModule.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/AbpWxPusherSettingManagementModule.cs new file mode 100644 index 000000000..3fd735933 --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/AbpWxPusherSettingManagementModule.cs @@ -0,0 +1,48 @@ +using LINGYUN.Abp.WxPusher.Localization; +using Localization.Resources.AbpUi; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace LINGYUN.Abp.WxPusher.SettingManagement +{ + [DependsOn( + typeof(AbpWxPusherModule), + typeof(AbpAspNetCoreMvcModule))] + public class AbpWxPusherSettingManagementModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpWxPusherSettingManagementModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Get() + .AddVirtualJson("/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources"); + }); + + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes( + typeof(AbpUiResource) + ); + }); + } + } +} diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/IWxPusherSettingAppService.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/IWxPusherSettingAppService.cs new file mode 100644 index 000000000..a51e6bba9 --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/IWxPusherSettingAppService.cs @@ -0,0 +1,8 @@ +using LINGYUN.Abp.SettingManagement; + +namespace LINGYUN.Abp.WxPusher.SettingManagement +{ + public interface IWxPusherSettingAppService : IReadonlySettingAppService + { + } +} diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/en.json b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/en.json new file mode 100644 index 000000000..9fd24fc75 --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/en.json @@ -0,0 +1,7 @@ +{ + "culture": "en", + "texts": { + "Permission:WxPusher": "WxPusher", + "Permission:ManageSetting": "Manage Setting" + } +} \ No newline at end of file diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/zh-Hans.json b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/zh-Hans.json new file mode 100644 index 000000000..724cc21f8 --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/Localization/Resources/zh-Hans.json @@ -0,0 +1,7 @@ +{ + "culture": "zh-Hans", + "texts": { + "Permission:WxPusher": "WxPusher", + "Permission:ManageSetting": "管理设置" + } +} \ No newline at end of file diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs new file mode 100644 index 000000000..d337079cd --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingAppService.cs @@ -0,0 +1,61 @@ +using LINGYUN.Abp.SettingManagement; +using LINGYUN.Abp.WxPusher.Localization; +using LINGYUN.Abp.WxPusher.Settings; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.MultiTenancy; +using Volo.Abp.SettingManagement; +using Volo.Abp.Settings; + +namespace LINGYUN.Abp.WxPusher.SettingManagement +{ + public class WxPusherSettingAppService : ApplicationService, IWxPusherSettingAppService + { + protected ISettingManager SettingManager { get; } + protected IPermissionChecker PermissionChecker { get; } + protected ISettingDefinitionManager SettingDefinitionManager { get; } + + public WxPusherSettingAppService( + ISettingManager settingManager, + IPermissionChecker permissionChecker, + ISettingDefinitionManager settingDefinitionManager) + { + SettingManager = settingManager; + PermissionChecker = permissionChecker; + SettingDefinitionManager = settingDefinitionManager; + LocalizationResource = typeof(WxPusherResource); + } + + public async virtual Task GetAllForCurrentTenantAsync() + { + return await GetAllForProviderAsync(TenantSettingValueProvider.ProviderName, CurrentTenant.GetId().ToString()); + } + + public async virtual Task GetAllForGlobalAsync() + { + return await GetAllForProviderAsync(GlobalSettingValueProvider.ProviderName, null); + } + + protected async virtual Task GetAllForProviderAsync(string providerName, string providerKey) + { + var settingGroups = new SettingGroupResult(); + var wxPusherSettingGroup = new SettingGroupDto(L["DisplayName:WxPusher"], L["Description:WxPusher"]); + + if (await PermissionChecker.IsGrantedAsync(WxPusherSettingPermissionNames.ManageSetting)) + { + var securitySetting = wxPusherSettingGroup.AddSetting(L["Security"], L["Security"]); + securitySetting.AddDetail( + SettingDefinitionManager.Get(WxPusherSettingNames.Security.AppToken), + StringLocalizerFactory, + await SettingManager.GetOrNullAsync(WxPusherSettingNames.Security.AppToken, providerName, providerKey), + ValueType.String, + providerName); + } + + settingGroups.AddGroup(wxPusherSettingGroup); + + return settingGroups; + } + } +} diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingController.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingController.cs new file mode 100644 index 000000000..453020c31 --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingController.cs @@ -0,0 +1,36 @@ +using LINGYUN.Abp.SettingManagement; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc; + +namespace LINGYUN.Abp.WxPusher.SettingManagement +{ + [RemoteService(Name = AbpSettingManagementRemoteServiceConsts.RemoteServiceName)] + [Area(AbpSettingManagementRemoteServiceConsts.ModuleName)] + [Route($"api/{AbpSettingManagementRemoteServiceConsts.ModuleName}/wx-pusher")] + public class WxPusherSettingController : AbpController, IWxPusherSettingAppService + { + protected IWxPusherSettingAppService Service { get; } + + public WxPusherSettingController( + IWxPusherSettingAppService service) + { + Service = service; + } + + [HttpGet] + [Route("by-current-tenant")] + public async virtual Task GetAllForCurrentTenantAsync() + { + return await Service.GetAllForCurrentTenantAsync(); + } + + [HttpGet] + [Route("by-global")] + public async virtual Task GetAllForGlobalAsync() + { + return await Service.GetAllForGlobalAsync(); + } + } +} diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionDefinitionProvider.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionDefinitionProvider.cs new file mode 100644 index 000000000..7256f2e51 --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionDefinitionProvider.cs @@ -0,0 +1,24 @@ +using LINGYUN.Abp.WxPusher.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace LINGYUN.Abp.WxPusher.SettingManagement +{ + public class WxPusherSettingPermissionDefinitionProvider : PermissionDefinitionProvider + { + public override void Define(IPermissionDefinitionContext context) + { + var wxPusherGroup = context.AddGroup( + WxPusherSettingPermissionNames.GroupName, + L("Permission:WxPusher")); + + wxPusherGroup.AddPermission( + WxPusherSettingPermissionNames.ManageSetting, L("Permission:ManageSetting")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionNames.cs b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionNames.cs new file mode 100644 index 000000000..6fa23ddcd --- /dev/null +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher.SettingManagement/LINGYUN/Abp/WxPusher/SettingManagement/WxPusherSettingPermissionNames.cs @@ -0,0 +1,9 @@ +namespace LINGYUN.Abp.WxPusher.SettingManagement +{ + public class WxPusherSettingPermissionNames + { + public const string GroupName = "Abp.WxPusher"; + + public const string ManageSetting = GroupName + ".ManageSetting"; + } +} diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj index cf5c943d2..206c5d785 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj @@ -9,13 +9,11 @@ - - + - - + diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/en.json b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/en.json index cdea368c4..4c3d3dd8b 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/en.json +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/en.json @@ -1,6 +1,8 @@ { "culture": "en", "texts": { + "DisplayName:WxPusher": "WxPusher", + "Description:WxPusher": "WxPusher", "Settings:Security.AppToken": "App Token", "Settings:Security.AppTokenDesc": "If you have APP_TOKEN, you can send messages to users of the corresponding application. Keep it confidential.", "Features:WxPusher": "WxPusher Wechat push service", @@ -12,6 +14,7 @@ "Features:Message.SendLimit": "Amount of wechat message push", "Features:Message.SendLimitDesc": "Set to limit the amount of wechat message push.", "Features:Message.SendLimitInterval": "Wechat message limit interval", - "Features:Message.SendLimitIntervalDesc": "Set the wechat message limit period (time scale: days). A single wechat user (UID) can receive a maximum of 500 messages per day. Please arrange the sending frequency reasonably." + "Features:Message.SendLimitIntervalDesc": "Set the wechat message limit period (time scale: days). A single wechat user (UID) can receive a maximum of 500 messages per day. Please arrange the sending frequency reasonably.", + "Security": "Security" } } \ No newline at end of file diff --git a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/zh-Hans.json b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/zh-Hans.json index f4b5a1bae..11636f0e1 100644 --- a/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/zh-Hans.json +++ b/aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/Localization/Resources/zh-Hans.json @@ -1,6 +1,8 @@ { "culture": "zh-Hans", "texts": { + "DisplayName:WxPusher": "WxPusher", + "Description:WxPusher": "WxPusher", "Settings:Security.AppToken": "应用的身份标志", "Settings:Security.AppTokenDesc": "拥有APP_TOKEN,就可以给对应的应用的用户发送消息, 请严格保密.", "Features:WxPusher": "WxPusher微信推送服务", @@ -12,6 +14,7 @@ "Features:Message.SendLimit": "微信消息推送量", "Features:Message.SendLimitDesc": "设置以限制微信消息推送量.", "Features:Message.SendLimitInterval": "微信消息限制周期", - "Features:Message.SendLimitIntervalDesc": "设置微信消息限制周期(时间刻度: 天).单个微信用户(uid),每天最多接收500条消息,请合理安排发送频率." + "Features:Message.SendLimitIntervalDesc": "设置微信消息限制周期(时间刻度: 天).单个微信用户(uid),每天最多接收500条消息,请合理安排发送频率.", + "Security": "安全选项" } } \ No newline at end of file