增加资源配置功能,把Url配置成资源

This commit is contained in:
Argo-Lenovo 2017-02-14 21:04:40 +08:00
parent ce459e65f3
commit bf11833af1
6 changed files with 31 additions and 6 deletions

View File

@ -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";
}

View File

@ -33,7 +33,8 @@
Icon: "icon",
Url: "url",
Category: "category",
Target: "target"
Target: "target",
IsResource: "isRes"
}
}),
click: {

View File

@ -135,6 +135,20 @@
</ul>
</div>
</div>
<div class="form-group col-sm-6 col-xs-12">
<label class="control-label" for="isRes">菜单类型</label>
<div class="btn-group dropup btn-select">
<button id="isRes" type="button" class="btn btn-success" data-default-val="0" data-val="0">菜单</button>
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">下拉菜单</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#" data-val="0">菜单</a></li>
<li><a href="#" data-val="1">资源</a></li>
</ul>
</div>
</div>
</div>
</form>
</div>

View File

@ -52,6 +52,10 @@ namespace Bootstrap.DataAccess
/// </summary>
public string Target { get; set; }
/// <summary>
/// 获得/设置 是否为资源文件
/// </summary>
public int IsResource { get; set; }
/// <summary>
///
/// </summary>
public IEnumerable<Menu> Menus { get; set; }

View File

@ -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());

View File

@ -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