refactor: 更新客户端框架获取系统数据方法

This commit is contained in:
Argo Zhang 2019-09-06 00:12:54 +08:00
parent ea670fc1bc
commit 632630e0e9
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
7 changed files with 27 additions and 43 deletions

View File

@ -1,5 +1,4 @@
using Bootstrap.Security; using Bootstrap.Security;
using Longbow.Configuration;
using MongoDB.Driver; using MongoDB.Driver;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -16,30 +15,5 @@ namespace Bootstrap.Client.DataAccess.MongoDB
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public override IEnumerable<BootstrapDict> RetrieveDicts() => DbManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList(); public override IEnumerable<BootstrapDict> RetrieveDicts() => DbManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList();
private static string RetrieveAppName(string name, string defaultValue = "未设置")
{
var dicts = DictHelper.RetrieveDicts();
var platName = dicts.FirstOrDefault(d => d.Category == "应用程序" && d.Code == ConfigurationManager.AppSettings["AppId"])?.Name;
return dicts.FirstOrDefault(d => d.Category == platName && d.Name == name)?.Code ?? $"{name}{defaultValue}";
}
/// <summary>
/// 获得系统设置地址
/// </summary>
/// <returns></returns>
public override string RetrieveSettingsUrl() => RetrieveAppName("系统设置地址");
/// <summary>
/// 获得系统个人中心地址
/// </summary>
/// <returns></returns>
public override string RetrieveProfilesUrl() => RetrieveAppName("个人中心地址");
/// <summary>
/// 获得系统通知地址地址
/// </summary>
/// <returns></returns>
public override string RetrieveNotisUrl() => RetrieveAppName("系统通知地址");
} }
} }

View File

@ -5,8 +5,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.13-preview-1" /> <PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.13-preview-4" />
<PackageReference Include="Longbow.Cache" Version="2.2.15" /> <PackageReference Include="Longbow.Cache" Version="2.2.15" />
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
<PackageReference Include="Longbow.Data" Version="2.3.7" /> <PackageReference Include="Longbow.Data" Version="2.3.7" />
<PackageReference Include="Longbow.Logging" Version="2.2.13" /> <PackageReference Include="Longbow.Logging" Version="2.2.13" />
<PackageReference Include="Longbow.Web" Version="2.2.16" /> <PackageReference Include="Longbow.Web" Version="2.2.16" />

View File

@ -16,13 +16,13 @@ namespace Bootstrap.Client.DataAccess
/// 获取系统网站标题 /// 获取系统网站标题
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public virtual string RetrieveWebTitle() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "后台管理系统" }).Code; public virtual string RetrieveWebTitle(string appId) => DbHelper.RetrieveTitle(appId);
/// <summary> /// <summary>
/// 获取系统网站页脚 /// 获取系统网站页脚
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public virtual string RetrieveWebFooter() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "2016 © 通用后台管理系统" }).Code; public virtual string RetrieveWebFooter(string appId) => DbHelper.RetrieveFooter(appId);
/// <summary> /// <summary>
/// 获得网站设置中的当前样式 /// 获得网站设置中的当前样式
@ -93,18 +93,18 @@ namespace Bootstrap.Client.DataAccess
/// 获得系统设置地址 /// 获得系统设置地址
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public virtual string RetrieveSettingsUrl() => DbHelper.RetrieveSettingsUrl(); public virtual string RetrieveSettingsUrl(string appId) => DbHelper.RetrieveSettingsUrl(appId);
/// <summary> /// <summary>
/// 获得系统个人中心地址 /// 获得系统个人中心地址
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public virtual string RetrieveProfilesUrl() => DbHelper.RetrieveProfilesUrl(); public virtual string RetrieveProfilesUrl(string appId) => DbHelper.RetrieveProfilesUrl(appId);
/// <summary> /// <summary>
/// 获得系统通知地址地址 /// 获得系统通知地址地址
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public virtual string RetrieveNotisUrl() => DbHelper.RetrieveNotisUrl(); public virtual string RetrieveNotisUrl(string appId) => DbHelper.RetrieveNotisUrl(appId);
} }
} }

View File

