From 17f632298fb610fc133a811e2d17df299ef91960 Mon Sep 17 00:00:00 2001 From: lzw <605106923@qq.com> Date: Tue, 12 Oct 2021 22:19:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.Interface/IMenuService.cs | 12 +++++++++++ .../Yi.Framework.Interface/IRoleService.cs | 6 ++++++ .../Yi.Framework.Interface/IUserService.cs | 1 + .../Yi.Framework.Service/MenuService.cs | 21 +++++++++++++++++++ .../Yi.Framework.Service/RoleService.cs | 10 +++++++++ 5 files changed, 50 insertions(+) diff --git a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs index 2b603862..cc13c920 100644 --- a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs @@ -40,5 +40,17 @@ namespace Yi.Framework.Interface /// /// Task SetMouldByMenu(int mouldId,int menuId); + /// + /// 添加菜单 + /// + /// + /// + Task AddMenu(menu _menu); + /// + /// 添加子菜单 + /// + /// + /// + Task AddChildrenMenu(menu _menu); } } diff --git a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs index 6d9a47a7..943ae5c5 100644 --- a/Yi.Framework/Yi.Framework.Interface/IRoleService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IRoleService.cs @@ -33,6 +33,12 @@ namespace Yi.Framework.Interface /// /// Task SetMenusByRolesId(List menuIds, int roleId); + /// + /// 添加角色 + /// + /// + /// + Task AddRole(role _role); } } diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework/Yi.Framework.Interface/IUserService.cs index ccc67e8a..ba356f07 100644 --- a/Yi.Framework/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IUserService.cs @@ -52,5 +52,6 @@ namespace Yi.Framework.Interface /// /// Task SetRolesByUserId(List roleIds,int userId); + } } diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework/Yi.Framework.Service/MenuService.cs index 275968ed..27b01c3c 100644 --- a/Yi.Framework/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework/Yi.Framework.Service/MenuService.cs @@ -13,6 +13,27 @@ namespace Yi.Framework.Service { public MenuService(DbContext Db) : base(Db) { } + 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); + } + + public async Task AddMenu(menu _menu) + { + var menu_data = await GetEntityById(_menu.id); + if (menu_data == null) + { + return false; + } + return await AddAsync(_menu); + } + public async Task DelListByUpdateAsync(List _ids) { var menuList = await GetEntitiesAsync(u=>_ids.Contains(u.id)); diff --git a/Yi.Framework/Yi.Framework.Service/RoleService.cs b/Yi.Framework/Yi.Framework.Service/RoleService.cs index a51873bc..79a62af8 100644 --- a/Yi.Framework/Yi.Framework.Service/RoleService.cs +++ b/Yi.Framework/Yi.Framework.Service/RoleService.cs @@ -15,6 +15,16 @@ namespace Yi.Framework.Service { } + public async Task AddRole(role _role) + { + var role_data = await GetEntityById(_role.id); + if(role_data==null) + { + return false; + } + return await AddAsync(_role); + } + public async Task DelListByUpdateAsync(List _ids) { var userList = await GetEntitiesAsync(u=>_ids.Contains(u.id));