From 0ec160bbb59a200d82f313f8f2ff897063c9b955 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Fri, 23 Aug 2019 23:02:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=A7=92=E8=89=B2=E6=8E=88=E6=9D=83=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=AD=89=E9=A1=B9=E7=9B=AE=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/HealthChecks/DBHealthCheck.cs | 15 +++++++++++++-- Bootstrap.Admin/wwwroot/js/healths.js | 6 +++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Bootstrap.Admin/HealthChecks/DBHealthCheck.cs b/Bootstrap.Admin/HealthChecks/DBHealthCheck.cs index 3ec99cd7..d5e8a2c6 100644 --- a/Bootstrap.Admin/HealthChecks/DBHealthCheck.cs +++ b/Bootstrap.Admin/HealthChecks/DBHealthCheck.cs @@ -45,15 +45,26 @@ namespace Bootstrap.Admin.HealthChecks Widget = config["Widget"], ConnectionString = ConnectionStringResolve(config.GetSection("ConnectionStrings").Exists() ? config : _configuration, string.Empty) }).FirstOrDefault(i => i.Enabled); + + // 检查 Admin 账户权限 + var user = UserHelper.RetrieveUserByUserName("Admin"); + var roles = RoleHelper.RetrievesByUserName("Admin"); var dicts = DictHelper.RetrieveDicts(); + var menus = MenuHelper.RetrieveMenusByUserName("Admin"); + var data = new Dictionary() { { "ConnectionString", db.ConnectionString }, { "Widget", db.Widget }, { "DbType", db.ProviderName }, - { "Dicts", dicts.Count() } + { "Dicts", dicts.Count() }, + { "User(Admin)", user != null }, + { "Roles(Admin)", string.Join(",", roles) }, + { "Navigations(Admin)", menus.Count() } }; - return dicts.Any() ? Task.FromResult(HealthCheckResult.Healthy("Ok", data)) : Task.FromResult(HealthCheckResult.Degraded("No init data in DB")); + + var v = dicts.Any() && user != null && roles.Any() && menus.Any(); + return v ? Task.FromResult(HealthCheckResult.Healthy("Ok", data)) : Task.FromResult(HealthCheckResult.Degraded("Failed")); } } } diff --git a/Bootstrap.Admin/wwwroot/js/healths.js b/Bootstrap.Admin/wwwroot/js/healths.js index ede0b1d1..f859358e 100644 --- a/Bootstrap.Admin/wwwroot/js/healths.js +++ b/Bootstrap.Admin/wwwroot/js/healths.js @@ -9,6 +9,10 @@ return cate[value]; }; + var ExceptionFormatter = function (value) { + return value ? JSON.stringify(value) : null; + }; + var $table = $('#tbCheck').smartTable({ sidePagination: "client", showToggle: false, @@ -17,7 +21,7 @@ columns: [ { title: "分类", field: "Name", formatter: CategoryFormatter }, { title: "描述", field: "Description" }, - { title: "异常信息", field: "Exception" }, + { title: "异常信息", field: "Exception", formatter: ExceptionFormatter }, { title: "耗时", field: "Duration" }, { title: "检查结果", field: "Status", formatter: StatusFormatter }, {