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 UserManagerController : BaseController { public UserManagerApp App { get; set; } // // GET: /UserManager/ [Authenticate] public ActionResult Index() { return View(); } //添加或修改组织 [System.Web.Mvc.HttpPost] public string AddOrUpdate(UserView view) { try { App.AddOrUpdate(view); } catch (Exception ex) { Result.Code = 500; Result.Message = ex.Message; } return JsonHelper.Instance.Serialize(Result); } /// /// 加载组织下面的所有用户 /// public string Load([FromUri]QueryUserListReq 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); } #region 获取权限数据 /// /// 获取用户可访问的账号 /// 李玉宝于2017-02-28 15:12:19 /// public string GetAccessedUsers() { IEnumerable users = App.Load(new QueryUserListReq()).data; var result = new Dictionary(); foreach (var user in users) { var item = new { Account = user.Account, RealName = user.Name, id = user.Id, text = user.Name, value = user.Account, parentId = "0", showcheck = true, img = "fa fa-user", }; result.Add(user.Id, item); } return JsonHelper.Instance.Serialize(result); } #endregion } }