From c15c43dba4e61c341a5a0687e226a59b576e1254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Fri, 9 Sep 2022 16:52:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=95=B0=E6=8D=AE=E5=AF=B9=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/SwaggerDoc.xml | 13 ++++++++++ .../Controllers/MenuController.cs | 16 ++++++++---- .../Controllers/RoleController.cs | 9 +++++-- .../yi-sqlsugar-dev.db | Bin 118784 -> 118784 bytes .../Yi.Framework.Interface/IMenuService.cs | 2 ++ .../Yi.Framework.Interface/IRoleService.cs | 2 ++ .../Yi.Framework.Service/MenuService.cs | 12 ++++++++- .../Yi.Framework.Service/RoleService.cs | 18 +++++++++++++ .../Yi.Framework.Service/UserService.cs | 2 +- .../src/views/system/menu/index.vue | 8 +++--- .../src/views/system/role/index.vue | 24 +++++++++--------- 11 files changed, 81 insertions(+), 25 deletions(-) diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 5b5ff7b2..bc81ce88 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -141,6 +141,13 @@ 菜单管理 + + + 动态条件查询全部 + + + + 得到树形菜单 @@ -152,6 +159,12 @@ 角色管理 + + + 动态条件分页查询 + + + 给多用户设置多角色 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs index dd32986a..81ab9f17 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -20,7 +20,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [ApiController] [Route("api/[controller]/[action]")] - public class MenuController + public class MenuController { private IMenuService _iMenuService; public MenuController(ILogger logger, IMenuService iMenuService) @@ -28,10 +28,16 @@ namespace Yi.Framework.ApiMicroservice.Controllers _iMenuService = iMenuService; } + + /// + /// 动态条件查询全部 + /// + /// + /// [HttpGet] - public async Task GetList() + public async Task GetList([FromQuery] MenuEntity menu) { - return Result.Success().SetData(await _iMenuService._repository.GetListAsync()); + return Result.Success().SetData(await _iMenuService.SelctGetList(menu)); } @@ -41,8 +47,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers /// [HttpGet] public async Task GetMenuTree() - { - return Result.Success().SetData(await _iMenuService. GetMenuTreeAsync()); + { + return Result.Success().SetData(await _iMenuService.GetMenuTreeAsync()); } } } diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs index cefe4d83..57b2bc89 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/RoleController.cs @@ -29,12 +29,17 @@ namespace Yi.Framework.ApiMicroservice.Controllers _iRoleService = iRoleService; } + /// + /// 动态条件分页查询 + /// + /// [HttpGet] - public async Task PageList() + public async Task PageList([FromQuery] RoleEntity role, [FromQuery] PageParModel page) { - return Result.Success().SetData(await _iRoleService._repository.GetListAsync()); + return Result.Success().SetData(await _iRoleService.SelctPageList(role, page)); } + /// /// 给多用户设置多角色 /// diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index 5dfa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oleService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs index 58895248..5350f42b 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IRoleService.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Yi.Framework.Common.Models; using Yi.Framework.Model.Models; using Yi.Framework.Repository; @@ -27,5 +28,6 @@ namespace Yi.Framework.Interface /// /// Task GiveRoleSetMenu(List roleIds, List menuIds); + Task>> SelctPageList(RoleEntity role, PageParModel page); } } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/MenuService.cs b/Yi.Framework.Net6/Yi.Framework.Service/MenuService.cs index e85ef7f2..014dde7f 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/MenuService.cs @@ -1,6 +1,7 @@ using SqlSugar; using System.Collections.Generic; using System.Threading.Tasks; +using Yi.Framework.Common.Models; using Yi.Framework.Interface; using Yi.Framework.Model.Models; using Yi.Framework.Repository; @@ -9,11 +10,20 @@ namespace Yi.Framework.Service { public partial class MenuService : BaseService, IMenuService { + public async Task> SelctGetList(MenuEntity menu) + { + var data = await _repository._Db.Queryable() + .WhereIF(!string.IsNullOrEmpty(menu.MenuName), u => u.MenuName.Contains(menu.MenuName)) + .Where(u => u.IsDeleted == false) + .OrderBy(u => u.OrderNum, OrderByType.Desc) + .ToListAsync(); + return data; + } public async Task> GetMenuTreeAsync() { //ParentId 0,代表为根目录,只能存在一个 //复杂查询直接使用db代理 - return await _repository._Db.Queryable().Where(u=>u.IsDeleted==false).ToTreeAsync(it=>it.Children,it=>it.ParentId,0); + return await _repository._Db.Queryable().Where(u => u.IsDeleted == false).ToTreeAsync(it => it.Children, it => it.ParentId, 0); } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs index 52546893..6e0f68ea 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/RoleService.cs @@ -1,6 +1,8 @@ using SqlSugar; +using System; using System.Collections.Generic; using System.Threading.Tasks; +using Yi.Framework.Common.Models; using Yi.Framework.Interface; using Yi.Framework.Model.Models; using Yi.Framework.Repository; @@ -46,5 +48,21 @@ namespace Yi.Framework.Service return await _repository._Db.Queryable().Includes(u => u.Menus).InSingleAsync(roleId); } + + + + public async Task>> SelctPageList(RoleEntity role, PageParModel page) + { + RefAsync total = 0; + var data = await _repository._Db.Queryable() + .WhereIF(!string.IsNullOrEmpty(role.RoleName), u => u.RoleName.Contains(role.RoleName)) + .WhereIF(!string.IsNullOrEmpty(role.RoleCode), u => u.RoleCode.Contains(role.RoleCode)) + .WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime) + .Where(u => u.IsDeleted == role.IsDeleted) + .OrderBy(u => u.OrderNum, OrderByType.Desc) + .ToPageListAsync(page.PageNum, page.PageSize, total); + + return new PageModel>(data, total); + } } } diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs index 5f052ab6..c330927b 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs @@ -165,7 +165,7 @@ namespace Yi.Framework.Service .WhereIF(!string.IsNullOrEmpty(user.Phone), u => u.Phone.Contains(user.Phone)) .WhereIF(page.StartTime.IsNotNull() && page.EndTime.IsNotNull(), u => u.CreateTime >= page.StartTime && u.CreateTime <= page.EndTime) .Where(u => u.IsDeleted == false) - .OrderBy(u => u.OrderNum) + .OrderBy(u => u.OrderNum, OrderByType.Desc) .ToPageListAsync(page.PageNum, page.PageSize, total); return new PageModel>(data, total); diff --git a/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue index eb6747de..02f091dc 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue @@ -9,8 +9,8 @@ @keyup.enter="handleQuery" /> - - + + - + @@ -360,7 +360,7 @@ function reset() { isFrame: "1", isCache: "0", visible: "0", - status: "0" + isDeleted: "0" }; proxy.resetForm("menuRef"); } diff --git a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue index 8262d2f9..275dec07 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue @@ -10,18 +10,18 @@ @keyup.enter="handleQuery" /> - + - + - - + +