diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs index 1c4506ad..eab50a11 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -26,7 +26,9 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpGet] public async Task GetMenu() { - return Result.Success().SetData(await _menuService.GetTopMenu()); + //var top =await _menuService.GetTopMenu(); + //var children=await _menuService.get + return Result.Success().SetData(await _menuService.GetTopMenu()); } /// diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs index a62cc81e..befb426c 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -71,10 +71,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPost] public async Task SetMenuByRole(IdsListDto idsListDto) { - foreach(var id in idsListDto.ids1) - { - await _roleService.SetMenusByRolesId(idsListDto.ids2, id); - } + await _roleService.SetMenusByRolesId(idsListDto.ids2, idsListDto.ids1); return Result.Success(); } } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db index 0e47b3b3..8173bcc1 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.Interface/IMenuService.cs b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs index 98ea93d7..1c77e4b2 100644 --- a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs @@ -60,5 +60,6 @@ namespace Yi.Framework.Interface /// /// Task> GetChildrenMenu(menu _menu); + } } diff --git a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs index a8295ddb..e06f3337 100644 --- a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs @@ -32,7 +32,7 @@ namespace Yi.Framework.Interface /// /// /// - Task SetMenusByRolesId(List menuIds, int roleId); + Task SetMenusByRolesId(List menuIds, List roleIds); } } diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework/Yi.Framework.Service/MenuService.cs index 4af787c7..f67047a4 100644 --- a/Yi.Framework/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework/Yi.Framework.Service/MenuService.cs @@ -13,10 +13,11 @@ namespace Yi.Framework.Service { public MenuService(DbContext Db) : base(Db) { } + public async Task AddChildrenMenu(menu _menu, menu _children) { var menu_data = await _Db.Set().Include(u => u.children).Where(u => u.id == _menu.id).FirstOrDefaultAsync(); - _children.is_top = (short)Common.Enum.TopFlagEnum.Children; + _children.is_top = (short)Common.Enum.TopFlagEnum.Children; menu_data.children.Add(_children); await UpdateAsync(menu_data); return menu_data; diff --git a/Yi.Framework/Yi.Framework.Service/RoleService.cs b/Yi.Framework/Yi.Framework.Service/RoleService.cs index e0e38b50..8d355ac1 100644 --- a/Yi.Framework/Yi.Framework.Service/RoleService.cs +++ b/Yi.Framework/Yi.Framework.Service/RoleService.cs @@ -42,17 +42,20 @@ namespace Yi.Framework.Service return role_data.users.ToList(); } - public async Task SetMenusByRolesId(List menuIds, int roleId) + public async Task SetMenusByRolesId(List menuIds,List roleIds) { - var role_data = await GetEntity(u => u.id == roleId && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); + var role_data = await _Db.Set().Include(u=>u.menus) + .Where(u =>roleIds.Contains(u.id) && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync(); if (role_data == null) { return false; } var menuList = await _Db.Set().Where(u => menuIds.Contains(u.id)&&u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync(); - - role_data.menus =menuList; - return await AddAsync(role_data); + foreach(var role in role_data) + { + role.menus =menuList; + } + return await UpdateListAsync(role_data); } } }