mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-21 02:57:54 +08:00
完成机构与用户管理
This commit is contained in:
@@ -1,21 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using OpenAuth.App;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class HomeController : BaseController
|
||||
{
|
||||
private LoginApp _loginApp;
|
||||
|
||||
public HomeController()
|
||||
{
|
||||
_loginApp = (LoginApp)DependencyResolver.Current.GetService(typeof(LoginApp));
|
||||
}
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
@@ -30,11 +18,5 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public string LoadUsers()
|
||||
{
|
||||
return JsonConvert.SerializeObject(_loginApp.LoadUsers());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -33,6 +33,11 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult LookupMulti()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult AddOrg()
|
||||
{
|
||||
return View();
|
||||
@@ -71,7 +76,16 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
public string LoadOrg()
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_orgApp.GetAll());
|
||||
var orgs = _orgApp.GetAll();
|
||||
//添加根节点
|
||||
orgs.Add(new Org
|
||||
{
|
||||
Id = 0,
|
||||
ParentId = -1,
|
||||
Name = "全部机构",
|
||||
CascadeId = "0"
|
||||
});
|
||||
return JsonHelper.Instance.Serialize(orgs);
|
||||
}
|
||||
|
||||
public string LoadChildren(int id)
|
||||
|
@@ -1,18 +1,90 @@
|
||||
using System;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.App.ViewModel;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class UserManagerController : BaseController
|
||||
{
|
||||
private UserManagerApp _app;
|
||||
|
||||
public UserManagerController()
|
||||
{
|
||||
_app = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /UserManager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
public ActionResult Add()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//添加组织提交
|
||||
[HttpPost]
|
||||
public string Add(UserView org)
|
||||
{
|
||||
try
|
||||
{
|
||||
int[] orgIds = org.OrganizationIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||
_app.Add(org, orgIds);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
public string Edit(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
var org = JsonHelper.Instance.Deserialize<User>(json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载组织下面的所有用户
|
||||
/// </summary>
|
||||
public string Load(int orgId)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(orgId));
|
||||
}
|
||||
|
||||
public string Delete(string Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var obj in Id.Split(','))
|
||||
{
|
||||
_app.Delete(int.Parse(obj));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = e.Message;
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user