From 030d5c6b50611359ba227c3777e4a3c6021a484a Mon Sep 17 00:00:00 2001 From: lzw <605106923@qq.com> Date: Fri, 15 Oct 2021 21:50:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=8F=9C=E5=8D=95=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/MenuController.cs | 7 ++++++- .../Controllers/UserController.cs | 3 +-- .../Yi.Framework.ApiMicroservice/YIDB.db | Bin 65536 -> 65536 bytes .../Yi.Framework.Interface/IMenuService.cs | 2 +- .../Yi.Framework.Service/MenuService.cs | 15 +++++++-------- .../Yi.Framework.Service/UserService.cs | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs index bfdc2523..c44f1d02 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -100,7 +100,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [HttpPost] public async Task AddChildrenMenu(ChildrenDto childrenDto) - { + { + var _menu = await _menuService.GetEntityById(childrenDto.parentId); + var _children= await _menuService.AddChildrenMenu(_menu); + _children = childrenDto.data; + return Result.Success(); + } } } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs index a1d38072..7dfeda30 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -92,8 +92,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPost] public async Task SetRoleByUser(IdsListDto idsListDto) { - 有bug:无法运行,500报错; - var _user = this.HttpContext.GetCurrentUserInfo(); + await _userService.SetRolesByUser(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 8932385efef7a37797adb4a84cad8a962ae54d20..b2c233d87e56f739f19854503b45862550172f91 100644 GIT binary patch delta 239 zcmY+7F$%&k07a8Frb!BZ-6~WlIC%j_5uBxm@c`xy4jw}xgM&xtPy|67w2Dg?7ad$2 zOzL3!hX-$Xe65+*Y;#SiGPiV)L<%4%u)_*-q?lraA!5LEJFoUQREoG!K?o0JUBq9! zFsO;*Kas-B7Tbw^$Ot}o)hk#+M!e`N(eR(^j5{`>s9`KR+2^ZRcW6tLyr>|ejt0Vwf;f&UNx dcm7ZOZ~0$r7F4*#Kl#OZ8EoR4U)+~a005ZlA|U_( diff --git a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs index a39e9b6e..fc480933 100644 --- a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs @@ -45,6 +45,6 @@ namespace Yi.Framework.Interface /// /// /// - Task AddChildrenMenu(menu _menu); + Task AddChildrenMenu(menu _menu); } } diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework/Yi.Framework.Service/MenuService.cs index c0bf6d9d..001f32d9 100644 --- a/Yi.Framework/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework/Yi.Framework.Service/MenuService.cs @@ -13,15 +13,14 @@ namespace Yi.Framework.Service { public MenuService(DbContext Db) : base(Db) { } - public async Task AddChildrenMenu(menu _menu) + public async Task AddChildrenMenu(menu _menu) { - var menu_data = await GetEntity(u=>u.id==_menu.id&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); - if (menu_data == null) - { - return false; - } - menu_data.children.Add(new menu()) ; - return await AddAsync(_menu); + var menu_data = await _Db.Set().Include(u=>u.children) + .Where(u=>u.id==_menu.id&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); + var _children = menu_data.children.ToList(); + _children.Add(new menu()); + await UpdateAsync(menu_data); + return menu_data; } public async Task DelListByUpdateAsync(List _ids) diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs index b4448d3e..004001dd 100644 --- a/Yi.Framework/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -92,7 +92,7 @@ namespace Yi.Framework.Service { return false; } - var roleList = _Db.Set().Where(u => roleIds.Contains(u.id)).ToList(); + var roleList =await _Db.Set().Where(u => roleIds.Contains(u.id) && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).ToListAsync(); foreach(var item in user_data) { item.roles = roleList;