From 104866d83bcf2a73fcc49752e6efe6ecc2df2e26 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Thu, 29 Oct 2015 23:51:10 +0800 Subject: [PATCH] Routine Update --- OpenAuth.App/OrgManagerApp.cs | 16 +++ .../Controllers/OrgManagerController.cs | 16 +-- OpenAuth.Mvc/Views/OrgManager/Index.cshtml | 103 +++++++++--------- OpenAuth.Repository/App.config | 7 ++ 4 files changed, 83 insertions(+), 59 deletions(-) create mode 100644 OpenAuth.Repository/App.config diff --git a/OpenAuth.App/OrgManagerApp.cs b/OpenAuth.App/OrgManagerApp.cs index eb6dd67b..45a24137 100644 --- a/OpenAuth.App/OrgManagerApp.cs +++ b/OpenAuth.App/OrgManagerApp.cs @@ -21,6 +21,12 @@ namespace OpenAuth.App return _repository.LoadOrgs(); } + /// + /// 添加部门 + /// + /// The org. + /// System.Int32. + /// 未能找到该组织的父节点信息 public int AddOrg(Org org) { string cascadeId; @@ -61,5 +67,15 @@ namespace OpenAuth.App _repository.Save(); return org.Id; } + + /// + /// 部门的直接子部门 + /// + /// The org unique identifier. + /// IEnumerable{Org}. + public IEnumerable LoadChildren(int orgId) + { + return _repository.Find(u => u.ParentId == orgId); + } } } diff --git a/OpenAuth.Mvc/Controllers/OrgManagerController.cs b/OpenAuth.Mvc/Controllers/OrgManagerController.cs index 8d097171..6a12e3f1 100644 --- a/OpenAuth.Mvc/Controllers/OrgManagerController.cs +++ b/OpenAuth.Mvc/Controllers/OrgManagerController.cs @@ -5,6 +5,7 @@ using System.Web; using System.Web.Mvc; using Infrastructure; using OpenAuth.App; +using OpenAuth.Domain; namespace OpenAuth.Mvc.Controllers { @@ -26,19 +27,14 @@ namespace OpenAuth.Mvc.Controllers public string LoadOrg() { - var orgs = _orgApp.GetAll(); - return JsonHelper.Instance.Serialize(orgs); + return JsonHelper.Instance.Serialize(_orgApp.GetAll()); } - public JsonResult LoadTree() + public string LoadChildren(int id) { - return Json(_orgApp.GetAll().Select(o =>new - { - id = o.Id, - pId = o.ParentId, - name = o.Name, - text = o.Name - }), JsonRequestBehavior.AllowGet); + return JsonHelper.Instance.Serialize(_orgApp.LoadChildren(id)); } + + } } \ No newline at end of file diff --git a/OpenAuth.Mvc/Views/OrgManager/Index.cshtml b/OpenAuth.Mvc/Views/OrgManager/Index.cshtml index 9803ec92..ebb60a71 100644 --- a/OpenAuth.Mvc/Views/OrgManager/Index.cshtml +++ b/OpenAuth.Mvc/Views/OrgManager/Index.cshtml @@ -11,10 +11,6 @@ \ No newline at end of file diff --git a/OpenAuth.Repository/App.config b/OpenAuth.Repository/App.config new file mode 100644 index 00000000..b1300dd5 --- /dev/null +++ b/OpenAuth.Repository/App.config @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file