OpenAuth.Net/OpenAuth.Mvc/Controllers/RoleManagerController.cs
2017-10-11 16:19:34 +08:00

81 lines
2.1 KiB
C#

using Infrastructure;
using OpenAuth.App;
using System;
using System.Web.Http;
using System.Web.Mvc;
using Newtonsoft.Json.Linq;
using OpenAuth.Mvc.Models;
namespace OpenAuth.Mvc.Controllers
{
public class RoleManagerController : BaseController
{
public RoleManagerApp App { get; set; }
//
// GET: /RoleManager/
[Authenticate]
public ActionResult Index()
{
return View();
}
//添加或修改角色
[System.Web.Mvc.HttpPost]
public string Add([FromBody]JObject obj)
{
try
{
App.AddOrUpdate(obj);
}
catch (Exception ex)
{
Result.Status = false;
Result.Message = ex.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
/// <summary>
/// 加载角色下面的所有用户
/// </summary>
public string Load(string orgId, int pageCurrent = 1, int pageSize = 30)
{
return JsonHelper.Instance.Serialize(App.Load(orgId, pageCurrent, pageSize));
}
[System.Web.Mvc.HttpPost]
public string Delete(string[] ids)
{
try
{
foreach (var obj in ids)
{
App.Delete(obj);
}
}
catch (Exception e)
{
Result.Status = false;
Result.Message = e.Message;
}
return JsonHelper.Instance.Serialize(Result);
}
#region
public ActionResult LookupMulti(string firstId, string key)
{
ViewBag.FirstId = firstId;
ViewBag.ModuleType = key;
return View();
}
public string LoadForOrgAndUser(string orgId, string userId)
{
return JsonHelper.Instance.Serialize(App.LoadForOrgAndUser(orgId, userId));
}
#endregion
}
}