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 => DbContextManager.Create().RetrieveDicts());
///
/// 删除字典中的数据
///
/// 需要删除的IDs
///
public static bool Delete(IEnumerable value)
{
var ret = DbContextManager.Create().Delete(value);
CacheCleanUtility.ClearCache(dictIds: value);
return ret;
}
///
/// 保存新建/更新的字典信息
///
///
///
public static bool Save(BootstrapDict p)
{
var ret = DbContextManager.Create().Save(p);
if (ret) CacheCleanUtility.ClearCache(new List() { p.Id });
return ret;
}
///
/// 保存网站个性化设置
///
///
///
///
///
public static bool SaveSettings(BootstrapDict dict)
{
var ret = DbContextManager.Create().SaveSettings(dict);
if (ret) CacheCleanUtility.ClearCache(dictIds: new List());
return ret;
}
///
/// 获取字典分类名称
///
///
public static IEnumerable RetrieveCategories() => CacheManager.GetOrAdd(RetrieveCategoryDataKey, key => DbContextManager.Create().RetrieveCategories());
///
///
///
///
public static string RetrieveWebTitle() => DbContextManager.Create().RetrieveWebTitle();
///
///
///
///
public static string RetrieveWebFooter() => DbContextManager.Create().RetrieveWebFooter();
///
/// 获得系统中配置的可以使用的网站样式
///
///
public static IEnumerable RetrieveThemes() => DbContextManager.Create().RetrieveThemes();
///
/// 获得网站设置中的当前样式
///
///
public static string RetrieveActiveTheme() => DbContextManager.Create().RetrieveActiveTheme();
///
/// 获取头像路径
///
///
public static string RetrieveIconFolderPath() => DbContextManager.Create().RetrieveIconFolderPath();
///
/// 获得默认的前台首页地址,默认为~/Home/Index
///
///
public static string RetrieveHomeUrl() => DbContextManager.Create().RetrieveHomeUrl();
///
/// 获得默认的前台首页地址,默认为~/Home/Index
///
///
public static string RetrieveDefaultIcon() => DbContextManager.Create().RetrieveDefaultIcon();
///
///
///
///
public static IEnumerable> RetrieveApps() => DbContextManager.Create().RetrieveApps();
}
}