using Bootstrap.Security; using Longbow.Cache; using Longbow.Data; using System.Collections.Generic; namespace Bootstrap.DataAccess { /// /// /// public static class DictHelper { /// /// /// /// /// 缓存索引,BootstrapAdmin后台清理缓存时使用 /// public const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts"; /// /// /// public const string RetrieveCategoryDataKey = "DictHelper-RetrieveDictsCategory"; /// /// /// /// public static IEnumerable RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbAdapterManager.Create().RetrieveDicts()); /// /// 删除字典中的数据 /// /// 需要删除的IDs /// public static bool DeleteDict(IEnumerable value) { var ret = DbAdapterManager.Create().DeleteDict(value); CacheCleanUtility.ClearCache(dictIds: value); return ret; } /// /// 保存新建/更新的字典信息 /// /// /// public static bool SaveDict(BootstrapDict p) { var ret = DbAdapterManager.Create().SaveDict(p); if (ret) CacheCleanUtility.ClearCache( new List() { p.Id }); return ret; } /// /// 保存网站个性化设置 /// /// /// /// /// public static bool SaveSettings(BootstrapDict dict) { var ret = DbAdapterManager.Create().SaveSettings(dict); if (ret) CacheCleanUtility.ClearCache(dictIds: new List()); return ret; } /// /// 获取字典分类名称 /// /// public static IEnumerable RetrieveCategories() => CacheManager.GetOrAdd(RetrieveCategoryDataKey, key => DbAdapterManager.Create().RetrieveCategories()); /// /// /// /// public static string RetrieveWebTitle() => DbAdapterManager.Create().RetrieveWebTitle(); /// /// /// /// public static string RetrieveWebFooter() => DbAdapterManager.Create().RetrieveWebFooter(); /// /// 获得系统中配置的可以使用的网站样式 /// /// public static IEnumerable RetrieveThemes() => DbAdapterManager.Create().RetrieveThemes(); /// /// 获得网站设置中的当前样式 /// /// public static string RetrieveActiveTheme() => DbAdapterManager.Create().RetrieveActiveTheme(); /// /// 获取头像路径 /// /// public static BootstrapDict RetrieveIconFolderPath() => DbAdapterManager.Create().RetrieveIconFolderPath(); /// /// 获得默认的前台首页地址,默认为~/Home/Index /// /// public static string RetrieveHomeUrl() => DbAdapterManager.Create().RetrieveHomeUrl(); /// /// /// /// public static IEnumerable> RetrieveApps() => DbAdapterManager.Create().RetrieveApps(); } }