using Longbow.Cache; using Longbow.Data; using System.Collections.Generic; namespace Bootstrap.DataAccess { public static class AppHelper { public const string RetrieveAppsByRoleIdDataKey = "AppHelper-RetrieveAppsByRoleId"; /// /// 根据角色ID指派应用程序 /// /// /// public static IEnumerable RetrievesByRoleId(string roleId) => CacheManager.GetOrAdd(string.Format("{0}-{1}", RetrieveAppsByRoleIdDataKey, roleId), key => DbContextManager.Create().RetrievesByRoleId(roleId), RetrieveAppsByRoleIdDataKey); /// /// 根据角色ID以及选定的App ID,保到角色应用表 /// /// /// /// public static bool SaveByRoleId(string roleId, IEnumerable appIds) { var ret = DbContextManager.Create().SaveByRoleId(roleId, appIds); if (ret) CacheCleanUtility.ClearCache(appIds: appIds, roleIds: new List() { roleId }); return ret; } /// /// 根据指定用户名获得授权应用程序集合 /// /// /// public static IEnumerable RetrievesByUserName(string userName) => DbContextManager.Create().RetrievesByUserName(userName); } }