diff --git a/OpenAuth.App/ModuleManagerApp.cs b/OpenAuth.App/ModuleManagerApp.cs
index cf535e96..a01e67e7 100644
--- a/OpenAuth.App/ModuleManagerApp.cs
+++ b/OpenAuth.App/ModuleManagerApp.cs
@@ -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));
- }
- }
-
///
/// 加载一个部门及子部门全部Modules
///
@@ -61,7 +50,19 @@ namespace OpenAuth.App
return _repository.Find(u => u.ParentId == 0).ToList();
}
-
+ public List LoadByParent(int parentId)
+ {
+ var modules = new List();
+ 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 私有方法
-
}
}
\ No newline at end of file
diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj
index 3b03fa3a..3fea74be 100644
--- a/OpenAuth.App/OpenAuth.App.csproj
+++ b/OpenAuth.App/OpenAuth.App.csproj
@@ -49,6 +49,7 @@
+
diff --git a/OpenAuth.App/ViewModel/ModuleView.cs b/OpenAuth.App/ViewModel/ModuleView.cs
new file mode 100644
index 00000000..8d38504b
--- /dev/null
+++ b/OpenAuth.App/ViewModel/ModuleView.cs
@@ -0,0 +1,55 @@
+using System.Collections.Generic;
+using Infrastructure;
+using OpenAuth.Domain;
+
+namespace OpenAuth.App.ViewModel
+{
+ public class ModuleView
+ {
+ ///
+ /// ID
+ ///
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// 组织名称
+ ///
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 主页面URL
+ ///
+ ///
+ public string Url { get; set; }
+
+ ///
+ /// 父节点流水号
+ ///
+ ///
+ public int ParentId { get; set; }
+
+ ///
+ /// 节点图标文件名称
+ ///
+ ///
+ public string IconName { get; set; }
+
+ ///
+ /// 子节点
+ ///
+ public List Childern = new List();
+
+ public static implicit operator ModuleView(Module module)
+ {
+ return AutoMapperExt.ConvertTo(module);
+ }
+
+ public static implicit operator Module(ModuleView view)
+ {
+ return AutoMapperExt.ConvertTo(view);
+ }
+
+ }
+}
diff --git a/OpenAuth.Mvc/Controllers/HomeController.cs b/OpenAuth.Mvc/Controllers/HomeController.cs
index d1dd5f58..4b8654df 100644
--- a/OpenAuth.Mvc/Controllers/HomeController.cs
+++ b/OpenAuth.Mvc/Controllers/HomeController.cs
@@ -1,12 +1,25 @@
using System.Web.Mvc;
+using Infrastructure;
+using OpenAuth.App;
namespace OpenAuth.Mvc.Controllers
{
public class HomeController : BaseController
{
+ private ModuleManagerApp _app;
+
+ public HomeController()
+ {
+ _app = (ModuleManagerApp)DependencyResolver.Current.GetService(typeof(ModuleManagerApp));
+ }
+
+ public string GetModules(int parentId = 0)
+ {
+ return JsonHelper.Instance.Serialize(_app.LoadByParent(parentId));
+ }
public ActionResult Index()
{
- return View();
+ return View(_app.LoadByParent(0));
}
public ActionResult Main()
diff --git a/OpenAuth.Mvc/Controllers/ModuleManagerController.cs b/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
index 01562f7e..d45c4e9e 100644
--- a/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
+++ b/OpenAuth.Mvc/Controllers/ModuleManagerController.cs
@@ -23,28 +23,6 @@ namespace OpenAuth.Mvc.Controllers
return View();
}
- public ActionResult Add(int id = 0)
- {
- return View(_app.Find(id));
- }
-
- //添加或修改模块
- [HttpPost]
- public string Add(Module model)
- {
- try
- {
- _app.AddOrUpdate(model);
-
- }
- catch (Exception ex)
- {
- BjuiResponse.statusCode = "300";
- BjuiResponse.message = ex.Message;
- }
- return JsonHelper.Instance.Serialize(BjuiResponse);
- }
-
///
/// 加载模块下面的所有模块
///
@@ -64,16 +42,33 @@ namespace OpenAuth.Mvc.Controllers
{
Id = 0,
ParentId = -1,
- Name = "全部模块",
+ Name = "根节点",
CascadeId = "0"
});
return JsonHelper.Instance.Serialize(orgs);
}
- //获取模块下面模块个数
- public int GetCount(int orgId)
+
+ public ActionResult Add(int id = 0)
{
- return _app.GetModuleCntInOrg(orgId);
+ return View(_app.Find(id));
+ }
+
+ //添加或修改模块
+ [HttpPost]
+ public string Add(Module model)
+ {
+ try
+ {
+ _app.AddOrUpdate(model);
+
+ }
+ catch (Exception ex)
+ {
+ BjuiResponse.statusCode = "300";
+ BjuiResponse.message = ex.Message;
+ }
+ return JsonHelper.Instance.Serialize(BjuiResponse);
}
public string Delete(string Id)
diff --git a/OpenAuth.Mvc/Views/Home/Index.cshtml b/OpenAuth.Mvc/Views/Home/Index.cshtml
index 42dda811..7dfd34cb 100644
--- a/OpenAuth.Mvc/Views/Home/Index.cshtml
+++ b/OpenAuth.Mvc/Views/Home/Index.cshtml
@@ -1,4 +1,5 @@
-
+@model List
+
@@ -84,76 +85,70 @@
},
debug: true, // [可选]调试模式 [true|false,默认false]
theme: 'sky' // 若有Cookie['bjui_theme'],优先选择Cookie['bjui_theme']。皮肤[五种皮肤:default, orange, purple, blue, red, green]
- })
+ });
// main - menu
$('#bjui-accordionmenu')
.collapse()
.on('hidden.bs.collapse', function (e) {
$(this).find('> .panel > .panel-heading').each(function () {
- var $heading = $(this), $a = $heading.find('> h4 > a')
-
- if ($a.hasClass('collapsed')) $heading.removeClass('active')
- })
+ var $heading = $(this), $a = $heading.find('> h4 > a');
+ if ($a.hasClass('collapsed')) $heading.removeClass('active');
+ });
})
.on('shown.bs.collapse', function (e) {
$(this).find('> .panel > .panel-heading').each(function () {
- var $heading = $(this), $a = $heading.find('> h4 > a')
-
- if (!$a.hasClass('collapsed')) $heading.addClass('active')
- })
- })
-
+ var $heading = $(this), $a = $heading.find('> h4 > a');
+ if (!$a.hasClass('collapsed')) $heading.addClass('active');
+ });
+ });
$(document).on('click', 'ul.menu-items > li > a', function (e) {
- var $a = $(this), $li = $a.parent(), options = $a.data('options').toObj()
+ var $a = $(this), $li = $a.parent(), options = $a.data('options').toObj();
var onClose = function () {
- $li.removeClass('active')
- }
+ $li.removeClass('active');
+ };
var onSwitch = function () {
- $('#bjui-accordionmenu').find('ul.menu-items > li').removeClass('switch')
- $li.addClass('switch')
- }
-
- $li.addClass('active')
+ $('#bjui-accordionmenu').find('ul.menu-items > li').removeClass('switch');
+ $li.addClass('switch');
+ };
+ $li.addClass('active');
if (options) {
- options.url = $a.attr('href')
- options.onClose = onClose
- options.onSwitch = onSwitch
- if (!options.title) options.title = $a.text()
-
+ options.url = $a.attr('href');
+ options.onClose = onClose;
+ options.onSwitch = onSwitch;
+ if (!options.title) options.title = $a.text();
if (!options.target)
- $a.navtab(options)
+ $a.navtab(options);
else
- $a.dialog(options)
+ $a.dialog(options);
}
- e.preventDefault()
- })
+ e.preventDefault();
+ });
//时钟
- var today = new Date(), time = today.getTime()
- $('#bjui-date').html(today.formatDate('yyyy/MM/dd'))
+ var today = new Date(), time = today.getTime();
+ $('#bjui-date').html(today.formatDate('yyyy/MM/dd'));
setInterval(function () {
- today = new Date(today.setSeconds(today.getSeconds() + 1))
- $('#bjui-clock').html(today.formatDate('HH:mm:ss'))
- }, 1000)
- })
+ today = new Date(today.setSeconds(today.getSeconds() + 1));
+ $('#bjui-clock').html(today.formatDate('HH:mm:ss'));
+ }, 1000);
+
+ });
//菜单-事件
function MainMenuClick(event, treeId, treeNode) {
- event.preventDefault()
-
- if (treeNode.isParent) {
- var zTree = $.fn.zTree.getZTreeObj(treeId)
-
- zTree.expandNode(treeNode, !treeNode.open, false, true, true)
- return
- }
+ event.preventDefault();
+ //if (treeNode.isParent) {
+ // var zTree = $.fn.zTree.getZTreeObj(treeId);
+ // zTree.expandNode(treeNode, !treeNode.open, false, true, true);
+ // return;
+ //}
if (treeNode.target && treeNode.target == 'dialog')
- $(event.target).dialog({ id: treeNode.tabid, url: treeNode.url, title: treeNode.name })
+ $(event.target).dialog({ id: treeNode.tabid, url: treeNode.url, title: treeNode.name });
else
- $(event.target).navtab({ id: treeNode.tabid, url: treeNode.url, title: treeNode.name, fresh: treeNode.fresh, external: treeNode.external })
+ $(event.target).navtab({ id: treeNode.tabid, url: treeNode.url, title: treeNode.name, fresh: treeNode.fresh, external: treeNode.external });
}
@@ -200,19 +195,30 @@
-
应用管理
-
+
+
- - 系统设置
- - 机构管理
- - 用户管理
- - 角色管理
- - 模块管理
+ data-expand-all="true" data-faicon="star-o" data-tit="控制台">
+
+ @foreach (var module in Model)
+ {
+ - @module.Name
+
+ foreach (var child in module.Childern)
+ {
+ - @child.Name
+ }
+
+ }
-
- 系统设置
+
+ 系统设置
+