public JsonResult GetAllRightTree(int roleId) { var roleRights = _permissionManager.GetPermissionsByRoleId(roleId); var allRight = _permissionManager.GetPermissionsByTenantId(CurrentTenant.TenantId); var root = allRight.FirstOrDefault(p => p.ParentId == 0); var node = GetChildRights(root, allRight, roleRights); return(Json(new[] { node }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取角色已有的权限树 /// </summary> /// <param name="roleId">角色Id</param> /// <returns></returns> public JsonResult GetRoleRightTree(int roleId) { var roleRights = _permissionManager.GetPermissionsByRoleId(roleId); var roleAllRights = new List <vTenantFunction>(); foreach (vTenantFunction function in roleRights) { List <vTenantFunction> list = GetFathers(function.PermissionId); foreach (var vTenantFunction in list) { if (roleAllRights.Any(p => p.PermissionId == vTenantFunction.PermissionId)) { continue; } roleAllRights.Add(vTenantFunction); } } var allRight = _permissionManager.GetPermissionsByTenantId(CurrentTenant.TenantId); var root = allRight.FirstOrDefault(p => p.ParentId == 0); var node = GetChildRights(root, roleAllRights, null, 0); return(Json(new[] { node }, JsonRequestBehavior.AllowGet)); }