using Bowin.Common.Linq; using YLShipBuildLandMap.Entity; using YLShipBuildLandMap.Entity.ViewModel; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; namespace YLShipBuildLandMap.Services.SystemSetting { public class MenuService : IMenuService { private YLShipBuildLandMapContext DbContext { get; set; } public MenuService(YLShipBuildLandMapContext dbContext) { DbContext = dbContext; } private IQueryable GetMenuByUser( Expression> menuDefineExp, Expression> userExp) { var userFunc = userExp; var menuDefineFunc = menuDefineExp; var iqResult = ( from m in this.DbContext.SysMenu.Where(menuDefineExp) where m.FunctionCode == null || ( from u in this.DbContext.SysUser.Where(userExp) from r in u.SysUserSysRole from f in r.Role.SysRoleSysFunctionCode where f.FunctionCode == m.FunctionCode select 1 ).Any() select m ); return iqResult.OrderBy(x => x.OrderNo).ThenBy(x => x.MenuNo); } public List GetMenuByUserID(Guid userID) { Expression> menuDefineExp = (x => x.RecordStatus >= 1); Expression> userExp = (x => x.UserId == userID); return GetMenuByUser(menuDefineExp, userExp).ToList(); } } }