From 8ce6778bb32748242a94c758bdfc2cbe23f0b7cb Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Mon, 1 Jul 2019 15:48:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=A0=B9=E6=8D=AE=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=BB=84=E4=BB=B6=E7=A7=BB=E9=99=A4Client.DataAccess?= =?UTF-8?q?=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #Comment DbHelper增加大量公用静态方法 --- Bootstrap.Admin/appsettings.Development.json | 7 +++++++ .../Bootstrap.Client.DataAccess.csproj | 15 --------------- Bootstrap.Client.DataAccess/DbAccessManager.cs | 16 ---------------- Bootstrap.Client.DataAccess/DictHelper.cs | 17 ----------------- Bootstrap.Client/Bootstrap.Client.csproj | 6 ++---- Bootstrap.Client/Controllers/HomeController.cs | 2 +- Bootstrap.Client/Models/HeaderBarModel.cs | 2 +- Bootstrap.Client/Models/ModelBase.cs | 3 +-- Bootstrap.Client/Models/NavigatorBarModel.cs | 5 ++--- Bootstrap.Client/Startup.cs | 3 +-- Bootstrap.Client/appsettings.Development.json | 2 +- Bootstrap.Client/appsettings.json | 2 +- BootstrapAdmin.sln | 7 ------- 13 files changed, 17 insertions(+), 70 deletions(-) delete mode 100644 Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj delete mode 100644 Bootstrap.Client.DataAccess/DbAccessManager.cs delete mode 100644 Bootstrap.Client.DataAccess/DictHelper.cs diff --git a/Bootstrap.Admin/appsettings.Development.json b/Bootstrap.Admin/appsettings.Development.json index 5c9025b1..5a25ad7b 100644 --- a/Bootstrap.Admin/appsettings.Development.json +++ b/Bootstrap.Admin/appsettings.Development.json @@ -50,6 +50,13 @@ "SlidingExpiration": true, "Desc": "通过菜单获得角色数据" }, + { + "Enabled": true, + "Key": "AppHelper-RetrieveAppsByUserName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "指定用户授权应用数据缓存" + }, { "Enabled": true, "Key": "BootstrapUser-RetrieveUsersByName", diff --git a/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj b/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj deleted file mode 100644 index 4e1b388a..00000000 --- a/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - netstandard2.0 - - - - - - - - - - - diff --git a/Bootstrap.Client.DataAccess/DbAccessManager.cs b/Bootstrap.Client.DataAccess/DbAccessManager.cs deleted file mode 100644 index ad0e73a2..00000000 --- a/Bootstrap.Client.DataAccess/DbAccessManager.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Longbow.Data; -using PetaPoco; - -namespace Bootstrap.Client.DataAccess -{ - /// - /// - /// - public static class DbAccessManager - { - /// - /// - /// - public static IDatabase DbAccess { get { return DbManager.Create(); } } - } -} diff --git a/Bootstrap.Client.DataAccess/DictHelper.cs b/Bootstrap.Client.DataAccess/DictHelper.cs deleted file mode 100644 index 54a3a2d9..00000000 --- a/Bootstrap.Client.DataAccess/DictHelper.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Bootstrap.Security.DataAccess; -using System.Linq; - -namespace Bootstrap.Client.DataAccess -{ - /// - /// - /// - public static class DictHelper - { - /// - /// 获取验证码图床 - /// - /// - public static string RetrieveImagesLibUrl() => DbHelper.RetrieveDictsWithCache().FirstOrDefault(d => d.Name == "验证码图床" && d.Category == "系统设置" && d.Define == 0)?.Code ?? "http://images.sdgxgz.com/"; - } -} diff --git a/Bootstrap.Client/Bootstrap.Client.csproj b/Bootstrap.Client/Bootstrap.Client.csproj index fe26d8c9..77148d4a 100644 --- a/Bootstrap.Client/Bootstrap.Client.csproj +++ b/Bootstrap.Client/Bootstrap.Client.csproj @@ -10,11 +10,9 @@ + - - - - + diff --git a/Bootstrap.Client/Controllers/HomeController.cs b/Bootstrap.Client/Controllers/HomeController.cs index 82fb4b62..645df249 100644 --- a/Bootstrap.Client/Controllers/HomeController.cs +++ b/Bootstrap.Client/Controllers/HomeController.cs @@ -38,7 +38,7 @@ namespace Bootstrap.Client.Controllers [AllowAnonymous] public IActionResult Error(int id) { - var options = ConfigurationManager.Get(); + var options = ConfigurationManager.Get(); var uriBuilder = new UriBuilder(options.AuthHost) { Query = QueryString.Create(CookieAuthenticationDefaults.ReturnUrlParameter, $"{Request.Scheme}://{Request.Host}{Request.PathBase}").ToString() }; uriBuilder.Path = uriBuilder.Path == "/" ? Request.Path.Value : uriBuilder.Path + Request.Path.Value; return Redirect(uriBuilder.ToString()); diff --git a/Bootstrap.Client/Models/HeaderBarModel.cs b/Bootstrap.Client/Models/HeaderBarModel.cs index 332fd4cf..99749a3e 100644 --- a/Bootstrap.Client/Models/HeaderBarModel.cs +++ b/Bootstrap.Client/Models/HeaderBarModel.cs @@ -26,7 +26,7 @@ namespace Bootstrap.Client.Models NotisUrl = DbHelper.RetrieveNotisUrl(); // set LogoutUrl - var authHost = ConfigurationManager.Get().AuthHost; + var authHost = ConfigurationManager.Get().AuthHost; var uriBuilder = new UriBuilder(authHost); uriBuilder.Path = uriBuilder.Path == "/" ? CookieAuthenticationDefaults.LogoutPath.Value : $"{uriBuilder.Path.TrimEnd('/')}{CookieAuthenticationDefaults.LogoutPath.Value}"; LogoutUrl = uriBuilder.ToString(); diff --git a/Bootstrap.Client/Models/ModelBase.cs b/Bootstrap.Client/Models/ModelBase.cs index 4c1898b5..2b76baf7 100644 --- a/Bootstrap.Client/Models/ModelBase.cs +++ b/Bootstrap.Client/Models/ModelBase.cs @@ -1,5 +1,4 @@ -using Bootstrap.Client.DataAccess; -using Bootstrap.Security.DataAccess; +using Bootstrap.Security.DataAccess; namespace Bootstrap.Client.Models { diff --git a/Bootstrap.Client/Models/NavigatorBarModel.cs b/Bootstrap.Client/Models/NavigatorBarModel.cs index 577b1140..3cc0341e 100644 --- a/Bootstrap.Client/Models/NavigatorBarModel.cs +++ b/Bootstrap.Client/Models/NavigatorBarModel.cs @@ -1,5 +1,4 @@ -using Bootstrap.Client.DataAccess; -using Bootstrap.Security; +using Bootstrap.Security; using Bootstrap.Security.DataAccess; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; @@ -18,7 +17,7 @@ namespace Bootstrap.Client.Models public NavigatorBarModel(ControllerBase controller) : base(controller.User.Identity) { Navigations = DbHelper.RetrieveAppCascadeMenus(UserName, $"~/{controller.ControllerContext.ActionDescriptor.ControllerName}/{controller.ControllerContext.ActionDescriptor.ActionName}"); - ImageLibUrl = DictHelper.RetrieveImagesLibUrl(); + ImageLibUrl = DbHelper.RetrieveImagesLibUrl(); } /// diff --git a/Bootstrap.Client/Startup.cs b/Bootstrap.Client/Startup.cs index b130d67b..19854bc3 100644 --- a/Bootstrap.Client/Startup.cs +++ b/Bootstrap.Client/Startup.cs @@ -1,5 +1,4 @@ -using Bootstrap.Client.DataAccess; -using Bootstrap.Security.DataAccess; +using Bootstrap.Security.DataAccess; using Longbow.Configuration; using Longbow.Web; using Longbow.Web.SignalR; diff --git a/Bootstrap.Client/appsettings.Development.json b/Bootstrap.Client/appsettings.Development.json index 53c73a59..d91cc053 100644 --- a/Bootstrap.Client/appsettings.Development.json +++ b/Bootstrap.Client/appsettings.Development.json @@ -31,7 +31,7 @@ } ], "SimulateUserName": "Admin", - "BootstrapAdminOptions": { + "BootstrapAdminAuthenticationOptions": { "AuthHost": "http://localhost:50852" }, "AllowOrigins": "http://localhost:50852" diff --git a/Bootstrap.Client/appsettings.json b/Bootstrap.Client/appsettings.json index 59509234..7c23ca28 100644 --- a/Bootstrap.Client/appsettings.json +++ b/Bootstrap.Client/appsettings.json @@ -29,7 +29,7 @@ } ], "AppId": 2, - "BootstrapAdminOptions": { + "BootstrapAdminAuthenticationOptions": { "AuthHost": "http://argo.zylweb.cn/BA" }, "AllowOrigins": "http://localhost,http://argo.zylweb.cn", diff --git a/BootstrapAdmin.sln b/BootstrapAdmin.sln index 8df7a4ec..2b93d145 100644 --- a/BootstrapAdmin.sln +++ b/BootstrapAdmin.sln @@ -30,8 +30,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bootstrap.Client", "Bootstr EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{C7F51A14-2D89-4D1F-AD78-C42B79AB0BF0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bootstrap.Client.DataAccess", "Bootstrap.Client.DataAccess\Bootstrap.Client.DataAccess.csproj", "{B6B29DE5-D7B0-4A4D-9E7A-AADC68E9C43F}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bootstrap.DataAccess", "Bootstrap.DataAccess\Bootstrap.DataAccess.csproj", "{8D62BE79-BE13-43C8-969B-C9B00B3C84B7}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQLite", "SQLite", "{523515EC-2AD7-4282-9AF4-9D20371183B0}" @@ -83,10 +81,6 @@ Global {C82A6E45-AB90-43D1-8429-5CBE953D8151}.Debug|Any CPU.Build.0 = Debug|Any CPU {C82A6E45-AB90-43D1-8429-5CBE953D8151}.Release|Any CPU.ActiveCfg = Release|Any CPU {C82A6E45-AB90-43D1-8429-5CBE953D8151}.Release|Any CPU.Build.0 = Release|Any CPU - {B6B29DE5-D7B0-4A4D-9E7A-AADC68E9C43F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6B29DE5-D7B0-4A4D-9E7A-AADC68E9C43F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6B29DE5-D7B0-4A4D-9E7A-AADC68E9C43F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6B29DE5-D7B0-4A4D-9E7A-AADC68E9C43F}.Release|Any CPU.Build.0 = Release|Any CPU {8D62BE79-BE13-43C8-969B-C9B00B3C84B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D62BE79-BE13-43C8-969B-C9B00B3C84B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D62BE79-BE13-43C8-969B-C9B00B3C84B7}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -106,7 +100,6 @@ Global GlobalSection(NestedProjects) = preSolution {87319AF5-7C40-4362-B67C-35F9DD737DB4} = {586410F2-C1F0-47CD-AB28-2CF506DED2C8} {C82A6E45-AB90-43D1-8429-5CBE953D8151} = {C7F51A14-2D89-4D1F-AD78-C42B79AB0BF0} - {B6B29DE5-D7B0-4A4D-9E7A-AADC68E9C43F} = {C7F51A14-2D89-4D1F-AD78-C42B79AB0BF0} {523515EC-2AD7-4282-9AF4-9D20371183B0} = {586410F2-C1F0-47CD-AB28-2CF506DED2C8} {A06A0AD8-A246-4329-B024-7174AE4A3EDE} = {586410F2-C1F0-47CD-AB28-2CF506DED2C8} {084E2E94-6B7D-4D3E-9BF1-6972427FBF80} = {586410F2-C1F0-47CD-AB28-2CF506DED2C8}