OpenAuth.Net/OpenAuth.Mvc/Controllers/UserManagerController.cs

96 lines
2.5 KiB
C#
Raw Normal View History

using System;
2017-02-28 16:51:07 +08:00
using System.Collections.Generic;
2017-10-12 16:38:46 +08:00
using System.Web.Http;
2015-10-26 21:58:12 +08:00
using System.Web.Mvc;
2015-11-15 00:13:49 +08:00
using Infrastructure;
using OpenAuth.App;
2017-10-12 16:38:46 +08:00
using OpenAuth.App.Request;
2015-11-13 21:33:53 +08:00
using OpenAuth.App.ViewModel;
using OpenAuth.Mvc.Models;
2015-10-26 21:58:12 +08:00
namespace OpenAuth.Mvc.Controllers
{
2015-11-08 23:19:04 +08:00
public class UserManagerController : BaseController
2015-10-26 21:58:12 +08:00
{
public UserManagerApp App { get; set; }
2015-11-13 21:33:53 +08:00
2015-10-26 21:58:12 +08:00
//
// GET: /UserManager/
[Authenticate]
2015-10-26 21:58:12 +08:00
public ActionResult Index()
{
return View();
}
2015-11-13 21:33:53 +08:00
2015-11-16 23:18:51 +08:00
//添加或修改组织
2017-10-12 16:38:46 +08:00
[System.Web.Mvc.HttpPost]
public string AddOrUpdate(UserView view)
2015-11-13 21:33:53 +08:00
{
try
{
App.AddOrUpdate(view);
2017-11-29 18:26:36 +08:00
2015-11-13 21:33:53 +08:00
}
catch (Exception ex)
{
2017-11-29 18:26:36 +08:00
Result.Code = 500;
2016-10-14 11:22:16 +08:00
Result.Message = ex.Message;
2015-11-13 21:33:53 +08:00
}
2016-10-14 11:22:16 +08:00
return JsonHelper.Instance.Serialize(Result);
2015-11-13 21:33:53 +08:00
}
/// <summary>
/// 加载组织下面的所有用户
/// </summary>
2017-10-12 16:38:46 +08:00
public string Load([FromUri]QueryUserListReq request)
2015-11-15 00:13:49 +08:00
{
2017-10-12 16:38:46 +08:00
return JsonHelper.Instance.Serialize(App.Load(request));
2015-11-15 00:13:49 +08:00
}
2017-10-12 16:38:46 +08:00
[System.Web.Mvc.HttpPost]
2017-10-11 16:19:34 +08:00
public string Delete(string[] ids)
2015-11-13 21:33:53 +08:00
{
try
{
App.Delete(ids);
2015-11-13 21:33:53 +08:00
}
catch (Exception e)
{
2017-11-29 18:26:36 +08:00
Result.Code = 500;
2016-10-14 11:22:16 +08:00
Result.Message = e.Message;
2015-11-13 21:33:53 +08:00
}
2016-10-14 11:22:16 +08:00
return JsonHelper.Instance.Serialize(Result);
2015-11-13 21:33:53 +08:00
}
2015-11-26 23:09:25 +08:00
2017-02-28 16:51:07 +08:00
#region
/// <summary>
/// 获取用户可访问的账号
/// <para>李玉宝于2017-02-28 15:12:19</para>
/// </summary>
public string GetAccessedUsers()
{
2017-11-29 18:26:36 +08:00
IEnumerable<UserView> users = App.Load(new QueryUserListReq()).data;
var result = new Dictionary<string, object>();
2017-02-28 16:51:07 +08:00
foreach (var user in users)
{
var item = new
{
Account = user.Account,
RealName = user.Name,
2017-10-12 16:38:46 +08:00
id = user.Id,
2017-06-01 00:07:01 +08:00
text = user.Name,
value = user.Account,
parentId = "0",
showcheck = true,
img = "fa fa-user",
2017-02-28 16:51:07 +08:00
};
2017-10-12 16:38:46 +08:00
result.Add(user.Id, item);
2017-02-28 16:51:07 +08:00
}
return JsonHelper.Instance.Serialize(result);
}
#endregion
2015-11-13 21:33:53 +08:00
}
2015-10-26 21:58:12 +08:00
}