diff --git a/Bootstrap.Admin/Controllers/Api/MenusController.cs b/Bootstrap.Admin/Controllers/Api/MenusController.cs
index 2028df2f..dbe13674 100644
--- a/Bootstrap.Admin/Controllers/Api/MenusController.cs
+++ b/Bootstrap.Admin/Controllers/Api/MenusController.cs
@@ -16,7 +16,7 @@ namespace Bootstrap.Admin.Controllers.Api
public class MenusController : Controller
{
///
- ///
+ /// 获得所有菜单列表调用
///
///
///
@@ -26,7 +26,7 @@ namespace Bootstrap.Admin.Controllers.Api
return value.RetrieveData(User.Identity.Name);
}
///
- ///
+ /// 保存菜单调用
///
///
[HttpPost]
@@ -35,7 +35,7 @@ namespace Bootstrap.Admin.Controllers.Api
return MenuHelper.SaveMenu(value);
}
///
- ///
+ /// 删除菜单调用
///
///
[HttpDelete]
@@ -68,26 +68,15 @@ namespace Bootstrap.Admin.Controllers.Api
return ret;
}
///
- ///
+ /// 角色管理页面分配菜单时调用
///
- ///
- ///
+ /// 角色ID
+ /// 菜单ID集合
///
[HttpPut("{id}")]
- public bool Put(int id, [FromBody]JObject value)
+ public bool Put(int id, [FromBody]IEnumerable value)
{
- var ret = false;
- dynamic json = value;
- string menuIds = json.menuIds.ToString();
- switch ((string)json.type)
- {
- case "role":
- ret = MenuHelper.SaveMenusByRoleId(id, menuIds);
- break;
- default:
- break;
- }
- return ret;
+ return MenuHelper.SaveMenusByRoleId(id, value);
}
}
}
\ No newline at end of file
diff --git a/Bootstrap.Admin/wwwroot/js/roles.js b/Bootstrap.Admin/wwwroot/js/roles.js
index 5d7a3c52..4e706175 100644
--- a/Bootstrap.Admin/wwwroot/js/roles.js
+++ b/Bootstrap.Admin/wwwroot/js/roles.js
@@ -87,17 +87,10 @@
},
'#btnSubmitMenu': function (row) {
var roleId = row.Id;
- var type = $btnSubmitMenu.data('type');
- switch (type) {
- case "menu":
- var menuIds = $nestMenuInput.find('input:checkbox:checked').map(function (index, element) {
- return $(element).val();
- }).toArray().join(',');
- break;
- default:
- break;
- }
- $.bc({ id: roleId, url: Menu.url, method: "put", data: { type: "role", menuIds: menuIds }, modal: '#dialogMenu', title: Menu.title });
+ var menuIds = $nestMenuInput.find('input:checkbox:checked').map(function (index, element) {
+ return $(element).val();
+ }).toArray();
+ $.bc({ id: roleId, url: Menu.url, method: "put", data: menuIds, modal: '#dialogMenu', title: Menu.title });
}
}
},
diff --git a/Bootstrap.DataAccess/CacheCleanUtility.cs b/Bootstrap.DataAccess/CacheCleanUtility.cs
index ab39a2ec..17076fb5 100644
--- a/Bootstrap.DataAccess/CacheCleanUtility.cs
+++ b/Bootstrap.DataAccess/CacheCleanUtility.cs
@@ -18,7 +18,7 @@ namespace Bootstrap.DataAccess
///
///
///
- internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, string menuIds = null, string dictIds = null, string cacheKey = null)
+ internal static void ClearCache(string roleIds = null, string userIds = null, string groupIds = null, IEnumerable menuIds = null, string dictIds = null, string cacheKey = null)
{
var cacheKeys = new List();
var corsKeys = new List();
@@ -62,7 +62,7 @@ namespace Bootstrap.DataAccess
}
if (menuIds != null)
{
- menuIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach(id =>
+ menuIds.ToList().ForEach(id =>
{
cacheKeys.Add(string.Format("{0}-{1}", RoleHelper.RetrieveRolesByMenuIdDataKey, id));
});
diff --git a/Bootstrap.DataAccess/MenuHelper.cs b/Bootstrap.DataAccess/MenuHelper.cs
index 84b9b63a..f1c1874b 100644
--- a/Bootstrap.DataAccess/MenuHelper.cs
+++ b/Bootstrap.DataAccess/MenuHelper.cs
@@ -32,7 +32,7 @@ namespace Bootstrap.DataAccess
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ids", ids));
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == value.Count();
}
- CacheCleanUtility.ClearCache(menuIds: ids);
+ CacheCleanUtility.ClearCache(menuIds: value);
return ret;
}
///
@@ -64,7 +64,7 @@ namespace Bootstrap.DataAccess
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@ApplicationCode", p.ApplicationCode));
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == 1;
}
- CacheCleanUtility.ClearCache(menuIds: p.Id == 0 ? string.Empty : p.Id.ToString());
+ CacheCleanUtility.ClearCache(menuIds: p.Id == 0 ? new List() : new List() { p.Id });
return ret;
}
@@ -103,13 +103,13 @@ namespace Bootstrap.DataAccess
///
///
///
- public static bool SaveMenusByRoleId(int id, string menuIds)
+ public static bool SaveMenusByRoleId(int id, IEnumerable menuIds)
{
bool ret = false;
DataTable dt = new DataTable();
dt.Columns.Add("RoleID", typeof(int));
dt.Columns.Add("NavigationID", typeof(int));
- if (!string.IsNullOrEmpty(menuIds)) menuIds.Split(',').ToList().ForEach(menuId => dt.Rows.Add(id, Convert.ToInt32(menuId)));
+ menuIds.ToList().ForEach(menuId => dt.Rows.Add(id, menuId));
using (TransactionPackage transaction = DBAccessManager.SqlDBAccess.BeginTransaction())
{
try
diff --git a/Bootstrap.DataAccess/RoleHelper.cs b/Bootstrap.DataAccess/RoleHelper.cs
index 9aaf431b..790b491f 100644
--- a/Bootstrap.DataAccess/RoleHelper.cs
+++ b/Bootstrap.DataAccess/RoleHelper.cs
@@ -223,7 +223,7 @@ namespace Bootstrap.DataAccess
transaction.CommitTransaction();
}
}
- CacheCleanUtility.ClearCache(roleIds: roleIds, menuIds: id.ToString());
+ CacheCleanUtility.ClearCache(roleIds: roleIds, menuIds: new List() { id });
ret = true;
}
catch (Exception ex)