using Bootstrap.Security; using Bootstrap.Security.DataAccess; using Longbow.Cache; using Longbow.Configuration; using System.Collections.Generic; using System.Linq; namespace Bootstrap.Client.DataAccess { /// /// /// public static class MenuHelper { private const string RetrieveMenusAll = "BootstrapMenu-RetrieveMenus"; /// /// /// /// /// /// public static IEnumerable RetrieveAppMenus(string userName, string activeUrl) { var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0 && m.Application == ConfigurationManager.AppSettings["AppId"]); return DbHelper.CascadeMenus(menus, activeUrl); } /// /// 通过用户获得所有菜单 /// /// /// private static IEnumerable RetrieveAllMenus(string userName) => CacheManager.GetOrAdd($"{RetrieveMenusAll}-{userName}", key => DbHelper.RetrieveAllMenus(userName), RetrieveMenusAll); } }