mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-12-26 22:25:39 +08:00
完成导航动态加载
This commit is contained in:
@@ -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 私有方法
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,7 @@
|
||||
<Compile Include="UserManagerApp.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="OrgManagerApp.cs" />
|
||||
<Compile Include="ViewModel\ModuleView.cs" />
|
||||
<Compile Include="ViewModel\UserView.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
55
OpenAuth.App/ViewModel/ModuleView.cs
Normal file
55
OpenAuth.App/ViewModel/ModuleView.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using Infrastructure;
|
||||
using OpenAuth.Domain;
|
||||
|
||||
namespace OpenAuth.App.ViewModel
|
||||
{
|
||||
public class ModuleView
|
||||
{
|
||||
/// <summary>
|
||||
/// ID
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组织名称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 主页面URL
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父节点流水号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点图标文件名称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string IconName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子节点
|
||||
/// </summary>
|
||||
public List<ModuleView> Childern = new List<ModuleView>();
|
||||
|
||||
public static implicit operator ModuleView(Module module)
|
||||
{
|
||||
return AutoMapperExt.ConvertTo<Module, ModuleView>(module);
|
||||
}
|
||||
|
||||
public static implicit operator Module(ModuleView view)
|
||||
{
|
||||
return AutoMapperExt.ConvertTo<ModuleView, Module>(view);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user