数据库种子初始化搭建
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -7,10 +8,10 @@ using Yi.Framework.Model.Models;
|
||||
|
||||
namespace Yi.Framework.Model.SeedData
|
||||
{
|
||||
public class SeedFactory
|
||||
public class SeedFactory
|
||||
{
|
||||
public static List<UserEntity> GetUserSeed()
|
||||
{
|
||||
{
|
||||
return new UserSeed().GetSeed();
|
||||
}
|
||||
public static List<RoleEntity> GetRoleSeed()
|
||||
@@ -21,9 +22,30 @@ namespace Yi.Framework.Model.SeedData
|
||||
{
|
||||
return new MenuSeed().GetSeed();
|
||||
}
|
||||
public static List<UserRoleEntity> GetUserRoleSeed(List<UserEntity> users,List<RoleEntity> roles)
|
||||
public static List<UserRoleEntity> GetUserRoleSeed(List<UserEntity> users, List<RoleEntity> roles)
|
||||
{
|
||||
return new List<UserRoleEntity>();
|
||||
List<UserRoleEntity> userRoleEntities = new();
|
||||
foreach (var u in users)
|
||||
{
|
||||
foreach (var r in roles)
|
||||
{
|
||||
userRoleEntities.Add(new UserRoleEntity() {Id= SnowFlakeSingle.Instance.NextId(),UserId = u.Id, RoleId = r.Id, IsDeleted = false });
|
||||
}
|
||||
}
|
||||
return userRoleEntities;
|
||||
}
|
||||
|
||||
public static List<RoleMenuEntity> GetRoleMenuSeed(List<RoleEntity> roles, List<MenuEntity> menus)
|
||||
{
|
||||
List<RoleMenuEntity> roleMenuEntities = new();
|
||||
foreach (var r in roles)
|
||||
{
|
||||
foreach (var m in menus)
|
||||
{
|
||||
roleMenuEntities.Add(new RoleMenuEntity() { Id = SnowFlakeSingle.Instance.NextId(), RoleId = r.Id, MenuId = m.Id, IsDeleted = false });
|
||||
}
|
||||
}
|
||||
return roleMenuEntities;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user