From e25fecb16422d6d16f86f09d4449f796e1b41d95 Mon Sep 17 00:00:00 2001 From: Argo Date: Wed, 12 Jan 2022 03:22:42 +0000 Subject: [PATCH] =?UTF-8?q?!99=20feat:=20=E5=A2=9E=E5=8A=A0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=BA=94=E7=94=A8=E5=8A=9F=E8=83=BD=20*=20chore:=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E6=9C=8D=E5=8A=A1=E4=B8=BA?= =?UTF-8?q?=20PetaPoco=20*=20feat:=20=E5=A2=9E=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E9=85=8D=E7=BD=AE=20api=20*=20feat:=20?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BootstrapAdmin-Blazor.slnf | 1 - .../Services/DictService.cs | 18 ++++++-- .../admin/BootstrapAdmin.Web.Core/IDict.cs | 6 +++ .../BootstrapAdmin.Web.csproj | 2 +- .../BootstrapAdmin.Web/BootstrapAdmin.db | Bin 167936 -> 167936 bytes .../Extensions/ServiceCollectionExtensions.cs | 39 ++++++++++-------- ...ions.cs => ServiceCollectionExtensions.cs} | 2 +- 7 files changed, 44 insertions(+), 24 deletions(-) rename src/blazor/client/BootstrapClient.Web/Extensions/{ServicesExtensions.cs => ServiceCollectionExtensions.cs} (95%) diff --git a/BootstrapAdmin-Blazor.slnf b/BootstrapAdmin-Blazor.slnf index 94ec6aaa..5f6d75ed 100644 --- a/BootstrapAdmin-Blazor.slnf +++ b/BootstrapAdmin-Blazor.slnf @@ -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", diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs index 548bd090..7e07daac 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/DictService.cs @@ -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; } } diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs index e0b20c73..cd7eb6fc 100644 --- a/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/IDict.cs @@ -149,4 +149,10 @@ public interface IDict /// /// string? GetHomeUrlByAppId(string? appId = null); + + /// + /// 是否开启默认应用 + /// + /// + bool GetEnableDefaultApp(); } diff --git a/src/blazor/admin/BootstrapAdmin.Web/BootstrapAdmin.Web.csproj b/src/blazor/admin/BootstrapAdmin.Web/BootstrapAdmin.Web.csproj index 4fb7a65b..6997d44d 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/BootstrapAdmin.Web.csproj +++ b/src/blazor/admin/BootstrapAdmin.Web/BootstrapAdmin.Web.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/blazor/admin/BootstrapAdmin.Web/BootstrapAdmin.db b/src/blazor/admin/BootstrapAdmin.Web/BootstrapAdmin.db index 5708b5a6dda3a0822e0368e25bc9b99c78d581aa..661b75a4f3807d4268c89589154db6a1b884f66a 100644 GIT binary patch delta 34 qcmZozz}2vTYl1W*_e2?IR&EA8|Jscyx2`i9G~3_UZhwRE;C2AS91Pw7 delta 34 qcmZozz}2vTYl1W**F+g-RxSoTm4=Nex2`i9HrwCWZhwRE;C2APP7JjG diff --git a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs index 4e0f4bd6..9f817f49 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Extensions/ServiceCollectionExtensions.cs @@ -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(); + // 增加 缓存管理服务 services.AddCacheManager(); @@ -48,30 +54,27 @@ namespace Microsoft.Extensions.DependencyInjection // option.UseSqlite(connString); //}); - // 增加 PetaPoco 数据服务 - //services.AddPetaPocoDataAccessServices((provider, builder) => - //{ - // var configuration = provider.GetRequiredService(); - // var connString = configuration.GetConnectionString("bb"); - // builder.UsingProvider() - // .UsingConnectionString(connString); - //}); + // 增加 FreeSql 数据服务 + // services.AddFreeSql((provider, builder) => + // { + // var configuration = provider.GetRequiredService(); + // 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(); 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() + .UsingConnectionString(connString); }); - // 增加后台任务 - services.AddTaskServices(); - services.AddHostedService(); - return services; } } diff --git a/src/blazor/client/BootstrapClient.Web/Extensions/ServicesExtensions.cs b/src/blazor/client/BootstrapClient.Web/Extensions/ServiceCollectionExtensions.cs similarity index 95% rename from src/blazor/client/BootstrapClient.Web/Extensions/ServicesExtensions.cs rename to src/blazor/client/BootstrapClient.Web/Extensions/ServiceCollectionExtensions.cs index 62db1765..f7caad32 100644 --- a/src/blazor/client/BootstrapClient.Web/Extensions/ServicesExtensions.cs +++ b/src/blazor/client/BootstrapClient.Web/Extensions/ServiceCollectionExtensions.cs @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.DependencyInjection /// /// /// - public static class ServicesExtensions + public static class ServiceCollectionExtensions { /// /// 添加示例后台任务