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 }, {