mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
111 lines
2.8 KiB
C#
111 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web.Http;
|
|
using System.Web.Mvc;
|
|
using Infrastructure;
|
|
using OpenAuth.App;
|
|
using OpenAuth.App.Request;
|
|
using OpenAuth.App.Response;
|
|
using OpenAuth.Mvc.Models;
|
|
|
|
namespace OpenAuth.Mvc.Controllers
|
|
{
|
|
public class RoleManagerController : BaseController
|
|
{
|
|
public RoleApp App { get; set; }
|
|
public RevelanceManagerApp RevelanceManagerApp { get; set; }
|
|
|
|
//
|
|
// GET: /UserManager/
|
|
[Authenticate]
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult Assign()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
//添加或修改组织
|
|
[System.Web.Mvc.HttpPost]
|
|
public string Add(RoleView obj)
|
|
{
|
|
try
|
|
{
|
|
App.Add(obj);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Result.Code = 500;
|
|
Result.Message = ex.Message;
|
|
}
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
}
|
|
|
|
//添加或修改组织
|
|
[System.Web.Mvc.HttpPost]
|
|
public string Update(RoleView obj)
|
|
{
|
|
try
|
|
{
|
|
App.Update(obj);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Result.Code = 500;
|
|
Result.Message = ex.Message;
|
|
}
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载用户的角色
|
|
/// </summary>
|
|
public string LoadForUser(string userId)
|
|
{
|
|
try
|
|
{
|
|
var result = new Response<List<string>>
|
|
{
|
|
Result = RevelanceManagerApp.Get(Define.USERROLE, true, userId)
|
|
};
|
|
return JsonHelper.Instance.Serialize(result);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Result.Code = 500;
|
|
Result.Message = e.Message;
|
|
}
|
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载组织下面的所有用户
|
|
/// </summary>
|
|
public string Load([FromUri]QueryRoleListReq request)
|
|
{
|
|
return JsonHelper.Instance.Serialize(App.Load(request));
|
|
}
|
|
|
|
[System.Web.Mvc.HttpPost]
|
|
public string Delete(string[] ids)
|
|
{
|
|
try
|
|
{
|
|
App.Delete(ids);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Result.Code = 500;
|
|
Result.Message = e.Message;
|
|
}
|
|
|
|
return JsonHelper.Instance.Serialize(Result);
|
|
}
|
|
}
|
|
} |