From 6e1a306ac67ea37dea860e0ab5c3de382ba986b1 Mon Sep 17 00:00:00 2001
From: summer853300975 <853300975@qq.com>
Date: Mon, 7 Nov 2016 21:41:17 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E9=85=8D=E7=BD=AE=E8=8F=9C?=
=?UTF-8?q?=E5=8D=95=E5=AE=8C=E6=88=90=EF=BC=8C=E5=A4=84=E7=90=86=E4=BA=86?=
=?UTF-8?q?=E5=87=A0=E4=B8=AAToDo?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Bootstrap.Admin/Bootstrap.Admin.csproj | 1 +
Bootstrap.Admin/Content/js/framework.js | 15 ++
.../Controllers/GroupsController.cs | 176 +++++++++---------
.../Controllers/MenusController.cs | 34 ++++
Bootstrap.Admin/Models/QueryGroupOption.cs | 1 -
Bootstrap.Admin/Models/QueryRoleOption.cs | 1 -
Bootstrap.Admin/Models/QueryUserOption.cs | 13 +-
Bootstrap.Admin/Scripts/Roles.js | 37 +++-
Bootstrap.Admin/Views/Admin/Roles.cshtml | 10 +
.../Views/Shared/NavigatorConfig.cshtml | 7 +
Bootstrap.Admin/Web.config | 1 +
Bootstrap.DataAccess/MenuHelper.cs | 85 +++++++++
Bootstrap.DataAccessTests/MenuHelperTests.cs | 28 +++
13 files changed, 314 insertions(+), 95 deletions(-)
create mode 100644 Bootstrap.Admin/Views/Shared/NavigatorConfig.cshtml
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