Setting Management: 用于持久化设置Setting值

一、定义SettingManagementOptions,多个设置值提供者,(与Volo.Abp.Settings模块ISettingValueProvider区别??

 public override void ConfigureServices(ServiceConfigurationContext context)
        {
            Configure<SettingManagementOptions>(options =>
            {
                options.Providers.Add<DefaultValueSettingManagementProvider>();
                options.Providers.Add<GlobalSettingManagementProvider>();
                options.Providers.Add<TenantSettingManagementProvider>();
                options.Providers.Add<UserSettingManagementProvider>();
            });
        }

  

1、实体  Setting : Entity<Guid>, IAggregateRoot<Guid>

 名称、值、提供名称(比如默认,全部,租户,用户),ProviderKey(可以租户Id,用户Id等)

2、服务

1、SettingStore,依赖ISettingManagementStore,获取设置值

2、ISettingManagementStore获取,设置,删除设置值,     依赖仓储ISettingRepository,分布式缓存IDistributedCache<SettingCacheItem>

3、ISettingManager,关联IOptions<SettingManagementOptions> options, IServiceProvider serviceProvider, ISettingDefinitionManager settingDefinitionManager,

ISettingEncryptionService settingEncryptionService,遍历List<ISettingManagementProvider>得到

3、UI层

1、配置导航菜单

    Configure<NavigationOptions>(options =>
            {
                options.MenuContributors.Add(new SettingManagementMainMenuContributor());
            });

 2、配置虚拟文件

   Configure<VirtualFileSystemOptions>(options =>
            {
                options.FileSets.AddEmbedded<AbpSettingManagementWebModule>("Volo.Abp.SettingManagement.Web");
            });

  3、配置本地化

  Configure<AbpLocalizationOptions>(options =>
            {
                options.Resources
                    .Add<AbpSettingManagementResource>("en");
            });

            Configure<AbpLocalizationOptions>(options =>
            {
                options.Resources
                    .Get<AbpSettingManagementResource>()
                    .AddVirtualJson("/Localization/Resources/AbpSettingManagement");
            });

  菜单路径:/SettingManagement,Abp的UI模块暂没有完善好

 

三、测试

同一配置名,可根据默认(从settingDefinitionContext里的SettingDefinition设置),全局,不同用户,租户可获取不同的值

posted on 2019-07-10 11:56  dollymi  阅读(859)  评论(0编辑  收藏  举报

导航