From 3dbd838de6662be49eadd7ab530b022aea07c104 Mon Sep 17 00:00:00 2001 From: lzw <605106923@qq.com> Date: Mon, 18 Oct 2021 16:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MenuController.cs | 5 ++--- .../Controllers/RoleController.cs | 3 +++ .../Controllers/UserController.cs | 12 ++++++++++++ .../Yi.Framework.ApiMicroservice/YIDB.db | Bin 65536 -> 65536 bytes .../Models/Enum/ShowFlagEnum.cs | 14 ++++++++++++++ .../Yi.Framework.Interface/IMenuService.cs | 2 +- .../Yi.Framework.Interface/IRoleService.cs | 1 + .../Yi.Framework.Interface/IUserService.cs | 5 ++--- .../Yi.Framework.Service/MenuService.cs | 8 ++++++++ .../Yi.Framework.Service/RoleService.cs | 2 +- .../Yi.Framework.Service/UserService.cs | 1 + 11 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 Yi.Framework/Yi.Framework.Common/Models/Enum/ShowFlagEnum.cs 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 8173bcc19910ebb95860dc7e2158539b8ad73bf5..e304553a0408d7f3af14cf2aaab76b7b5394acce 100644 GIT binary patch delta 155 zcmZo@U})hQDgH%e`N(`4X)3V*$aGGxJ9`>Zx$4o&Bd;u!Ob8qDm{5(jU}K- zqwHqC1E=}8S(zCb#Wh%%85q?kYn;Estif+Nnf-z<3%?z|CD5XWd|V(oh=R?|_xCCQ E08N%GcmMzZ delta 111 zcmZo@U})hQEl@>e`N(`HEz?%>;=A?1qB{*amlN3GsufdGB9#XZmbsD99q5J zMM8~VgMt4K|9AdR{BQYR@E_pc&A*L*BY)XsxdXw3P P0?4rUe4Cx`?^OT*rv@b$ 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;