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();
|
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>
|
||||||
/// 添加部门
|
/// 添加部门
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,33 +86,9 @@ namespace OpenAuth.App
|
|||||||
return org.Id;
|
return org.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
public void ModifyOrg(Org org)
|
||||||
/// 部门的直接子部门
|
|
||||||
/// <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);
|
_repository.Update(u =>u.Id == org.Id,org);
|
||||||
}
|
|
||||||
|
|
||||||
/// <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>
|
||||||
@ -116,4 +121,4 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
#endregion 私有方法
|
#endregion 私有方法
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,49 +1,46 @@
|
|||||||
using System;
|
using Infrastructure;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Web;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using Infrastructure;
|
|
||||||
using OpenAuth.App;
|
using OpenAuth.App;
|
||||||
using OpenAuth.Domain;
|
using OpenAuth.Domain;
|
||||||
using OpenAuth.Mvc.Models;
|
using OpenAuth.Mvc.Models;
|
||||||
|
using System;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
namespace OpenAuth.Mvc.Controllers
|
||||||
{
|
{
|
||||||
public class OrgManagerController : BaseController
|
public class OrgManagerController : BaseController
|
||||||
{
|
{
|
||||||
private OrgManagerApp _orgApp;
|
private OrgManagerApp _orgApp;
|
||||||
private BjuiResponse _bjuiResponse = new BjuiResponse();
|
private BjuiResponse _bjuiResponse = new BjuiResponse();
|
||||||
|
|
||||||
public OrgManagerController()
|
public OrgManagerController()
|
||||||
{
|
{
|
||||||
_orgApp = (OrgManagerApp) DependencyResolver.Current.GetService(typeof (OrgManagerApp));
|
_orgApp = (OrgManagerApp)DependencyResolver.Current.GetService(typeof(OrgManagerApp));
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// GET: /OrgManager/
|
//
|
||||||
public ActionResult Index()
|
// GET: /OrgManager/
|
||||||
{
|
public ActionResult Index()
|
||||||
return View();
|
{
|
||||||
}
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 选择上级机构页面
|
/// 选择上级机构页面
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>ActionResult.</returns>
|
/// <returns>ActionResult.</returns>
|
||||||
public ActionResult LookupParent()
|
public ActionResult LookupParent()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult AddOrg()
|
||||||
public ActionResult AddOrg()
|
{
|
||||||
{
|
return View();
|
||||||
return View();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//添加组织提交
|
//添加组织提交
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public string AddOrg(Org org)
|
public string AddOrg(Org org)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -55,19 +52,32 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
_bjuiResponse.message = ex.Message;
|
_bjuiResponse.message = ex.Message;
|
||||||
}
|
}
|
||||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
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()
|
public string LoadOrg()
|
||||||
{
|
{
|
||||||
return JsonHelper.Instance.Serialize(_orgApp.GetAll());
|
return JsonHelper.Instance.Serialize(_orgApp.GetAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LoadChildren(int id)
|
public string LoadChildren(int id)
|
||||||
{
|
{
|
||||||
return JsonHelper.Instance.Serialize(_orgApp.LoadAllChildren(id));
|
return JsonHelper.Instance.Serialize(_orgApp.LoadAllChildren(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除指定ID的组织
|
/// 删除指定ID的组织
|
||||||
@ -78,7 +88,6 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (var obj in Id.Split(','))
|
foreach (var obj in Id.Split(','))
|
||||||
{
|
{
|
||||||
_orgApp.DelOrg(int.Parse(obj));
|
_orgApp.DelOrg(int.Parse(obj));
|
||||||
@ -91,7 +100,6 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,7 +23,7 @@
|
|||||||
$('#mainGrid').datagrid({
|
$('#mainGrid').datagrid({
|
||||||
gridTitle: '机构列表显示',
|
gridTitle: '机构列表显示',
|
||||||
showToolbar: true,
|
showToolbar: true,
|
||||||
toolbarItem: 'refresh, |, del',
|
toolbarItem: 'refresh, |, del,edit',
|
||||||
toolbarCustom: '<a href="/OrgManager/AddOrg" class="btn btn-green" data-icon ="plus" ' +
|
toolbarCustom: '<a href="/OrgManager/AddOrg" class="btn btn-green" data-icon ="plus" ' +
|
||||||
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' +
|
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' +
|
||||||
'<button class=" btn-green" onclick="editOrg()" data-icon="pencil" type="button">编辑</button>',
|
'<button class=" btn-green" onclick="editOrg()" data-icon="pencil" type="button">编辑</button>',
|
||||||
@ -31,16 +31,19 @@
|
|||||||
{
|
{
|
||||||
name: 'Id',
|
name: 'Id',
|
||||||
label: 'Id',
|
label: 'Id',
|
||||||
|
attrs: { readonly: 'readonly' },
|
||||||
hide: true
|
hide: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ParentId',
|
name: 'ParentId',
|
||||||
label: '上级机构ID',
|
label: '上级机构ID',
|
||||||
|
attrs: { readonly: 'readonly'},
|
||||||
hide: true
|
hide: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'CascadeId',
|
name: 'CascadeId',
|
||||||
label: '唯一标识'
|
label: '唯一标识',
|
||||||
|
attrs: { readonly: 'readonly'}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Name',
|
name: 'Name',
|
||||||
@ -48,7 +51,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ParentName',
|
name: 'ParentName',
|
||||||
label: '上级机构'
|
label: '上级机构',
|
||||||
|
edit: false,
|
||||||
|
attrs: { readonly: 'readonly' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Status',
|
name: 'Status',
|
||||||
@ -65,7 +70,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
data: data,
|
data: data,
|
||||||
addUrl: 'OrgManager/AddOrg',
|
|
||||||
delUrl: 'OrgManager/DelOrg',
|
delUrl: 'OrgManager/DelOrg',
|
||||||
delPK: "Id",
|
delPK: "Id",
|
||||||
editUrl: 'OrgManager/EditOrg',
|
editUrl: 'OrgManager/EditOrg',
|
||||||
@ -82,6 +86,13 @@
|
|||||||
else {
|
else {
|
||||||
$(this).alertmsg('warn', delResult.message);
|
$(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