!99 feat: 增加默认应用功能
* chore: 更新数据服务为 PetaPoco * feat: 增加默认应用配置 api * feat: 重命名服务
This commit is contained in:
parent
5096910ba3
commit
e25fecb164
|
@ -2,7 +2,6 @@
|
|||
"solution": {
|
||||
"path": "BootstrapAdmin.sln",
|
||||
"projects": [
|
||||
"src\\blazor\\admin\\BootstrapAdmin.DataAccess.EFCore\\BootstrapAdmin.DataAccess.EFCore.csproj",
|
||||
"src\\blazor\\admin\\BootstrapAdmin.DataAccess.Models\\BootstrapAdmin.DataAccess.Models.csproj",
|
||||
"src\\blazor\\admin\\BootstrapAdmin.DataAccess.PetaPoco\\BootstrapAdmin.DataAccess.PetaPoco.csproj",
|
||||
"src\\blazor\\admin\\BootstrapAdmin.Web.Core\\BootstrapAdmin.Web.Core.csproj",
|
||||
|
|
|
@ -159,6 +159,13 @@ class DictService : BaseDatabase, IDict
|
|||
|
||||
public string? GetNotificationUrl(string appId) => GetUrlByName(appId, "系统通知地址");
|
||||
|
||||
public bool GetEnableDefaultApp()
|
||||
{
|
||||
var dicts = GetAll();
|
||||
var code = dicts.FirstOrDefault(d => d.Category == "网站设置" && d.Name == "默认应用程序")?.Code ?? "0";
|
||||
return code == "1";
|
||||
}
|
||||
|
||||
private string? GetUrlByName(string appId, string dictName)
|
||||
{
|
||||
string? url = null;
|
||||
|
@ -191,9 +198,14 @@ class DictService : BaseDatabase, IDict
|
|||
string? url = null;
|
||||
var dicts = GetAll();
|
||||
|
||||
// appId 为空时读取前台列表取第一个应用作为默认应用
|
||||
appId ??= GetApps().FirstOrDefault(d => d.Key != AppId).Key ?? AppId;
|
||||
url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Define == EnumDictDefine.System)?.Code;
|
||||
// 查看是否开启默认应用
|
||||
var enableDefaultApp = GetEnableDefaultApp();
|
||||
if (enableDefaultApp)
|
||||
{
|
||||
// appId 为空时读取前台列表取第一个应用作为默认应用
|
||||
appId ??= GetApps().FirstOrDefault(d => d.Key != AppId).Key ?? AppId;
|
||||
url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Define == EnumDictDefine.System)?.Code;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,4 +149,10 @@ public interface IDict
|
|||
/// <param name="appId"></param>
|
||||
/// <returns></returns>
|
||||
string? GetHomeUrlByAppId(string? appId = null);
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启默认应用
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool GetEnableDefaultApp();
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BootStarpAdmin.DataAccess.FreeSql\BootStarpAdmin.DataAccess.FreeSql.csproj" />
|
||||
<ProjectReference Include="..\BootstrapAdmin.DataAccess.PetaPoco\BootstrapAdmin.DataAccess.PetaPoco.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Binary file not shown.
|
@ -4,6 +4,8 @@ using BootstrapAdmin.Web.Services;
|
|||
using BootstrapAdmin.Web.Services.SMS;
|
||||
using BootstrapAdmin.Web.Services.SMS.Tencent;
|
||||
using BootstrapAdmin.Web.Utils;
|
||||
using PetaPoco;
|
||||
using PetaPoco.Providers;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
|
@ -22,6 +24,10 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
services.AddCors();
|
||||
services.AddResponseCompression();
|
||||
|
||||
// 增加后台任务
|
||||
services.AddTaskServices();
|
||||
services.AddHostedService<AdminTaskService>();
|
||||
|
||||
// 增加 缓存管理服务
|
||||
services.AddCacheManager();
|
||||
|
||||
|
@ -48,30 +54,27 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
// option.UseSqlite(connString);
|
||||
//});
|
||||
|
||||
// 增加 PetaPoco 数据服务
|
||||
//services.AddPetaPocoDataAccessServices((provider, builder) =>
|
||||
//{
|
||||
// var configuration = provider.GetRequiredService<IConfiguration>();
|
||||
// var connString = configuration.GetConnectionString("bb");
|
||||
// builder.UsingProvider<SQLiteDatabaseProvider>()
|
||||
// .UsingConnectionString(connString);
|
||||
//});
|
||||
// 增加 FreeSql 数据服务
|
||||
// services.AddFreeSql((provider, builder) =>
|
||||
// {
|
||||
// var configuration = provider.GetRequiredService<IConfiguration>();
|
||||
// var connString = configuration.GetConnectionString("bb");
|
||||
// builder.UseConnectionString(FreeSql.DataType.Sqlite, connString);
|
||||
//#if DEBUG
|
||||
// //调试sql语句输出
|
||||
// builder.UseMonitorCommand(cmd => System.Console.WriteLine(cmd.CommandText));
|
||||
//#endif
|
||||
// });
|
||||
|
||||
services.AddFreeSql((provider, builder) =>
|
||||
// 增加 PetaPoco 数据服务
|
||||
services.AddPetaPocoDataAccessServices((provider, builder) =>
|
||||
{
|
||||
var configuration = provider.GetRequiredService<IConfiguration>();
|
||||
var connString = configuration.GetConnectionString("bb");
|
||||
builder.UseConnectionString(FreeSql.DataType.Sqlite, connString);
|
||||
#if DEBUG
|
||||
//调试sql语句输出
|
||||
builder.UseMonitorCommand(cmd => System.Console.WriteLine(cmd.CommandText));
|
||||
#endif
|
||||
builder.UsingProvider<SQLiteDatabaseProvider>()
|
||||
.UsingConnectionString(connString);
|
||||
});
|
||||
|
||||
// 增加后台任务
|
||||
services.AddTaskServices();
|
||||
services.AddHostedService<AdminTaskService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class ServicesExtensions
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加示例后台任务
|
Loading…
Reference in New Issue