From 1d1355f07bbe38d9e7a41c06834971cbb5bd4280 Mon Sep 17 00:00:00 2001 From: Argo Windows Date: Tue, 5 Nov 2019 10:10:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/Bootstrap.DataAccess/Helper/MenuHelper.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/admin/Bootstrap.DataAccess/Helper/MenuHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/MenuHelper.cs index 0031e564..c20d96e4 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/MenuHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/MenuHelper.cs @@ -3,6 +3,7 @@ using Bootstrap.Security.DataAccess; using Bootstrap.Security.Mvc; using Longbow.Cache; using Microsoft.Extensions.Configuration; +using System; using System.Collections.Generic; using System.Linq; @@ -116,8 +117,10 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveAppMenus(string appId, string userName, string activeUrl) { + if (string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(userName)) return new BootstrapMenu[0]; + var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0); - if (appId != "0") menus = menus.Where(m => m.Application == appId); + menus = menus.Where(m => m.Application.Equals(appId, StringComparison.OrdinalIgnoreCase)); return DbHelper.CascadeMenus(menus, activeUrl); } @@ -129,6 +132,8 @@ namespace Bootstrap.DataAccess /// public static IEnumerable RetrieveSystemMenus(string userName, string activeUrl = null) { + if (string.IsNullOrEmpty(userName)) return new BootstrapMenu[0]; + var menus = RetrieveAllMenus(userName).Where(m => m.Category == "0" && m.IsResource == 0); return DbHelper.CascadeMenus(menus, activeUrl); }