diff --git a/Bootstrap.Admin/Models/NavigatorBarModel.cs b/Bootstrap.Admin/Models/NavigatorBarModel.cs index d365134f..c83f8d5a 100644 --- a/Bootstrap.Admin/Models/NavigatorBarModel.cs +++ b/Bootstrap.Admin/Models/NavigatorBarModel.cs @@ -9,7 +9,7 @@ namespace Bootstrap.Admin.Models { public NavigatorBarModel(string url) { - Navigations = MenuHelper.RetrieveNavigationsByUserName(UserName); + Navigations = MenuHelper.RetrieveNavigationsByUserName(UserName).Where(m => m.IsResource == 0); ActiveMenu(null, Navigations.ToList(), url); HomeUrl = "~/Admin/Index"; } diff --git a/Bootstrap.Admin/Scripts/Menus.js b/Bootstrap.Admin/Scripts/Menus.js index 9fb26e1b..1cef713e 100644 --- a/Bootstrap.Admin/Scripts/Menus.js +++ b/Bootstrap.Admin/Scripts/Menus.js @@ -33,7 +33,8 @@ Icon: "icon", Url: "url", Category: "category", - Target: "target" + Target: "target", + IsResource: "isRes" } }), click: { diff --git a/Bootstrap.Admin/Views/Admin/Menus.cshtml b/Bootstrap.Admin/Views/Admin/Menus.cshtml index 34b06bf4..0e528d5e 100644 --- a/Bootstrap.Admin/Views/Admin/Menus.cshtml +++ b/Bootstrap.Admin/Views/Admin/Menus.cshtml @@ -135,6 +135,20 @@ +
+ +
+ + + +
+
diff --git a/Bootstrap.DataAccess/Menu.cs b/Bootstrap.DataAccess/Menu.cs index ad9d5552..9471e2e6 100644 --- a/Bootstrap.DataAccess/Menu.cs +++ b/Bootstrap.DataAccess/Menu.cs @@ -52,6 +52,10 @@ namespace Bootstrap.DataAccess /// public string Target { get; set; } /// + /// 获得/设置 是否为资源文件 + /// + public int IsResource { get; set; } + /// /// /// public IEnumerable Menus { get; set; } diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs index 12f526d7..530fdd05 100644 --- a/Bootstrap.DataAccess/MenuHelper.cs +++ b/Bootstrap.DataAccess/MenuHelper.cs @@ -48,8 +48,9 @@ namespace Bootstrap.DataAccess Url = LgbConvert.ReadValue(reader[5], string.Empty), Category = (string)reader[6], Target = (string)reader[7], - CategoryName = (string)reader[8], - ParentName = LgbConvert.ReadValue(reader[9], string.Empty) + IsResource = (bool)reader[8] ? 1 : 0, + CategoryName = (string)reader[9], + ParentName = LgbConvert.ReadValue(reader[10], string.Empty) }); } } @@ -140,8 +141,8 @@ namespace Bootstrap.DataAccess if (p.Icon != null && p.Icon.Length > 50) p.Icon.Substring(0, 50); if (p.Url != null && p.Url.Length > 50) p.Url.Substring(0, 50); string sql = p.ID == 0 ? - "Insert Into Navigations (ParentId, Name, [Order], Icon, Url, Category, Target) Values (@ParentId, @Name, @Order, @Icon, @Url, @Category, @Target)" : - "Update Navigations set ParentId = @ParentId, Name = @Name, [Order] = @Order, Icon = @Icon, Url = @Url, Category = @Category, Target = @Target where ID = @ID"; + "Insert Into Navigations (ParentId, Name, [Order], Icon, Url, Category, Target, IsResource) Values (@ParentId, @Name, @Order, @Icon, @Url, @Category, @Target, @IsResource)" : + "Update Navigations set ParentId = @ParentId, Name = @Name, [Order] = @Order, Icon = @Icon, Url = @Url, Category = @Category, Target = @Target, IsResource = @IsResource where ID = @ID"; try { using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) @@ -154,6 +155,7 @@ namespace Bootstrap.DataAccess cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Url", DBAccess.ToDBValue(p.Url), ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", p.Category, ParameterDirection.Input)); cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Target", p.Target, ParameterDirection.Input)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@IsResource", p.IsResource, ParameterDirection.Input)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } CacheCleanUtility.ClearCache(menuIds: p.ID == 0 ? string.Empty : p.ID.ToString()); diff --git a/DatabaseScripts/Install.sql b/DatabaseScripts/Install.sql index fd617684..8b9c12b6 100644 --- a/DatabaseScripts/Install.sql +++ b/DatabaseScripts/Install.sql @@ -174,6 +174,7 @@ CREATE TABLE [dbo].[Navigations]( [Url] [varchar](4000) NULL, [Category] [nvarchar](50) NOT NULL, [Target] [varchar](10) NOT NULL, + [IsResource] [bit] NOT NULL, CONSTRAINT [PK_Navigations] PRIMARY KEY CLUSTERED ( [ID] ASC @@ -316,6 +317,9 @@ GO ALTER TABLE [dbo].[Notifications] ADD CONSTRAINT [DF_Notifications_Status] DEFAULT ((0)) FOR [Status] GO +ALTER TABLE [dbo].[Navigations] ADD CONSTRAINT [DF_Navigations_IsResource] DEFAULT ((0)) FOR [IsResource] +GO + /****** Object: Table [dbo].[Messages] Script Date: 11/14/2016 13:59:21 ******/ SET ANSI_NULLS ON GO