mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
Routine Update
This commit is contained in:
parent
e2f7e2cf42
commit
3170191db6
@ -20,6 +20,35 @@ namespace OpenAuth.App
|
||||
return _repository.LoadOrgs();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 部门的直接子部门
|
||||
/// <para>TODO:可以根据用户的喜好决定选择LoadAllChildren或LoadDirectChildren</para>
|
||||
/// </summary>
|
||||
/// <param name="orgId">The org unique identifier.</param>
|
||||
/// <returns>IEnumerable{Org}.</returns>
|
||||
public IEnumerable<Org> LoadDirectChildren(int orgId)
|
||||
{
|
||||
return _repository.Find(u => u.ParentId == orgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到部门的所有子部门
|
||||
/// <para>如果orgId为0,表示取得所有部门</para>
|
||||
/// </summary>
|
||||
public IEnumerable<Org> LoadAllChildren(int orgId)
|
||||
{
|
||||
string cascadeId = "0.";
|
||||
if (orgId != 0)
|
||||
{
|
||||
var org = _repository.FindSingle(u => u.Id == orgId);
|
||||
if (org == null)
|
||||
throw new Exception("未能找到指定对象信息");
|
||||
cascadeId = org.CascadeId;
|
||||
}
|
||||
|
||||
return _repository.Find(u => u.CascadeId.Contains(cascadeId) && u.Id != orgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加部门
|
||||
/// </summary>
|
||||
@ -57,33 +86,9 @@ namespace OpenAuth.App
|
||||
return org.Id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 部门的直接子部门
|
||||
/// <para>TODO:可以根据用户的喜好决定选择LoadAllChildren或LoadDirectChildren</para>
|
||||
/// </summary>
|
||||
/// <param name="orgId">The org unique identifier.</param>
|
||||
/// <returns>IEnumerable{Org}.</returns>
|
||||
public IEnumerable<Org> LoadDirectChildren(int orgId)
|
||||
public void ModifyOrg(Org org)
|
||||
{
|
||||
return _repository.Find(u => u.ParentId == orgId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到部门的所有子部门
|
||||
/// <para>如果orgId为0,表示取得所有部门</para>
|
||||
/// </summary>
|
||||
public IEnumerable<Org> LoadAllChildren(int orgId)
|
||||
{
|
||||
string cascadeId = "0.";
|
||||
if (orgId != 0)
|
||||
{
|
||||
var org = _repository.FindSingle(u => u.Id == orgId);
|
||||
if (org == null)
|
||||
throw new Exception("未能找到指定对象信息");
|
||||
cascadeId = org.CascadeId;
|
||||
}
|
||||
|
||||
return _repository.Find(u => u.CascadeId.Contains(cascadeId) && u.Id != orgId);
|
||||
_repository.Update(u =>u.Id == org.Id,org);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -116,4 +121,4 @@ namespace OpenAuth.App
|
||||
|
||||
#endregion 私有方法
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Mvc.Models;
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class OrgManagerController : BaseController
|
||||
{
|
||||
private OrgManagerApp _orgApp;
|
||||
public class OrgManagerController : BaseController
|
||||
{
|
||||
private OrgManagerApp _orgApp;
|
||||
private BjuiResponse _bjuiResponse = new BjuiResponse();
|
||||
|
||||
public OrgManagerController()
|
||||
{
|
||||
_orgApp = (OrgManagerApp) DependencyResolver.Current.GetService(typeof (OrgManagerApp));
|
||||
}
|
||||
//
|
||||
// GET: /OrgManager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public OrgManagerController()
|
||||
{
|
||||
_orgApp = (OrgManagerApp)DependencyResolver.Current.GetService(typeof(OrgManagerApp));
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /OrgManager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择上级机构页面
|
||||
/// </summary>
|
||||
/// <returns>ActionResult.</returns>
|
||||
public ActionResult LookupParent()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public ActionResult LookupParent()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
public ActionResult AddOrg()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public ActionResult AddOrg()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//添加组织提交
|
||||
[HttpPost]
|
||||
public string AddOrg(Org org)
|
||||
public string AddOrg(Org org)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -55,19 +52,32 @@ namespace OpenAuth.Mvc.Controllers
|
||||
_bjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
||||
|
||||
}
|
||||
|
||||
public string EditOrg(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
var org = JsonHelper.Instance.Deserialize<Org>(json);
|
||||
_orgApp.ModifyOrg(org);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_bjuiResponse.statusCode = "300";
|
||||
_bjuiResponse.message = ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
||||
}
|
||||
|
||||
public string LoadOrg()
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_orgApp.GetAll());
|
||||
}
|
||||
public string LoadOrg()
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_orgApp.GetAll());
|
||||
}
|
||||
|
||||
public string LoadChildren(int id)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_orgApp.LoadAllChildren(id));
|
||||
}
|
||||
public string LoadChildren(int id)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_orgApp.LoadAllChildren(id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除指定ID的组织
|
||||
@ -78,7 +88,6 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
foreach (var obj in Id.Split(','))
|
||||
{
|
||||
_orgApp.DelOrg(int.Parse(obj));
|
||||
@ -91,7 +100,6 @@ namespace OpenAuth.Mvc.Controllers
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
$('#mainGrid').datagrid({
|
||||
gridTitle: '机构列表显示',
|
||||
showToolbar: true,
|
||||
toolbarItem: 'refresh, |, del',
|
||||
toolbarItem: 'refresh, |, del,edit',
|
||||
toolbarCustom: '<a href="/OrgManager/AddOrg" class="btn btn-green" data-icon ="plus" ' +
|
||||
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' +
|
||||
'<button class=" btn-green" onclick="editOrg()" data-icon="pencil" type="button">编辑</button>',
|
||||
@ -31,16 +31,19 @@
|
||||
{
|
||||
name: 'Id',
|
||||
label: 'Id',
|
||||
attrs: { readonly: 'readonly' },
|
||||
hide: true
|
||||
},
|
||||
{
|
||||
name: 'ParentId',
|
||||
label: '上级机构ID',
|
||||
attrs: { readonly: 'readonly'},
|
||||
hide: true
|
||||
},
|
||||
{
|
||||
name: 'CascadeId',
|
||||
label: '唯一标识'
|
||||
label: '唯一标识',
|
||||
attrs: { readonly: 'readonly'}
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
@ -48,7 +51,9 @@
|
||||
},
|
||||
{
|
||||
name: 'ParentName',
|
||||
label: '上级机构'
|
||||
label: '上级机构',
|
||||
edit: false,
|
||||
attrs: { readonly: 'readonly' }
|
||||
},
|
||||
{
|
||||
name: 'Status',
|
||||
@ -65,7 +70,6 @@
|
||||
}
|
||||
],
|
||||
data: data,
|
||||
addUrl: 'OrgManager/AddOrg',
|
||||
delUrl: 'OrgManager/DelOrg',
|
||||
delPK: "Id",
|
||||
editUrl: 'OrgManager/EditOrg',
|
||||
@ -82,6 +86,13 @@
|
||||
else {
|
||||
$(this).alertmsg('warn', delResult.message);
|
||||
}
|
||||
},
|
||||
editCallback: function (delResult) {
|
||||
if (delResult.statusCode == "200")
|
||||
Init(selectedId);
|
||||
else {
|
||||
$(this).alertmsg('warn', delResult.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user