From 2563624936e0ab7ad910e556bf9dd77efbd62786 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: Sun, 29 May 2022 13:31:05 +0800
Subject: [PATCH] =?UTF-8?q?fix=E4=B8=80=E4=B8=AA=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E6=8B=A5=E6=9C=89=E5=A4=9A=E4=B8=AA=E8=A7=92=E8=89=B2=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ZR.Repository/System/SysMenuRepository.cs | 36 +++++------------------
1 file changed, 8 insertions(+), 28 deletions(-)
diff --git a/ZR.Repository/System/SysMenuRepository.cs b/ZR.Repository/System/SysMenuRepository.cs
index 4ab4478..d3d09ba 100644
--- a/ZR.Repository/System/SysMenuRepository.cs
+++ b/ZR.Repository/System/SysMenuRepository.cs
@@ -30,7 +30,7 @@ namespace ZR.Repository.System
}
///
- /// 根据用户查询系统菜单列表(菜单管理)
+ /// 根据用户查询系统菜单列表
///
///
/// 用户角色集合
@@ -38,15 +38,16 @@ namespace ZR.Repository.System
public List SelectTreeMenuListByRoles(MenuQueryDto menu, List roles)
{
var roleMenus = Context.Queryable()
- .Where(r => roles.Contains(r.Role_id));
+ .Where(r => roles.Contains(r.Role_id))
+ .Select(f => f.Menu_id).Distinct().ToList();
return Context.Queryable()
- .InnerJoin(roleMenus, (c, j) => c.MenuId == j.Menu_id)
- .WhereIF(!string.IsNullOrEmpty(menu.MenuName), (c, j) => c.MenuName.Contains(menu.MenuName))
- .WhereIF(!string.IsNullOrEmpty(menu.Visible), (c, j) => c.visible == menu.Visible)
- .WhereIF(!string.IsNullOrEmpty(menu.Status), (c, j) => c.status == menu.Status)
+ .Where(c => roleMenus.Contains(c.MenuId))
+ .WhereIF(!string.IsNullOrEmpty(menu.MenuName), (c) => c.MenuName.Contains(menu.MenuName))
+ .WhereIF(!string.IsNullOrEmpty(menu.Visible), (c) => c.visible == menu.Visible)
+ .WhereIF(!string.IsNullOrEmpty(menu.Status), (c) => c.status == menu.Status)
.WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), c => menu.MenuTypeIdArr.Contains(c.menuType))
- .OrderBy((c, j) => new { c.parentId, c.orderNum })
+ .OrderBy((c) => new { c.parentId, c.orderNum })
.Select(c => c)
.ToTree(it => it.children, it => it.parentId, 0);
}
@@ -87,27 +88,6 @@ namespace ZR.Repository.System
.ToList();
}
- #region 左侧菜单树
-
- /////
- ///// 根据用户角色获取左侧菜单树
- /////
- /////
- /////
- //public List SelectMenuTreeByRoleIds(List roleIds)
- //{
- // var menuTypes = new string[] { "M", "C" };
- // return Context.Queryable()
- // .Where((menu) =>
- // menuTypes.Contains(menu.menuType)
- // && menu.status == "0"
- // && SqlFunc.Subqueryable().Where(s => roleIds.Contains(s.Role_id) && s.Menu_id == menu.MenuId).Any())
- // .OrderBy((menu) => new { menu.parentId, menu.orderNum })
- // .Select((menu) => menu).ToList();
- //}
-
- #endregion
-
///
/// 获取菜单详情
///