完成导航动态加载

This commit is contained in:
yubaolee
2015-11-22 21:32:38 +08:00
parent cd31e8791d
commit 2793d20ef4
8 changed files with 177 additions and 98 deletions

View File

@@ -4,6 +4,7 @@ using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.App.ViewModel;
namespace OpenAuth.App
{
@@ -16,18 +17,6 @@ namespace OpenAuth.App
_repository = repository;
}
public int GetModuleCntInOrg(int orgId)
{
if (orgId == 0)
{
return _repository.Find(null).Count();
}
else
{
return _repository.GetModuleCntInOrgs(GetSubOrgIds(orgId));
}
}
/// <summary>
/// 加载一个部门及子部门全部Modules
/// </summary>
@@ -61,7 +50,19 @@ namespace OpenAuth.App
return _repository.Find(u => u.ParentId == 0).ToList();
}
public List<ModuleView> LoadByParent(int parentId)
{
var modules = new List<ModuleView>();
var roots = _repository.Find(u => u.ParentId == parentId);
foreach (var module in roots)
{
ModuleView mv = module;
mv.Childern = LoadByParent(module.Id);
modules.Add(mv);
}
return modules;
}
public Module Find(int id)
{
@@ -141,6 +142,5 @@ namespace OpenAuth.App
#endregion
}
}