From 6f83db2952f1d32cb5b285b85121fa3dd648189e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Sat, 17 Jun 2023 16:01:22 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Service/System/SysMenuService.cs | 34 +++++++++++++---------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/ZR.Service/System/SysMenuService.cs b/ZR.Service/System/SysMenuService.cs index 045046b..7db43f3 100644 --- a/ZR.Service/System/SysMenuService.cs +++ b/ZR.Service/System/SysMenuService.cs @@ -1,6 +1,5 @@ using Infrastructure.Attribute; using Infrastructure.Extensions; -using JinianNet.JNTemplate.Dynamic; using SqlSugar; using System; using System.Collections.Generic; @@ -34,17 +33,11 @@ namespace ZR.Service /// public List SelectTreeMenuList(MenuQueryDto menu, long userId) { - List menuList; - //if (SysRoleService.IsAdmin(userId)) - //{ - // menuList = SelectTreeMenuList(menu); - //} - //else - //{ - // var userRoles = SysRoleService.SelectUserRoles(userId); - // menuList = SelectTreeMenuListByRoles(menu, userRoles); - //} - menuList = BuildMenuTree(SelectMenuList(menu, userId)); + if (menu.ParentId != null) + { + return GetMenusByMenuId(menu.ParentId.ParseToInt(), userId); + } + List menuList = BuildMenuTree(SelectMenuList(menu, userId)); return menuList; } @@ -274,14 +267,17 @@ namespace ZR.Service /// private List SelectMenuList(MenuQueryDto menu) { + var menuExp = Expressionable.Create(); + menuExp.AndIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName)); + menuExp.AndIF(!string.IsNullOrEmpty(menu.Visible), it => it.Visible == menu.Visible); + menuExp.AndIF(!string.IsNullOrEmpty(menu.Status), it => it.Status == menu.Status); + menuExp.AndIF(!string.IsNullOrEmpty(menu.MenuTypeIds), it => menu.MenuTypeIdArr.Contains(it.MenuType)); + menuExp.AndIF(menu.ParentId != null, it => it.ParentId == menu.ParentId); + return Queryable() - .WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName)) - .WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.Visible == menu.Visible) - .WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.Status == menu.Status) - .WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), it => menu.MenuTypeIdArr.Contains(it.MenuType)) - .WhereIF(menu.ParentId != null, it => it.ParentId == menu.ParentId) - .OrderBy(it => new { it.ParentId, it.OrderNum }) - .ToList(); + .Where(menuExp.ToExpression()) + .OrderBy(it => new { it.ParentId, it.OrderNum }) + .ToList(); } ///