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

94 lines
2.5 KiB
C#
Raw Normal View History

using System;
2017-02-28 16:51:07 +08:00
using System.Collections.Generic;
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;
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
//添加或修改组织
2015-11-13 21:33:53 +08:00
[HttpPost]
2015-11-15 00:13:49 +08:00
public string Add(UserView view)
2015-11-13 21:33:53 +08:00
{
try
{
App.AddOrUpdate(view);
2015-11-15 00:13:49 +08:00
2015-11-13 21:33:53 +08:00
}
catch (Exception ex)
{
2016-10-14 11:22:16 +08:00
Result.Status = false;
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>
2016-10-17 11:43:56 +08:00
public string Load(Guid orgId, int page = 1, int rows = 30)
2015-11-15 00:13:49 +08:00
{
return JsonHelper.Instance.Serialize(App.Load(orgId, page, rows));
2015-11-15 00:13:49 +08:00
}
2016-10-15 01:27:39 +08:00
[HttpPost]
public string Delete(Guid[] ids)
2015-11-13 21:33:53 +08:00
{
try
{
App.Delete(ids);
2015-11-13 21:33:53 +08:00
}
catch (Exception e)
{
2016-10-14 11:22:16 +08:00
Result.Status = false;
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-08-31 19:54:12 +08:00
IEnumerable<UserView> users = App.Load(Guid.Empty, 1, 10).data;
2017-02-28 16:51:07 +08:00
var result = new Dictionary<string , object>();
foreach (var user in users)
{
var item = new
{
Account = user.Account,
RealName = user.Name,
2017-06-01 00:07:01 +08:00
id = user.Id.ToString(),
text = user.Name,
value = user.Account,
parentId = "0",
showcheck = true,
img = "fa fa-user",
2017-02-28 16:51:07 +08:00
};
result.Add(user.Id.ToString(), item);
}
return JsonHelper.Instance.Serialize(result);
}
#endregion
2015-11-13 21:33:53 +08:00
}
2015-10-26 21:58:12 +08:00
}