diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs index eab50a11..0b746043 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -26,9 +26,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpGet] public async Task GetMenu() { - //var top =await _menuService.GetTopMenu(); - //var children=await _menuService.get - return Result.Success().SetData(await _menuService.GetTopMenu()); + + return Result.Success().SetData(await _menuService.GetMenuMould()); } /// diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs index befb426c..eac2eb9a 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -74,5 +74,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers await _roleService.SetMenusByRolesId(idsListDto.ids2, idsListDto.ids1); return Result.Success(); } + + + } } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs index d56a98e3..0b1f374b 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -97,5 +97,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers await _userService.SetRolesByUser(idsListDto.ids2, idsListDto.ids1); return Result.Success(); } + /// + /// 根据http上下文的用户得到该用户有哪些角色 + /// + /// + [HttpGet] + public async Task GetRolesByUser() + { + var _user = HttpContext.GetCurrentUserInfo(); + var roleList = await _userService.GetRolesByUser(_user); + return Result.Success().SetData(roleList); + } + } } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db index 8173bcc1..e304553a 100644 Binary files a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db and b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db differ diff --git a/Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs b/Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs new file mode 100644 index 00000000..cbd8ea1b --- /dev/null +++ b/Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Enum +{ + public enum ShowFlagEnum + { + NoShow=0, + Show=1 + } +} diff --git a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs index 1c77e4b2..e0d24536 100644 --- a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs @@ -60,6 +60,6 @@ namespace Yi.Framework.Interface /// /// Task> GetChildrenMenu(menu _menu); - + Task> GetMenuMould(); } } diff --git a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs index e06f3337..e41b3efd 100644 --- a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs @@ -34,5 +34,6 @@ namespace Yi.Framework.Interface /// Task SetMenusByRolesId(List menuIds, List roleIds); + } } diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework/Yi.Framework.Interface/IUserService.cs index 27c5c206..1e1bad92 100644 --- a/Yi.Framework/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IUserService.cs @@ -25,9 +25,8 @@ namespace Yi.Framework.Interface Task Register(user _user); /// - /// 得到该用户拥有哪些角色 + /// 根据http上下文的用户得到该用户有哪些角色 /// - /// /// Task> GetRolesByUser(user _user); @@ -64,7 +63,7 @@ namespace Yi.Framework.Interface /// /// Task>> GetMenuByUser(user _user); - + } } diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework/Yi.Framework.Service/MenuService.cs index f67047a4..33285967 100644 --- a/Yi.Framework/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework/Yi.Framework.Service/MenuService.cs @@ -51,6 +51,14 @@ namespace Yi.Framework.Service return childrenList; } + public async Task> GetMenuMould() + { + var menuList= await _Db.Set().Include(u => u.children).Include(u => u.mould) + .Where(u => u.is_delete == (short)Common.Enum.DelFlagEnum.Normal ) + .ToListAsync(); + return menuList; + } + public async Task GetMenuMouldByMenu(menu _menu) { var menu_data = await _Db.Set().Include(u => u.children).Include(u=>u.mould).Where(u=>u.id==_menu.id).FirstOrDefaultAsync(); diff --git a/Yi.Framework/Yi.Framework.Service/RoleService.cs b/Yi.Framework/Yi.Framework.Service/RoleService.cs index 8d355ac1..68f15d3e 100644 --- a/Yi.Framework/Yi.Framework.Service/RoleService.cs +++ b/Yi.Framework/Yi.Framework.Service/RoleService.cs @@ -31,7 +31,7 @@ namespace Yi.Framework.Service var role_data =await _Db.Set().Include(u => u.menus) .Where(u => u.id == _role.id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); var menuList =role_data.menus.Where(u => u.is_top == (short)Common.Enum.TopFlagEnum.Top && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal) - .ToList(); + .ToList(); return menuList; } diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs index e95d4dd9..9301fd6c 100644 --- a/Yi.Framework/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -108,6 +108,7 @@ namespace Yi.Framework.Service foreach (var role in roleList) { var menu= await _roleService.GetMenusByRole(role); + menu.ForEach(u => u.roles = null); menuList.Add(menu); } return menuList;