mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
完成资源分配前端模块化处理
This commit is contained in:
@@ -41,15 +41,6 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择上级机构页面
|
||||
/// </summary>
|
||||
/// <returns>ActionResult.</returns>
|
||||
public ActionResult LookupParent()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult AddOrg()
|
||||
{
|
||||
return View();
|
||||
|
55
OpenAuth.Mvc/Controllers/RelevanceManagerController.cs
Normal file
55
OpenAuth.Mvc/Controllers/RelevanceManagerController.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Mvc.Models;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class RelevanceManagerController : BaseController
|
||||
{
|
||||
private RevelanceManagerApp _app;
|
||||
|
||||
public RelevanceManagerController()
|
||||
{
|
||||
_app = AutofacExt.GetFromFac<RevelanceManagerApp>();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Anonymous]
|
||||
public string Assign(string type, int firstId, string secIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var secIdList = JsonHelper.Instance.Deserialize<int[]>(secIds);
|
||||
_app.Assign(type, firstId, secIdList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
[HttpPost]
|
||||
[Anonymous]
|
||||
public string UnAssign(string type, int firstId, string secIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
var secIdList = JsonHelper.Instance.Deserialize<int[]>(secIds);
|
||||
_app.UnAssign(type, firstId, secIdList);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
}
|
||||
}
|
@@ -76,63 +76,31 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
#region 为用户分配资源
|
||||
|
||||
public ActionResult LookupMultiForUser(int userId)
|
||||
/// <summary>
|
||||
/// 为用户或角色分配权限
|
||||
/// </summary>
|
||||
/// <param name="firstId">关联表中的firstId.</param>
|
||||
/// <param name="key">关联表中的Key
|
||||
/// <para>如:UserResource/RoleResource</para>
|
||||
/// </param>
|
||||
/// <returns>ActionResult.</returns>
|
||||
public ActionResult AssignRes(int firstId, string key)
|
||||
{
|
||||
ViewBag.UserId = userId;
|
||||
ViewBag.FirstId = firstId;
|
||||
ViewBag.ModuleType = key;
|
||||
return View();
|
||||
}
|
||||
|
||||
public string LoadWithUserAccess(int cId, int userId)
|
||||
/// <summary>
|
||||
/// 加载带有授权的资源信息
|
||||
/// </summary>
|
||||
/// <param name="cId">分类ID</param>
|
||||
/// <param name="firstId">关联表中的firstId</param>
|
||||
/// <param name="key">关联表中的key</param>
|
||||
/// <returns>System.String.</returns>
|
||||
public string LoadWithAccess(int cId, int firstId, string key)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.LoadWithAccess("UserResource",userId, cId));
|
||||
return JsonHelper.Instance.Serialize(_app.LoadWithAccess(key,firstId, cId));
|
||||
}
|
||||
|
||||
public string AccessForUser(int userId, string ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resIds = ids.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_app.AssignResForUser(userId, resIds);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.message = e.Message;
|
||||
BjuiResponse.statusCode = "300";
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
#endregion 为用户分配资源
|
||||
|
||||
#region 为角色分配资源
|
||||
public ActionResult LookupMultiForRole(int roleId)
|
||||
{
|
||||
ViewBag.RoleId = roleId;
|
||||
return View();
|
||||
}
|
||||
|
||||
public string LoadWithRoleAccess(int cId, int roleId)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.LoadWithAccess("RoleResource", roleId, cId));
|
||||
}
|
||||
|
||||
public string AccessForRole(int roleId, string ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resIds = ids.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_app.AssignResForRole(roleId, resIds);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.message = e.Message;
|
||||
BjuiResponse.statusCode = "300";
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user