OpenAuth.Net/OpenAuth.Mvc/Controllers/RoleManagerController.cs

81 lines
2.1 KiB
C#
Raw Normal View History

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