2016-01-05 17:14:10 +08:00
|
|
|
|
using System;
|
2017-02-28 16:51:07 +08:00
|
|
|
|
using System.Collections.Generic;
|
2015-11-26 23:09:25 +08:00
|
|
|
|
using System.Linq;
|
2015-10-26 21:58:12 +08:00
|
|
|
|
using System.Web.Mvc;
|
2015-11-15 00:13:49 +08:00
|
|
|
|
using Infrastructure;
|
2017-02-28 16:51:07 +08:00
|
|
|
|
using LeaRun.Util.WebControl;
|
2015-11-15 00:13:49 +08:00
|
|
|
|
using OpenAuth.App;
|
2015-11-13 21:33:53 +08:00
|
|
|
|
using OpenAuth.App.ViewModel;
|
2017-02-28 16:51:07 +08:00
|
|
|
|
using OpenAuth.Domain;
|
2016-05-26 20:10:22 +08:00
|
|
|
|
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
|
|
|
|
{
|
2015-11-13 21:33:53 +08:00
|
|
|
|
private UserManagerApp _app;
|
|
|
|
|
|
|
|
|
|
public UserManagerController()
|
|
|
|
|
{
|
2015-12-16 22:52:23 +08:00
|
|
|
|
_app = AutofacExt.GetFromFac<UserManagerApp>();
|
2015-11-13 21:33:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-26 21:58:12 +08:00
|
|
|
|
//
|
|
|
|
|
// GET: /UserManager/
|
2016-05-26 20:10:22 +08:00
|
|
|
|
[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
|
|
|
|
|
{
|
2015-11-15 00:13:49 +08:00
|
|
|
|
_app.AddOrUpdate(view);
|
|
|
|
|
|
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
|
|
|
|
{
|
2016-10-17 11:43:56 +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
|
|
|
|
|
{
|
2016-10-15 01:27:39 +08:00
|
|
|
|
_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>
|
|
|
|
|
/// 用户列表树
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回树形Json</returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public ActionResult GetUserCheckTreeJson()
|
|
|
|
|
{
|
|
|
|
|
var treeList = new List<TreeEntity>();
|
|
|
|
|
string companyid = "";
|
|
|
|
|
string departmentid = "";
|
|
|
|
|
foreach (UserView item in _app.Load(Guid.Empty, 1, 10).rows)
|
|
|
|
|
{
|
|
|
|
|
TreeEntity tree = new TreeEntity();
|
|
|
|
|
|
|
|
|
|
tree.id = item.Id.ToString();
|
|
|
|
|
tree.text = item.Name;
|
|
|
|
|
tree.value = item.Id.ToString();
|
|
|
|
|
tree.isexpand = true;
|
|
|
|
|
tree.complete = true;
|
|
|
|
|
tree.hasChildren = false;
|
|
|
|
|
tree.parentId = "0";
|
|
|
|
|
tree.showcheck = true;
|
|
|
|
|
tree.img = "fa fa-user";
|
|
|
|
|
tree.Attribute = "mytype";
|
|
|
|
|
tree.AttributeValue = "User";
|
|
|
|
|
treeList.Add(tree);
|
|
|
|
|
}
|
|
|
|
|
return Content(treeList.TreeToJson());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取用户可访问的账号
|
|
|
|
|
/// <para>李玉宝于2017-02-28 15:12:19</para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string GetAccessedUsers()
|
|
|
|
|
{
|
|
|
|
|
IEnumerable<UserView> users = _app.Load(Guid.Empty, 1, 10).rows;
|
|
|
|
|
var result = new Dictionary<string , object>();
|
|
|
|
|
foreach (var user in users)
|
|
|
|
|
{
|
|
|
|
|
var item = new
|
|
|
|
|
{
|
|
|
|
|
Account = user.Account,
|
|
|
|
|
RealName = user.Name,
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
}
|