@ -27,14 +27,16 @@ namespace Bootstrap.Client.DataAccess
/// <summary> /// <summary>
/// 获取站点 Title 配置信息 /// 获取站点 Title 配置信息
/// </summary> /// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns> /// <returns></returns>
public static string RetrieveWebTitle() => DbContextManager.Create<Dict>().RetrieveWebTitle(); public static string RetrieveWebTitle(string appId) => DbContextManager.Create<Dict>().RetrieveWebTitle(appId);
/// <summary> /// <summary>
/// 获取站点 Footer 配置信息 /// 获取站点 Footer 配置信息
/// </summary> /// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns> /// <returns></returns>
public static string RetrieveWebFooter() => DbContextManager.Create<Dict>().RetrieveWebFooter(); public static string RetrieveWebFooter(string appId) => DbContextManager.Create<Dict>().RetrieveWebFooter(appId);
/// <summary> /// <summary>
/// 获得网站设置中的当前样式 /// 获得网站设置中的当前样式
@ -94,20 +96,23 @@ namespace Bootstrap.Client.DataAccess
/// <summary> /// <summary>
/// 获得系统设置地址 /// 获得系统设置地址
/// </summary> /// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns> /// <returns></returns>
public static string RetrieveSettingsUrl() => DbContextManager.Create<Dict>().RetrieveSettingsUrl(); public static string RetrieveSettingsUrl(string appId) => DbContextManager.Create<Dict>().RetrieveSettingsUrl(appId);
/// <summary> /// <summary>
/// 获得系统个人中心地址 /// 获得系统个人中心地址
/// </summary> /// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns> /// <returns></returns>
public static string RetrieveProfilesUrl() => DbContextManager.Create<Dict>().RetrieveProfilesUrl(); public static string RetrieveProfilesUrl(string appId) => DbContextManager.Create<Dict>().RetrieveProfilesUrl(appId);
/// <summary> /// <summary>
/// 获得系统通知地址地址 /// 获得系统通知地址地址
/// </summary> /// </summary>
/// <param name="appId">App 应用ID 默认为 0 表示后台管理程序</param>
/// <returns></returns> /// <returns></returns>
public static string RetrieveNotisUrl() => DbContextManager.Create<Dict>().RetrieveNotisUrl(); public static string RetrieveNotisUrl(string appId) => DbContextManager.Create<Dict>().RetrieveNotisUrl(appId);
/// <summary> /// <summary>
/// 配置 IP 地理位置查询配置项 注入方法调用此方法 /// 配置 IP 地理位置查询配置项 注入方法调用此方法

View File

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.16-preview-1" /> <PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.16-preview-2" />
<PackageReference Include="Longbow.Configuration" Version="2.2.7" /> <PackageReference Include="Longbow.Configuration" Version="2.2.7" />
<PackageReference Include="Longbow.Logging" Version="2.2.13" /> <PackageReference Include="Longbow.Logging" Version="2.2.13" />
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />

View File

@ -21,9 +21,9 @@ namespace Bootstrap.Client.Models
var user = UserHelper.RetrieveUserByUserName(identity.Name); var user = UserHelper.RetrieveUserByUserName(identity.Name);
DisplayName = user.DisplayName; DisplayName = user.DisplayName;
UserName = user.UserName; UserName = user.UserName;
SettingsUrl = DictHelper.RetrieveSettingsUrl(); SettingsUrl = DictHelper.RetrieveSettingsUrl(AppId);
ProfilesUrl = DictHelper.RetrieveProfilesUrl(); ProfilesUrl = DictHelper.RetrieveProfilesUrl(AppId);
NotisUrl = DictHelper.RetrieveNotisUrl(); NotisUrl = DictHelper.RetrieveNotisUrl(AppId);
// set LogoutUrl // set LogoutUrl
var authHost = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>().AuthHost; var authHost = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>().AuthHost;

View File

@ -1,4 +1,5 @@
using Bootstrap.Client.DataAccess; using Bootstrap.Client.DataAccess;
using Longbow.Configuration;
namespace Bootstrap.Client.Models namespace Bootstrap.Client.Models
{ {
@ -12,11 +13,14 @@ namespace Bootstrap.Client.Models
/// </summary> /// </summary>
public ModelBase() public ModelBase()
{ {
Title = DictHelper.RetrieveWebTitle(); AppId = ConfigurationManager.GetValue("AppId", "2");
Footer = DictHelper.RetrieveWebFooter(); Title = DictHelper.RetrieveWebTitle(AppId);
Footer = DictHelper.RetrieveWebFooter(AppId);
Theme = DictHelper.RetrieveActiveTheme(); Theme = DictHelper.RetrieveActiveTheme();
} }
public string AppId { get; private set; }
/// <summary> /// <summary>
/// 获取 网站标题 /// 获取 网站标题
/// </summary> /// </summary>