diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index b434aa41..1aec3327 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -116,6 +116,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers //通过鉴权jwt获取到用户的id var userId = HttpContext.GetUserIdInfo(); var data = await _iUserService.GetUserAllInfo(userId); + //系统用户数据被重置,老前端访问重新授权 + if (data is null) + { + return Result.UnAuthorize(); + } + data.Menus.Clear(); return Result.Success().SetData(data); } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs index 55be5dd9..c2f7fdf3 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs @@ -219,6 +219,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers await rep.ChangeRepository>().DeleteAsync(u => true); await rep.ChangeRepository>().DeleteAsync(u => true); await rep.ChangeRepository>().DeleteAsync(u => true); + await rep.ChangeRepository>().DeleteAsync(u => true); + await rep.ChangeRepository>().DeleteAsync(u => true); })); } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index 614c01a7..467083e3 100644 Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ diff --git a/Yi.Framework.Net6/Yi.Framework.Model/MenuEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/MenuEntity.cs index dfca072a..446470f0 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/MenuEntity.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/MenuEntity.cs @@ -48,8 +48,6 @@ namespace Yi.Framework.Model.Models r.Component = m.Component; r.AlwaysShow = false; } - - r.Meta = new Meta { Title = m.MenuName, @@ -59,6 +57,7 @@ namespace Yi.Framework.Model.Models if ((bool)m.IsLink) { r.Meta.link = m.Router; + r.AlwaysShow = false; } routers.Add(r); diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DeptSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DeptSeed.cs new file mode 100644 index 00000000..559735d3 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DeptSeed.cs @@ -0,0 +1,130 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Enum; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class DeptSeed : AbstractSeed + { + public override List GetSeed() + { + + DeptEntity chengziDept = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "橙子科技", + DeptCode="Yi", + OrderNum =100, + IsDeleted = false, + ParentId=0, + Leader="橙子", + Remark="如名所指" + }; + Entitys.Add(chengziDept); + + + DeptEntity shenzhenDept = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "深圳总公司", + OrderNum = 100, + IsDeleted = false, + ParentId=chengziDept.Id + }; + Entitys.Add(shenzhenDept); + + + DeptEntity jiangxiDept = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "江西总公司", + OrderNum = 100, + IsDeleted = false, + ParentId = chengziDept.Id + }; + Entitys.Add(jiangxiDept); + + + + DeptEntity szDept1 = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "研发部门", + OrderNum = 100, + IsDeleted = false, + ParentId = shenzhenDept.Id + }; + Entitys.Add(szDept1); + + DeptEntity szDept2 = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "市场部门", + OrderNum = 100, + IsDeleted = false, + ParentId = shenzhenDept.Id + }; + Entitys.Add(szDept2); + + DeptEntity szDept3 = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "测试部门", + OrderNum = 100, + IsDeleted = false, + ParentId = shenzhenDept.Id + }; + Entitys.Add(szDept3); + + DeptEntity szDept4 = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "财务部门", + OrderNum = 100, + IsDeleted = false, + ParentId = shenzhenDept.Id + }; + Entitys.Add(szDept4); + + DeptEntity szDept5 = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "运维部门", + OrderNum = 100, + IsDeleted = false, + ParentId = shenzhenDept.Id + }; + Entitys.Add(szDept5); + + + DeptEntity jxDept1 = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "市场部门", + OrderNum = 100, + IsDeleted = false, + ParentId = jiangxiDept.Id + }; + Entitys.Add(jxDept1); + + + DeptEntity jxDept2 = new DeptEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DeptName = "财务部门", + OrderNum = 100, + IsDeleted = false, + ParentId = jiangxiDept.Id + }; + Entitys.Add(jxDept2); + + + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DictionaryInfoSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DictionaryInfoSeed.cs new file mode 100644 index 00000000..41beab8b --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/DictionaryInfoSeed.cs @@ -0,0 +1,284 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class DictionaryInfoSeed : AbstractSeed + { + public override List GetSeed() + { + DictionaryInfoEntity dictInfo1 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "男", + DictValue= "0", + DictType = "sys_user_sex", + OrderNum = 100, + Remark = "性别男", + IsDeleted = false, + }; + Entitys.Add(dictInfo1); + + DictionaryInfoEntity dictInfo2 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "女", + DictValue = "1", + DictType = "sys_user_sex", + OrderNum = 99, + Remark = "性别女", + IsDeleted = false, + }; + Entitys.Add(dictInfo2); + + DictionaryInfoEntity dictInfo3 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "未知", + DictValue = "2", + DictType = "sys_user_sex", + OrderNum = 98, + Remark = "性别未知", + IsDeleted = false, + }; + Entitys.Add(dictInfo3); + + + + DictionaryInfoEntity dictInfo4 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "显示", + DictValue = "0", + DictType = "sys_show_hide", + OrderNum = 100, + Remark = "显示菜单", + IsDeleted = false, + }; + Entitys.Add(dictInfo4); + + DictionaryInfoEntity dictInfo5 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "隐藏", + DictValue = "1", + DictType = "sys_show_hide", + OrderNum = 99, + Remark = "隐藏菜单", + IsDeleted = false, + }; + Entitys.Add(dictInfo5); + + + + DictionaryInfoEntity dictInfo6= new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "正常", + DictValue = "false", + DictType = "sys_normal_disable", + OrderNum = 100, + Remark = "正常状态", + IsDeleted = false, + }; + Entitys.Add(dictInfo6); + DictionaryInfoEntity dictInfo7 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "停用", + DictValue = "true", + DictType = "sys_normal_disable", + OrderNum = 99, + Remark = "停用状态", + IsDeleted = false, + ListClass= "danger" + }; + Entitys.Add(dictInfo7); + + + + DictionaryInfoEntity dictInfo8 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "正常", + DictValue = "0", + DictType = "sys_job_status", + OrderNum = 100, + Remark = "正常状态", + IsDeleted = false, + }; + Entitys.Add(dictInfo8); + DictionaryInfoEntity dictInfo9 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "暂停", + DictValue = "1", + DictType = "sys_job_status", + OrderNum = 99, + Remark = "停用状态", + IsDeleted = false, + ListClass = "danger" + }; + Entitys.Add(dictInfo9); + + + + + DictionaryInfoEntity dictInfo10 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "默认", + DictValue = "DEFAULT", + DictType = "sys_job_group", + OrderNum = 100, + Remark = "默认分组", + IsDeleted = false, + }; + Entitys.Add(dictInfo10); + DictionaryInfoEntity dictInfo11 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "系统", + DictValue = "SYSTEM", + DictType = "sys_job_group", + OrderNum = 99, + Remark = "系统分组", + IsDeleted = false, + }; + Entitys.Add(dictInfo11); + + + + DictionaryInfoEntity dictInfo12 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "是", + DictValue = "Y", + DictType = "sys_yes_no", + OrderNum = 100, + Remark = "系统默认是", + IsDeleted = false, + }; + Entitys.Add(dictInfo12); + DictionaryInfoEntity dictInfo13 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "否", + DictValue = "N", + DictType = "sys_yes_no", + OrderNum = 99, + Remark = "系统默认否", + IsDeleted = false, + ListClass = "danger" + }; + Entitys.Add(dictInfo13); + + + + DictionaryInfoEntity dictInfo14 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "通知", + DictValue = "1", + DictType = "sys_notice_type", + OrderNum = 100, + Remark = "通知", + IsDeleted = false, + }; + Entitys.Add(dictInfo14); + DictionaryInfoEntity dictInfo15 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "公告", + DictValue = "2", + DictType = "sys_notice_type", + OrderNum = 99, + Remark = "公告", + IsDeleted = false, + }; + Entitys.Add(dictInfo15); + + DictionaryInfoEntity dictInfo16 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "正常", + DictValue = "0", + DictType = "sys_notice_status", + OrderNum = 100, + Remark = "正常状态", + IsDeleted = false, + }; + Entitys.Add(dictInfo16); + DictionaryInfoEntity dictInfo17 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "关闭", + DictValue = "1", + DictType = "sys_notice_status", + OrderNum = 99, + Remark = "关闭状态", + IsDeleted = false, + ListClass = "danger" + }; + Entitys.Add(dictInfo17); + + DictionaryInfoEntity dictInfo18 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "正常", + DictValue = "0", + DictType = "sys_oper_type", + OrderNum = 100, + Remark = "正常状态", + IsDeleted = false, + }; + Entitys.Add(dictInfo18); + DictionaryInfoEntity dictInfo19 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "关闭", + DictValue = "1", + DictType = "sys_oper_type", + OrderNum = 99, + Remark = "关闭状态", + IsDeleted = false, + ListClass = "danger" + }; + Entitys.Add(dictInfo19); + + + + + DictionaryInfoEntity dictInfo20 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "成功", + DictValue = "0", + DictType = "sys_common_status", + OrderNum = 100, + Remark = "正常状态", + IsDeleted = false, + }; + Entitys.Add(dictInfo20); + DictionaryInfoEntity dictInfo21 = new DictionaryInfoEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + DictLabel = "失败", + DictValue = "1", + DictType = "sys_common_status", + OrderNum = 99, + Remark = "失败状态", + IsDeleted = false, + ListClass = "danger" + }; + Entitys.Add(dictInfo21); + + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs index aa87ea54..de7b0767 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/MenuSeed.cs @@ -18,7 +18,6 @@ namespace Yi.Framework.Model.SeedData { Id = SnowFlakeSingle.Instance.NextId(), MenuName = "系统管理", - //PermissionCode = "*:*:*", MenuType = MenuTypeEnum.Catalogue.GetHashCode(), Router = "/system", IsShow = true, @@ -30,6 +29,55 @@ namespace Yi.Framework.Model.SeedData }; Entitys.Add(system); + //系统监控 + MenuEntity monitoring = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "系统监控", + MenuType = MenuTypeEnum.Catalogue.GetHashCode(), + Router = "/monitor", + IsShow = true, + IsLink = false, + MenuIcon = "monitor", + OrderNum = 99, + ParentId = 0, + IsDeleted = false + }; + Entitys.Add(monitoring); + + //系统工具 + MenuEntity tool = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "系统工具", + MenuType = MenuTypeEnum.Catalogue.GetHashCode(), + Router = "/tool", + IsShow = true, + IsLink = false, + MenuIcon = "tool", + OrderNum = 98, + ParentId = 0, + IsDeleted = false + }; + Entitys.Add(tool); + + //Yi框架 + MenuEntity guide = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "Yi框架", + MenuType = MenuTypeEnum.Catalogue.GetHashCode(), + Router = "https://gitee.com/ccnetcore/yi", + IsShow = true, + IsLink = true, + MenuIcon = "guide", + OrderNum = 90, + ParentId = 0, + IsDeleted = false, + }; + Entitys.Add(guide); + + //用户管理 MenuEntity user = new MenuEntity() { @@ -437,6 +485,73 @@ namespace Yi.Framework.Model.SeedData Entitys.Add(dictRemove); + //参数设置 + MenuEntity config = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "参数设置", + PermissionCode = "system:config:list", + MenuType = MenuTypeEnum.Menu.GetHashCode(), + Router = "config", + IsShow = true, + IsLink = false, + IsCache = true, + Component = "system/config/index", + MenuIcon = "edit", + OrderNum = 100, + ParentId = system.Id, + IsDeleted = false + }; + Entitys.Add(config); + + MenuEntity configQuery = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "参数查询", + PermissionCode = "system:config:query", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + Entitys.Add(configQuery); + + MenuEntity configAdd = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "参数新增", + PermissionCode = "system:config:add", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + Entitys.Add(configAdd); + + MenuEntity configEdit = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "参数修改", + PermissionCode = "system:config:edit", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + Entitys.Add(configEdit); + + MenuEntity configRemove = new MenuEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + MenuName = "参数删除", + PermissionCode = "system:config:remove", + MenuType = MenuTypeEnum.Component.GetHashCode(), + OrderNum = 100, + ParentId = config.Id, + IsDeleted = false + }; + Entitys.Add(configRemove); + return Entitys; } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/PostSeed.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/PostSeed.cs new file mode 100644 index 00000000..b13ffc5c --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/PostSeed.cs @@ -0,0 +1,58 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Yi.Framework.Common.Enum; +using Yi.Framework.Model.Models; + +namespace Yi.Framework.Model.SeedData +{ + public class PostSeed : AbstractSeed + { + public override List GetSeed() + { + PostEntity Post1 = new PostEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + PostName = "董事长", + PostCode = "ceo", + OrderNum =100, + IsDeleted = false + }; + Entitys.Add(Post1); + + PostEntity Post2 = new PostEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + PostName = "项目经理", + PostCode = "se", + OrderNum = 100, + IsDeleted = false + }; + Entitys.Add(Post2); + + PostEntity Post3 = new PostEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + PostName = "人力资源", + PostCode = "hr", + OrderNum = 100, + IsDeleted = false + }; + Entitys.Add(Post3); + + PostEntity Post4 = new PostEntity() + { + Id = SnowFlakeSingle.Instance.NextId(), + PostName = "普通员工", + PostCode = "user", + OrderNum = 100, + IsDeleted = false + }; + Entitys.Add(Post4); + return Entitys; + } + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs index ee32cc57..d6cedacf 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/SeedData/SeedFactory.cs @@ -26,6 +26,20 @@ namespace Yi.Framework.Model.SeedData { return new DictionarySeed().GetSeed(); } + public static List GetPostSeed() + { + return new PostSeed().GetSeed(); + } + + public static List GetDictionaryInfoSeed() + { + return new DictionaryInfoSeed().GetSeed(); + } + + public static List GetDeptSeed() + { + return new DeptSeed().GetSeed(); + } public static List GetUserRoleSeed(List users, List roles) { List userRoleEntities = new(); diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs index 3c5eb373..2ae0bd44 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs @@ -154,6 +154,10 @@ namespace Yi.Framework.Service //得到用户 var user = await _repository._DbQueryable.Includes(u => u.Roles.Where(r => r.IsDeleted == false).ToList(), r => r.Menus.Where(m => m.IsDeleted == false).ToList()).InSingleAsync(userId); + if (user is null) + { + return null; + } user.Password = null; user.Salt = null; //得到角色集合 @@ -293,6 +297,6 @@ namespace Yi.Framework.Service userDto.User.DeptId = null; return await _repository.UpdateIgnoreNullAsync(userDto.User); } - + } } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs index 8e1b11fe..65462da3 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs @@ -24,6 +24,9 @@ namespace Yi.Framework.WebCore.DbExtend var roles = SeedFactory.GetRoleSeed(); var menus = SeedFactory.GetMenuSeed(); var dicts= SeedFactory.GetDictionarySeed(); + var posts = SeedFactory.GetPostSeed(); + var dictinfos= SeedFactory.GetDictionaryInfoSeed(); + var depts = SeedFactory.GetDeptSeed(); if (!_Db.Queryable().Any()) { _Db.Insertable(users).ExecuteCommand(); @@ -43,6 +46,20 @@ namespace Yi.Framework.WebCore.DbExtend { _Db.Insertable(dicts).ExecuteCommand(); } + if (!_Db.Queryable().Any()) + { + _Db.Insertable(posts).ExecuteCommand(); + } + if (!_Db.Queryable().Any()) + { + _Db.Insertable(dictinfos).ExecuteCommand(); + } + + + if (!_Db.Queryable().Any()) + { + _Db.Insertable(depts).ExecuteCommand(); + } if (!_Db.Queryable().Any()) {