mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-03 15:46:37 +08:00
chore: 构建稳定版本
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Guids;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
|
||||
{
|
||||
|
||||
public class DeptDataSeed : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<DeptEntity> _repository;
|
||||
private IGuidGenerator _guidGenerator;
|
||||
public DeptDataSeed(ISqlSugarRepository<DeptEntity> repository, IGuidGenerator guidGenerator)
|
||||
{
|
||||
_repository = repository;
|
||||
_guidGenerator = guidGenerator;
|
||||
}
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
if (!await _repository.IsAnyAsync(x => true))
|
||||
{
|
||||
await _repository.InsertManyAsync(GetSeedData());
|
||||
}
|
||||
}
|
||||
public List<DeptEntity> GetSeedData()
|
||||
{
|
||||
var entities = new List<DeptEntity>();
|
||||
|
||||
DeptEntity chengziDept = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
DeptName = "橙子科技",
|
||||
DeptCode = "Yi",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
Leader = "橙子",
|
||||
Remark = "如名所指"
|
||||
};
|
||||
entities.Add(chengziDept);
|
||||
|
||||
|
||||
DeptEntity shenzhenDept = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "深圳总公司",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = chengziDept.Id
|
||||
};
|
||||
entities.Add(shenzhenDept);
|
||||
|
||||
|
||||
DeptEntity jiangxiDept = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "江西总公司",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = chengziDept.Id
|
||||
};
|
||||
entities.Add(jiangxiDept);
|
||||
|
||||
|
||||
|
||||
DeptEntity szDept1 = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "研发部门",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = shenzhenDept.Id
|
||||
};
|
||||
entities.Add(szDept1);
|
||||
|
||||
DeptEntity szDept2 = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "市场部门",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = shenzhenDept.Id
|
||||
};
|
||||
entities.Add(szDept2);
|
||||
|
||||
DeptEntity szDept3 = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "测试部门",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = shenzhenDept.Id
|
||||
};
|
||||
entities.Add(szDept3);
|
||||
|
||||
DeptEntity szDept4 = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "财务部门",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = shenzhenDept.Id
|
||||
};
|
||||
entities.Add(szDept4);
|
||||
|
||||
DeptEntity szDept5 = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "运维部门",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = shenzhenDept.Id
|
||||
};
|
||||
entities.Add(szDept5);
|
||||
|
||||
|
||||
DeptEntity jxDept1 = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "市场部门",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = jiangxiDept.Id
|
||||
};
|
||||
entities.Add(jxDept1);
|
||||
|
||||
|
||||
DeptEntity jxDept2 = new DeptEntity(_guidGenerator.Create())
|
||||
{
|
||||
|
||||
DeptName = "财务部门",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false,
|
||||
ParentId = jiangxiDept.Id
|
||||
};
|
||||
entities.Add(jxDept2);
|
||||
|
||||
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
|
||||
{
|
||||
public class DictionaryDataSeed : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<DictionaryEntity> _repository;
|
||||
public DictionaryDataSeed(ISqlSugarRepository<DictionaryEntity> repository)
|
||||
{
|
||||
_repository= repository;
|
||||
}
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
if (!await _repository.IsAnyAsync(x => true))
|
||||
{
|
||||
await _repository.InsertManyAsync(GetSeedData());
|
||||
}
|
||||
}
|
||||
public List<DictionaryEntity> GetSeedData()
|
||||
{
|
||||
List<DictionaryEntity> entities = new List<DictionaryEntity>();
|
||||
DictionaryEntity dictInfo1 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "男",
|
||||
DictValue = "0",
|
||||
DictType = "sys_user_sex",
|
||||
OrderNum = 100,
|
||||
Remark = "性别男",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
|
||||
};
|
||||
entities.Add(dictInfo1);
|
||||
|
||||
DictionaryEntity dictInfo2 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "女",
|
||||
DictValue = "1",
|
||||
DictType = "sys_user_sex",
|
||||
OrderNum = 99,
|
||||
Remark = "性别女",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo2);
|
||||
|
||||
DictionaryEntity dictInfo3 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "未知",
|
||||
DictValue = "2",
|
||||
DictType = "sys_user_sex",
|
||||
OrderNum = 98,
|
||||
Remark = "性别未知",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo3);
|
||||
|
||||
|
||||
|
||||
DictionaryEntity dictInfo4 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "显示",
|
||||
DictValue = "true",
|
||||
DictType = "sys_show_hide",
|
||||
OrderNum = 100,
|
||||
Remark = "显示菜单",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo4);
|
||||
|
||||
DictionaryEntity dictInfo5 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "隐藏",
|
||||
DictValue = "false",
|
||||
DictType = "sys_show_hide",
|
||||
OrderNum = 99,
|
||||
Remark = "隐藏菜单",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo5);
|
||||
|
||||
|
||||
|
||||
DictionaryEntity dictInfo6 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "正常",
|
||||
DictValue = "true",
|
||||
DictType = "sys_normal_disable",
|
||||
OrderNum = 100,
|
||||
Remark = "正常状态",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo6);
|
||||
DictionaryEntity dictInfo7 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "停用",
|
||||
DictValue = "false",
|
||||
DictType = "sys_normal_disable",
|
||||
OrderNum = 99,
|
||||
Remark = "停用状态",
|
||||
IsDeleted = false,
|
||||
State = true,
|
||||
ListClass = "danger"
|
||||
};
|
||||
entities.Add(dictInfo7);
|
||||
|
||||
|
||||
|
||||
DictionaryEntity dictInfo8 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "正常",
|
||||
DictValue = "0",
|
||||
DictType = "sys_job_status",
|
||||
OrderNum = 100,
|
||||
Remark = "正常状态",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo8);
|
||||
DictionaryEntity dictInfo9 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "暂停",
|
||||
DictValue = "1",
|
||||
DictType = "sys_job_status",
|
||||
OrderNum = 99,
|
||||
Remark = "停用状态",
|
||||
IsDeleted = false,
|
||||
State = true,
|
||||
ListClass = "danger"
|
||||
};
|
||||
entities.Add(dictInfo9);
|
||||
|
||||
|
||||
|
||||
|
||||
DictionaryEntity dictInfo10 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "默认",
|
||||
DictValue = "DEFAULT",
|
||||
DictType = "sys_job_group",
|
||||
OrderNum = 100,
|
||||
Remark = "默认分组",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo10);
|
||||
DictionaryEntity dictInfo11 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "系统",
|
||||
DictValue = "SYSTEM",
|
||||
DictType = "sys_job_group",
|
||||
OrderNum = 99,
|
||||
Remark = "系统分组",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo11);
|
||||
|
||||
|
||||
|
||||
DictionaryEntity dictInfo12 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "是",
|
||||
DictValue = "Y",
|
||||
DictType = "sys_yes_no",
|
||||
OrderNum = 100,
|
||||
Remark = "系统默认是",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo12);
|
||||
DictionaryEntity dictInfo13 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "否",
|
||||
DictValue = "N",
|
||||
DictType = "sys_yes_no",
|
||||
OrderNum = 99,
|
||||
Remark = "系统默认否",
|
||||
IsDeleted = false,
|
||||
State = true,
|
||||
ListClass = "danger"
|
||||
};
|
||||
entities.Add(dictInfo13);
|
||||
|
||||
|
||||
|
||||
DictionaryEntity dictInfo14 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "通知",
|
||||
DictValue = "1",
|
||||
DictType = "sys_notice_type",
|
||||
OrderNum = 100,
|
||||
Remark = "通知",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo14);
|
||||
DictionaryEntity dictInfo15 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "公告",
|
||||
DictValue = "2",
|
||||
DictType = "sys_notice_type",
|
||||
OrderNum = 99,
|
||||
Remark = "公告",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo15);
|
||||
|
||||
DictionaryEntity dictInfo16 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "正常",
|
||||
DictValue = "0",
|
||||
DictType = "sys_notice_status",
|
||||
OrderNum = 100,
|
||||
Remark = "正常状态",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo16);
|
||||
DictionaryEntity dictInfo17 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "关闭",
|
||||
DictValue = "1",
|
||||
DictType = "sys_notice_status",
|
||||
OrderNum = 99,
|
||||
Remark = "关闭状态",
|
||||
IsDeleted = false,
|
||||
State = true,
|
||||
ListClass = "danger"
|
||||
};
|
||||
entities.Add(dictInfo17);
|
||||
|
||||
DictionaryEntity dictInfo18 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "新增",
|
||||
DictValue = "1",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 100,
|
||||
Remark = "新增操作",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo18);
|
||||
DictionaryEntity dictInfo19 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "修改",
|
||||
DictValue = "2",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 99,
|
||||
Remark = "修改操作",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo19);
|
||||
DictionaryEntity dictInfo22 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "删除",
|
||||
DictValue = "3",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 98,
|
||||
Remark = "删除操作",
|
||||
IsDeleted = false,
|
||||
State = true,
|
||||
ListClass = "danger"
|
||||
};
|
||||
entities.Add(dictInfo22);
|
||||
DictionaryEntity dictInfo23 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "授权",
|
||||
DictValue = "4",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 97,
|
||||
Remark = "授权操作",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo23);
|
||||
DictionaryEntity dictInfo24 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "导出",
|
||||
DictValue = "5",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 96,
|
||||
Remark = "导出操作",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo24);
|
||||
DictionaryEntity dictInfo25 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "导入",
|
||||
DictValue = "6",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 95,
|
||||
Remark = "导入操作",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo25);
|
||||
DictionaryEntity dictInfo26 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "强退",
|
||||
DictValue = "7",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 94,
|
||||
Remark = "强退操作",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo26);
|
||||
DictionaryEntity dictInfo27 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "生成代码",
|
||||
DictValue = "8",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 93,
|
||||
Remark = "生成代码操作",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo27);
|
||||
DictionaryEntity dictInfo28 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "清空数据",
|
||||
DictValue = "9",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 92,
|
||||
Remark = "清空数据操作",
|
||||
IsDeleted = false,
|
||||
State = true,
|
||||
ListClass = "danger"
|
||||
};
|
||||
entities.Add(dictInfo28);
|
||||
|
||||
|
||||
|
||||
DictionaryEntity dictInfo20 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "成功",
|
||||
DictValue = "false",
|
||||
DictType = "sys_common_status",
|
||||
OrderNum = 100,
|
||||
Remark = "正常状态",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dictInfo20);
|
||||
DictionaryEntity dictInfo21 = new DictionaryEntity()
|
||||
{
|
||||
|
||||
DictLabel = "失败",
|
||||
DictValue = "true",
|
||||
DictType = "sys_common_status",
|
||||
OrderNum = 99,
|
||||
Remark = "失败状态",
|
||||
IsDeleted = false,
|
||||
State = true,
|
||||
ListClass = "danger"
|
||||
};
|
||||
entities.Add(dictInfo21);
|
||||
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
|
||||
{
|
||||
public class DictionaryTypeDataSeed : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<DictionaryTypeEntity> _repository;
|
||||
public DictionaryTypeDataSeed(ISqlSugarRepository<DictionaryTypeEntity> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
if (!await _repository.IsAnyAsync(x => true))
|
||||
{
|
||||
await _repository.InsertManyAsync(GetSeedData());
|
||||
}
|
||||
}
|
||||
public List<DictionaryTypeEntity> GetSeedData()
|
||||
{
|
||||
List<DictionaryTypeEntity> entities = new List<DictionaryTypeEntity>();
|
||||
DictionaryTypeEntity dict1 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "用户性别",
|
||||
DictType = "sys_user_sex",
|
||||
OrderNum = 100,
|
||||
Remark = "用户性别列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict1);
|
||||
|
||||
DictionaryTypeEntity dict2 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "菜单状态",
|
||||
DictType = "sys_show_hide",
|
||||
OrderNum = 100,
|
||||
Remark = "菜单状态列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict2);
|
||||
|
||||
DictionaryTypeEntity dict3 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "系统开关",
|
||||
DictType = "sys_normal_disable",
|
||||
OrderNum = 100,
|
||||
Remark = "系统开关列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict3);
|
||||
|
||||
DictionaryTypeEntity dict4 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "任务状态",
|
||||
DictType = "sys_job_status",
|
||||
OrderNum = 100,
|
||||
Remark = "任务状态列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict4);
|
||||
|
||||
DictionaryTypeEntity dict5 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "任务分组",
|
||||
DictType = "sys_job_group",
|
||||
OrderNum = 100,
|
||||
Remark = "任务分组列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict5);
|
||||
|
||||
DictionaryTypeEntity dict6 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "系统是否",
|
||||
DictType = "sys_yes_no",
|
||||
OrderNum = 100,
|
||||
Remark = "系统是否列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict6);
|
||||
|
||||
DictionaryTypeEntity dict7 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "通知类型",
|
||||
DictType = "sys_notice_type",
|
||||
OrderNum = 100,
|
||||
Remark = "通知类型列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict7);
|
||||
DictionaryTypeEntity dict8 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "通知状态",
|
||||
DictType = "sys_notice_status",
|
||||
OrderNum = 100,
|
||||
Remark = "通知状态列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict8);
|
||||
|
||||
DictionaryTypeEntity dict9 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "操作类型",
|
||||
DictType = "sys_oper_type",
|
||||
OrderNum = 100,
|
||||
Remark = "操作类型列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict9);
|
||||
|
||||
|
||||
DictionaryTypeEntity dict10 = new DictionaryTypeEntity()
|
||||
{
|
||||
|
||||
DictName = "系统状态",
|
||||
DictType = "sys_common_status",
|
||||
OrderNum = 100,
|
||||
Remark = "登录状态列表",
|
||||
IsDeleted = false,
|
||||
State = true
|
||||
};
|
||||
entities.Add(dict10);
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
|
||||
{
|
||||
public class PostDataSeed : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<PostEntity> _repository;
|
||||
public PostDataSeed(ISqlSugarRepository<PostEntity> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
if (!await _repository.IsAnyAsync(x => true))
|
||||
{
|
||||
await _repository.InsertManyAsync(GetSeedData());
|
||||
}
|
||||
}
|
||||
public List<PostEntity> GetSeedData()
|
||||
{
|
||||
var entites = new List<PostEntity>();
|
||||
|
||||
PostEntity Post1 = new PostEntity()
|
||||
{
|
||||
|
||||
PostName = "董事长",
|
||||
PostCode = "ceo",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false
|
||||
};
|
||||
entites.Add(Post1);
|
||||
|
||||
PostEntity Post2 = new PostEntity()
|
||||
{
|
||||
|
||||
PostName = "项目经理",
|
||||
PostCode = "se",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false
|
||||
};
|
||||
entites.Add(Post2);
|
||||
|
||||
PostEntity Post3 = new PostEntity()
|
||||
{
|
||||
|
||||
PostName = "人力资源",
|
||||
PostCode = "hr",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false
|
||||
};
|
||||
entites.Add(Post3);
|
||||
|
||||
PostEntity Post4 = new PostEntity()
|
||||
{
|
||||
|
||||
PostName = "普通员工",
|
||||
PostCode = "user",
|
||||
OrderNum = 100,
|
||||
IsDeleted = false
|
||||
};
|
||||
|
||||
entites.Add(Post4);
|
||||
return entites;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.Rbac.Domain.Shared.Enums;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
|
||||
{
|
||||
public class RoleDataSeed : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<RoleEntity> _repository;
|
||||
public RoleDataSeed(ISqlSugarRepository<RoleEntity> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public List<RoleEntity> GetSeedData()
|
||||
{
|
||||
var entities = new List<RoleEntity>();
|
||||
RoleEntity role1 = new RoleEntity()
|
||||
{
|
||||
|
||||
RoleName = "管理员",
|
||||
RoleCode = "admin",
|
||||
DataScope = DataScopeEnum.ALL,
|
||||
OrderNum = 999,
|
||||
Remark = "管理员",
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(role1);
|
||||
|
||||
RoleEntity role2 = new RoleEntity()
|
||||
{
|
||||
|
||||
RoleName = "测试角色",
|
||||
RoleCode = "test",
|
||||
DataScope = DataScopeEnum.ALL,
|
||||
OrderNum = 1,
|
||||
Remark = "测试用的角色",
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(role2);
|
||||
|
||||
RoleEntity role3 = new RoleEntity()
|
||||
{
|
||||
|
||||
RoleName = "普通用户",
|
||||
RoleCode = "common",
|
||||
DataScope = DataScopeEnum.ALL,
|
||||
OrderNum = 1,
|
||||
Remark = "正常用户",
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(role3);
|
||||
|
||||
RoleEntity role4 = new RoleEntity()
|
||||
{
|
||||
|
||||
RoleName = "游客用户",
|
||||
RoleCode = "guest",
|
||||
DataScope = DataScopeEnum.ALL,
|
||||
OrderNum = 1,
|
||||
Remark = "可简单浏览",
|
||||
IsDeleted = false
|
||||
};
|
||||
entities.Add(role4);
|
||||
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
if (!await _repository.IsAnyAsync(x => true))
|
||||
{
|
||||
await _repository.InsertManyAsync(GetSeedData());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.Rbac.Domain.Entities;
|
||||
using Yi.Framework.Rbac.Domain.Shared.Enums;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.Rbac.SqlSugarCore.DataSeeds
|
||||
{
|
||||
public class UserDataSeed : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private ISqlSugarRepository<UserEntity> _repository;
|
||||
public UserDataSeed(ISqlSugarRepository<UserEntity> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
public async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
if (!await _repository.IsAnyAsync(x => true))
|
||||
{
|
||||
var entities = new List<UserEntity>();
|
||||
UserEntity user1 = new UserEntity()
|
||||
{
|
||||
Name = "大橙子",
|
||||
UserName = "cc",
|
||||
Nick = "橙子",
|
||||
Password = "123456",
|
||||
Email = "454313500@qq.com",
|
||||
Phone = 13800000000,
|
||||
Sex = SexEnum.Male,
|
||||
Address = "深圳",
|
||||
Age = 20,
|
||||
Introduction = "还有谁?",
|
||||
OrderNum = 999,
|
||||
Remark = "描述是什么呢?",
|
||||
State = true
|
||||
};
|
||||
user1.BuildPassword();
|
||||
entities.Add(user1);
|
||||
|
||||
UserEntity user2 = new UserEntity()
|
||||
{
|
||||
|
||||
Name = "大测试",
|
||||
UserName = "test",
|
||||
Nick = "测试",
|
||||
Password = "123456",
|
||||
Email = "454313500@qq.com",
|
||||
Phone = 15900000000,
|
||||
Sex = SexEnum.Woman,
|
||||
Address = "深圳",
|
||||
Age = 18,
|
||||
Introduction = "还有我!",
|
||||
OrderNum = 1,
|
||||
Remark = "我没有描述!",
|
||||
State = true
|
||||
|
||||
};
|
||||
user2.BuildPassword();
|
||||
entities.Add(user2);
|
||||
|
||||
UserEntity user3 = new UserEntity()
|
||||
{
|
||||
|
||||
Name = "游客",
|
||||
UserName = "guest",
|
||||
Nick = "测试",
|
||||
Password = "123456",
|
||||
Email = "454313500@qq.com",
|
||||
Phone = 15900000000,
|
||||
Sex = SexEnum.Woman,
|
||||
Address = "深圳",
|
||||
Age = 18,
|
||||
Introduction = "临时游客",
|
||||
OrderNum = 1,
|
||||
Remark = "懒得创账号",
|
||||
State = true
|
||||
|
||||
};
|
||||
user3.BuildPassword();
|
||||
entities.Add(user3);
|
||||
|
||||
|
||||
await _repository.InsertManyAsync(entities);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user