Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionOptions 配置类改成强名称 #109

Closed
BAI-HANK opened this issue Nov 13, 2023 · 1 comment
Closed

PermissionOptions 配置类改成强名称 #109

BAI-HANK opened this issue Nov 13, 2023 · 1 comment

Comments

@BAI-HANK
Copy link

PermissionOptions 配置类改成强名称,并且此类 abp 内部也存在同名的类,故建议改名为 PermissionExcludeOptions

public class BasicManagementApplicationModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddAutoMapperObjectMapper<BasicManagementApplicationModule>();
        Configure<AbpAutoMapperOptions>(options =>
        {
            options.AddMaps<BasicManagementApplicationModule>(validate: true);
        });
        
        Configure<PermissionOptions>(options =>
        {
            options.Excludes.Add("AbpIdentity.Users.ManagePermissions");
            options.Excludes.Add("AbpIdentity.UserLookup");
            options.Excludes.Add("FeatureManagement");
            options.Excludes.Add("FeatureManagement.ManageHostFeatures");
            options.Excludes.Add("SettingManagement");
            options.Excludes.Add("SettingManagement.Emailing");
            // options.Excludes.Add("AbpTenantManagement");
            options.Excludes.Add("AbpTenantManagement.Tenants.ManageFeatures");
            options.Excludes.Add("AbpTenantManagement.Tenants.ManageConnectionStrings");
        });
        
        context.Services.Configure<JwtOptions>(context.Services.GetConfiguration().GetSection("Jwt"));

        ConfigureMagicodes(context);
    }
    
    /// <summary>
    /// 配置Magicodes.IE
    /// Excel导入导出
    /// </summary>
    private void ConfigureMagicodes(ServiceConfigurationContext context)
    {
        context.Services.AddTransient<IExporter, ExcelExporter>();
        context.Services.AddTransient<IExcelExporter, ExcelExporter>();
    }
}

是否可以改成强名称的字符串

public class BasicManagementApplicationModule : AbpModule {
  public override void ConfigureServices(ServiceConfigurationContext context) {
   
    context.Services.AddAutoMapperObjectMapper<BasicManagementApplicationModule>();
    
    Configure<AbpAutoMapperOptions>(
      options => { options.AddMaps<BasicManagementApplicationModule>(true); });
      Configure<PermissionExcludesOptions>(options => {
      options.Excludes.Add( IdentityPermissions.Users.ManagePermissions);
      options.Excludes.Add(IdentityPermissions.UserLookup.Default);
      options.Excludes.Add(FeatureManagementPermissions.GroupName);
      options.Excludes.Add(FeatureManagementPermissions.ManageHostFeatures);
      options.Excludes.Add(SettingManagementPermissions.GroupName);
      options.Excludes.Add(SettingManagementPermissions.Emailing);
      // options.Excludes.Add("AbpTenantManagement");
      options.Excludes.Add(TenantManagementPermissions.Tenants.ManageFeatures);
      options.Excludes.Add(TenantManagementPermissions.Tenants.ManageConnectionStrings);
    });

    context.Services.Configure<JwtOptions>(context.Services.GetConfiguration().GetSection("Jwt"));

    ConfigureMagicodes(context);
  }

  /// <summary>
  // ReSharper disable once CommentTypo
  ///   配置 Magicodes.IE
  ///   Excel导入导出
  /// </summary>
  // ReSharper disable once IdentifierTypo
  private void ConfigureMagicodes(ServiceConfigurationContext context) {
    context.Services.AddTransient<IExporter, ExcelExporter>();
    context.Services.AddTransient<IExcelExporter, ExcelExporter>();
  }
}
@WangJunZzz
Copy link
Owner

🆗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants