⚡ 优化菜单搜索
This commit is contained in:
parent
f577f3b0d8
commit
6f83db2952
@ -1,6 +1,5 @@
|
|||||||
using Infrastructure.Attribute;
|
using Infrastructure.Attribute;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using JinianNet.JNTemplate.Dynamic;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -34,17 +33,11 @@ namespace ZR.Service
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<SysMenu> SelectTreeMenuList(MenuQueryDto menu, long userId)
|
public List<SysMenu> SelectTreeMenuList(MenuQueryDto menu, long userId)
|
||||||
{
|
{
|
||||||
List<SysMenu> menuList;
|
if (menu.ParentId != null)
|
||||||
//if (SysRoleService.IsAdmin(userId))
|
{
|
||||||
//{
|
return GetMenusByMenuId(menu.ParentId.ParseToInt(), userId);
|
||||||
// menuList = SelectTreeMenuList(menu);
|
}
|
||||||
//}
|
List<SysMenu> menuList = BuildMenuTree(SelectMenuList(menu, userId));
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// var userRoles = SysRoleService.SelectUserRoles(userId);
|
|
||||||
// menuList = SelectTreeMenuListByRoles(menu, userRoles);
|
|
||||||
//}
|
|
||||||
menuList = BuildMenuTree(SelectMenuList(menu, userId));
|
|
||||||
return menuList;
|
return menuList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,14 +267,17 @@ namespace ZR.Service
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private List<SysMenu> SelectMenuList(MenuQueryDto menu)
|
private List<SysMenu> SelectMenuList(MenuQueryDto menu)
|
||||||
{
|
{
|
||||||
|
var menuExp = Expressionable.Create<SysMenu>();
|
||||||
|
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()
|
return Queryable()
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
.Where(menuExp.ToExpression())
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.Visible == menu.Visible)
|
.OrderBy(it => new { it.ParentId, it.OrderNum })
|
||||||
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.Status == menu.Status)
|
.ToList();
|
||||||
.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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user