• DataSeeder


    首先是实现IDataSeedContributor接口,此类型会自动加到AbpDataOptions的Contributors的列表

        public interface IDataSeedContributor
        {
            Task SeedAsync(DataSeedContext context);
        }

    IDataSeeder利用Contributors,逐个取出实例化进行执行,其中DataSeedContext是TenantId和自定义的Dictionary<string, object> Properties

    扩展一个SeedAsync方法tenantId,如果在多租户的环境,注意要带上

     public static Task SeedAsync(this IDataSeeder seeder, Guid? tenantId = null)
            {
                return seeder.SeedAsync(new DataSeedContext(tenantId));
            }

    ABP应用框架增加了两个方法,分别是用户和角色,以及权限 

    Volo.Abp.PermissionManagement

    IPermissionDataSeeder

    public virtual Task SeedAsync(DataSeedContext context)
            {
                var multiTenancySide = CurrentTenant.GetMultiTenancySide();
                var permissionNames = PermissionDefinitionManager
                    .GetPermissions()
                    .Where(p => p.MultiTenancySide.HasFlag(multiTenancySide))
                    .Select(p => p.Name)
                    .ToArray();
    
                return PermissionDataSeeder.SeedAsync(
                    RolePermissionValueProvider.ProviderName,
                    "admin",
                    permissionNames,
                    context.TenantId
                );
            }

    2、IIdentityDataSeeder

    Volo.Abp.Identity 

     public Task SeedAsync(DataSeedContext context)
            {
                return _identityDataSeeder.SeedAsync(
                    context["AdminEmail"] as string ?? "admin@abp.io",
                    context["AdminPassword"] as string ?? "1q2w3E*",
                    context.TenantId
                );
            }
  • 相关阅读:
    c++字符串排序
    JAVA实现四则运算的简单计算器
    JAVA图形小动画之简单行星运动
    JAVA多线程编程
    ege图形库之简单贪吃蛇(c++)
    ege图形库之动画排序
    mysql 性能优化方案
    MYSQL 优化常用方法
    [手把手教你] 用Swoft 搭建微服务(TCP RPC)
    php有效防止同一用户多次登录
  • 原文地址:https://www.cnblogs.com/cloudsu/p/11961047.html
Copyright © 2020-2023  润新知