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