diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj
index 60912a61..993dfbaf 100644
--- a/Bootstrap.Admin/Bootstrap.Admin.csproj
+++ b/Bootstrap.Admin/Bootstrap.Admin.csproj
@@ -264,6 +264,7 @@
+
diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js
index 932e78c2..aea0d9b5 100644
--- a/Bootstrap.Admin/Content/js/framework.js
+++ b/Bootstrap.Admin/Content/js/framework.js
@@ -310,4 +310,19 @@
Group.saveGroupsByRoleId = function (roleId, groupIds, callback) {
processData.call(this, { Id: roleId, callback: callback, method: "PUT", data: { type: "role", groupIds: groupIds } });
};
+ htmlTemplateForMenu='
';
+ //Menus
+ Menu = {
+ url: '../api/Menus/', title: "授权菜单", html: function (result) {
+ return $.map(result, function (element, index) {
+ return $.format(htmlTemplateForMenu, element.ID, element.Name, element.Active);
+ }).join('');
+ }
+ }
+ Menu.getMenusByRoleId = function (roleId, callback) {
+ processData.call(this, { Id: roleId, callback: callback, data: { type: "role" } });
+ };
+ Menu.saveMenusByRoleId = function (roleId, menuIds, callback) {
+ processData.call(this, { Id: roleId, callback: callback, method: "PUT", data: { type: "role", menuIds:menuIds } });
+ };
})(jQuery);
\ No newline at end of file
diff --git a/Bootstrap.Admin/Controllers/GroupsController.cs b/Bootstrap.Admin/Controllers/GroupsController.cs
index 54e9e1c7..298c9d47 100644
--- a/Bootstrap.Admin/Controllers/GroupsController.cs
+++ b/Bootstrap.Admin/Controllers/GroupsController.cs
@@ -7,94 +7,94 @@ using System.Web.Http;
namespace Bootstrap.Admin.Controllers
{
- public class GroupsController : ApiController
- {
- ///
- ///
- ///
- ///
- ///
- [HttpGet]
- public QueryData Get([FromUri]QueryGroupOption value)
- {
- return value.RetrieveData();
- }
- ///
- ///
- ///
- ///
- ///
- [HttpGet]
- public Group Get(int id)
- {
- return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.ID == id);
- }
- ///
- ///
- ///
- ///
- [HttpPost]
- public bool Post([FromBody]Group value)
- {
- return GroupHelper.SaveGroup(value);
- }
- ///
- ///
- ///
- ///
- [HttpDelete]
- public bool Delete([FromBody]string value)
- {
- return GroupHelper.DeleteGroup(value);
- }
- ///
- ///
- ///
- ///
- ///
- ///
- [HttpPost]
- public IEnumerable Post(int id, [FromBody]JObject value)
- {
- var ret = new List();
- dynamic json = value;
- switch ((string)json.type)
- {
- case "user":
- ret = GroupHelper.RetrieveGroupsByUserId(id).ToList();
- break;
+ public class GroupsController : ApiController
+ {
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet]
+ public QueryData Get([FromUri]QueryGroupOption value)
+ {
+ return value.RetrieveData();
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpGet]
+ public Group Get(int id)
+ {
+ return GroupHelper.RetrieveGroups().FirstOrDefault(t => t.ID == id);
+ }
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ public bool Post([FromBody]Group value)
+ {
+ return GroupHelper.SaveGroup(value);
+ }
+ ///
+ ///
+ ///
+ ///
+ [HttpDelete]
+ public bool Delete([FromBody]string value)
+ {
+ return GroupHelper.DeleteGroup(value);
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ public IEnumerable Post(int id, [FromBody]JObject value)
+ {
+ var ret = new List();
+ dynamic json = value;
+ switch ((string)json.type)
+ {
+ case "user":
+ ret = GroupHelper.RetrieveGroupsByUserId(id).ToList();
+ break;
case "role":
- ret = GroupHelper.RetrieveGroupsByRoleId(id).ToList();
- break;
- default:
- break;
- }
- return ret;
- }
- ///
- ///
- ///
- ///
- ///
- ///
- [HttpPut]
- public bool Put(int id, [FromBody]JObject value)
- {
- var ret = false;
- dynamic json = value;
- string groupIds = json.groupIds;
- switch ((string)json.type)
- {
- case "user":
- ret = GroupHelper.SaveGroupsByUserId(id, groupIds);
- break;
+ ret = GroupHelper.RetrieveGroupsByRoleId(id).ToList();
+ break;
+ default:
+ break;
+ }
+ return ret;
+ }
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpPut]
+ public bool Put(int id, [FromBody]JObject value)
+ {
+ var ret = false;
+ dynamic json = value;
+ string groupIds = json.groupIds;
+ switch ((string)json.type)
+ {
+ case "user":
+ ret = GroupHelper.SaveGroupsByUserId(id, groupIds);
+ break;
case "role":
- ret = GroupHelper.SaveGroupsByRoleId(id, groupIds);
- break;
- default:
- break;
- }
- return ret;
- }
- }
+ ret = GroupHelper.SaveGroupsByRoleId(id, groupIds);
+ break;
+ default:
+ break;
+ }
+ return ret;
+ }
+ }
}
diff --git a/Bootstrap.Admin/Controllers/MenusController.cs b/Bootstrap.Admin/Controllers/MenusController.cs
index 02050b38..ea3e39e5 100644
--- a/Bootstrap.Admin/Controllers/MenusController.cs
+++ b/Bootstrap.Admin/Controllers/MenusController.cs
@@ -1,5 +1,8 @@
using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
+using Newtonsoft.Json.Linq;
+using System.Collections.Generic;
+using System.Linq;
using System.Web.Http;
namespace Bootstrap.Admin.Controllers
@@ -34,5 +37,36 @@ namespace Bootstrap.Admin.Controllers
{
return MenuHelper.DeleteMenu(value);
}
+ [HttpPost]
+ public IEnumerable