revert: 修复 MongoDB 不使用缓存时页面无法打开问题

#Comment
link commit commit:6e4ac7c5153ff75065d6de30d09b69a45662ec7b
This commit is contained in:
Argo Zhang 2019-09-06 10:40:45 +08:00
parent 568052193e
commit 302976e761
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
5 changed files with 107 additions and 14 deletions

View File

@ -65,5 +65,34 @@ namespace Bootstrap.DataAccess.MongoDB
DbManager.Dicts.FindOneAndUpdate(md => md.Category == dict.Category && md.Name == dict.Name, Builders<BootstrapDict>.Update.Set(md => md.Code, dict.Code));
return true;
}
private static string RetrieveAppName(string name, string appId = "0", string defaultValue = "未设置")
{
var dicts = DictHelper.RetrieveDicts();
var platName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == appId)?.Name;
return dicts.FirstOrDefault(d => d.Category == platName && d.Name == name)?.Code ?? $"{name}{defaultValue}";
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string RetrieveWebTitle()
{
var code = RetrieveAppName("网站标题");
if (code == "网站标题未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统";
return code;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string RetrieveWebFooter()
{
var code = RetrieveAppName("网站页脚");
if (code == "网站页脚未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统";
return code;
}
}
}

View File

@ -64,13 +64,25 @@ namespace Bootstrap.DataAccess
/// 获取系统网站标题
/// </summary>
/// <returns></returns>
public virtual string RetrieveWebTitle() => DbHelper.RetrieveTitle();
public virtual string RetrieveWebTitle()
{
// 优先查找配置的应用程序网站标题
var code = DbHelper.RetrieveTitle();
if (code == "未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统";
return code;
}
/// <summary>
/// 获取系统网站页脚
/// </summary>
/// <returns></returns>
public virtual string RetrieveWebFooter() => DbHelper.RetrieveFooter();
public virtual string RetrieveWebFooter()
{
// 优先查找配置的应用程序网站标题
var code = DbHelper.RetrieveFooter();
if (code == "未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统";
return code;
}
/// <summary>
/// 获得系统中配置的可以使用的网站样式

View File

@ -15,5 +15,54 @@ namespace Bootstrap.Client.DataAccess.MongoDB
/// </summary>
/// <returns></returns>
public override IEnumerable<BootstrapDict> RetrieveDicts() => DbManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList();
/// <summary>
/// 获取应用程序配置值
/// </summary>
/// <param name="name"></param>
/// <param name="appId"></param>
/// <param name="defaultValue"></param>
/// <returns></returns>
private string RetrieveAppName(string name, string appId = "0", string defaultValue = "未设置")
{
var dicts = DictHelper.RetrieveDicts();
var platName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == appId)?.Name;
return dicts.FirstOrDefault(d => d.Category == platName && d.Name == name)?.Code ?? $"{name}{defaultValue}";
}
/// <summary>
/// 获取系统网站标题
/// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns>
public override string RetrieveWebTitle(string appId) => RetrieveAppName("网站标题", appId);
/// <summary>
/// 获取系统网站页脚
/// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns>
public override string RetrieveWebFooter(string appId) => RetrieveAppName("网站页脚", appId);
/// <summary>
/// 获得系统设置地址
/// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns>
public override string RetrieveSettingsUrl(string appId) => RetrieveAppName("系统设置地址", appId);
/// <summary>
/// 获得系统个人中心地址
/// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns>
public override string RetrieveProfilesUrl(string appId) => RetrieveAppName("个人中心地址", appId);
/// <summary>
/// 获得系统通知地址地址
/// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns>
public override string RetrieveNotisUrl(string appId) => RetrieveAppName("系统通知地址", appId);
}
}

View File

@ -12,18 +12,6 @@ namespace Bootstrap.Client.DataAccess
/// </summary>
public class Dict : BootstrapDict
{
/// <summary>
/// 获取系统网站标题
/// </summary>
/// <returns></returns>
public virtual string RetrieveWebTitle(string appId) => DbHelper.RetrieveTitle(appId);
/// <summary>
/// 获取系统网站页脚
/// </summary>
/// <returns></returns>
public virtual string RetrieveWebFooter(string appId) => DbHelper.RetrieveFooter(appId);
/// <summary>
/// 获得网站设置中的当前样式
/// </summary>
@ -89,6 +77,20 @@ namespace Bootstrap.Client.DataAccess
/// <returns></returns>
public virtual string RetrieveIconFolderPath() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "头像路径" && d.Category == "头像地址" && d.Define == 0) ?? new BootstrapDict { Code = "~/images/uploader/" }).Code;
/// <summary>
/// 获取系统网站标题
/// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns>
public virtual string RetrieveWebTitle(string appId) => DbHelper.RetrieveTitle(appId);
/// <summary>
/// 获取系统网站页脚
/// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns>
public virtual string RetrieveWebFooter(string appId) => DbHelper.RetrieveFooter(appId);
/// <summary>
/// 获得系统设置地址
/// </summary>

View File

@ -10,6 +10,7 @@
<PackageReference Include="Longbow.Logging" Version="2.2.13" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>
<ItemGroup>