mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-23 13:06:48 +08:00
增加Module模块
This commit is contained in:
parent
ea30b32af7
commit
12bd4591bb
99
OpenAuth.App/ModuleManagerApp.cs
Normal file
99
OpenAuth.App/ModuleManagerApp.cs
Normal file
@ -0,0 +1,99 @@
|
||||
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class ModuleManagerApp
|
||||
{
|
||||
private IModuleRepository _repository;
|
||||
private IOrgRepository _orgRepository;
|
||||
|
||||
public ModuleManagerApp(IModuleRepository repository,
|
||||
IOrgRepository orgRepository)
|
||||
{
|
||||
_repository = repository;
|
||||
_orgRepository = orgRepository;
|
||||
}
|
||||
|
||||
public int GetModuleCntInOrg(int orgId)
|
||||
{
|
||||
if (orgId == 0)
|
||||
{
|
||||
return _repository.Find(null).Count();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _repository.GetModuleCntInOrgs(GetSubOrgIds(orgId));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载一个部门及子部门全部Modules
|
||||
/// </summary>
|
||||
public dynamic Load(int orgId, int pageindex, int pagesize)
|
||||
{
|
||||
IEnumerable<Module> Modules;
|
||||
int total = 0;
|
||||
if (orgId == 0)
|
||||
{
|
||||
Modules = _repository.LoadModules(pageindex, pagesize);
|
||||
total = _repository.GetCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
Modules = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId));
|
||||
total = _repository.GetModuleCntInOrgs(orgId);
|
||||
}
|
||||
|
||||
return new
|
||||
{
|
||||
total = total,
|
||||
list = Modules,
|
||||
pageCurrent = pageindex
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前组织的所有下级组织
|
||||
/// </summary>
|
||||
private int[] GetSubOrgIds(int orgId)
|
||||
{
|
||||
var org = _orgRepository.FindSingle(u => u.Id == orgId);
|
||||
var orgs = _orgRepository.Find(u => u.CascadeId.Contains(org.CascadeId)).Select(u => u.Id).ToArray();
|
||||
return orgs;
|
||||
}
|
||||
|
||||
public Module Find(int id)
|
||||
{
|
||||
var module = _repository.FindSingle(u => u.Id == id);
|
||||
if (module == null) return new Module();
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
_repository.Delete(id);
|
||||
}
|
||||
|
||||
public void AddOrUpdate(Module model)
|
||||
{
|
||||
Module module = model;
|
||||
if (module.Id == 0)
|
||||
{
|
||||
_repository.Add(module);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.Update(module);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LoginApp.cs" />
|
||||
<Compile Include="ModuleManagerApp.cs" />
|
||||
<Compile Include="RoleManagerApp.cs" />
|
||||
<Compile Include="UserManagerApp.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
18
OpenAuth.Domain/Interface/IModuleRepository.cs
Normal file
18
OpenAuth.Domain/Interface/IModuleRepository.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenAuth.Domain.Interface
|
||||
{
|
||||
public interface IModuleRepository :IRepository<Module>
|
||||
{
|
||||
IEnumerable<Module> LoadModules(int pageindex, int pagesize);
|
||||
|
||||
IEnumerable<Module> LoadInOrgs(params int[] orgId);
|
||||
int GetModuleCntInOrgs(params int[] orgIds);
|
||||
IEnumerable<Module> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds);
|
||||
|
||||
|
||||
void Delete(int id);
|
||||
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Interface\IModuleRepository.cs" />
|
||||
<Compile Include="Interface\IOrgRepository.cs" />
|
||||
<Compile Include="Interface\IRepository.cs" />
|
||||
<Compile Include="Interface\IRoleRepository.cs" />
|
||||
|
@ -32,6 +32,7 @@ namespace OpenAuth.Mvc
|
||||
builder.RegisterType<OrgManagerApp>();
|
||||
builder.RegisterType<UserManagerApp>();
|
||||
builder.RegisterType<RoleManagerApp>();
|
||||
builder.RegisterType<ModuleManagerApp>();
|
||||
// Register your MVC controllers.
|
||||
builder.RegisterControllers(typeof(MvcApplication).Assembly);
|
||||
|
||||
|
@ -1,18 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class ModuleManagerController : BaseController
|
||||
{
|
||||
private ModuleManagerApp _app;
|
||||
|
||||
public ModuleManagerController()
|
||||
{
|
||||
_app = (ModuleManagerApp)DependencyResolver.Current.GetService(typeof(ModuleManagerApp));
|
||||
}
|
||||
|
||||
//
|
||||
// GET: /Modu/
|
||||
// GET: /ModuleManager/
|
||||
public ActionResult Index()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载组织下面的所有用户
|
||||
/// </summary>
|
||||
public string Load(int orgId, int pageCurrent = 1, int pageSize = 30)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.Load(orgId, pageCurrent, pageSize));
|
||||
}
|
||||
|
||||
//获取组织下面用户个数
|
||||
public int GetCount(int orgId)
|
||||
{
|
||||
return _app.GetModuleCntInOrg(orgId);
|
||||
}
|
||||
|
||||
public string Delete(string Id)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var obj in Id.Split(','))
|
||||
{
|
||||
_app.Delete(int.Parse(obj));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = e.Message;
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
}
|
||||
}
|
@ -126,6 +126,7 @@
|
||||
<Compile Include="AutofacExt.cs" />
|
||||
<Compile Include="Controllers\BaseController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\ModuleManagerController.cs" />
|
||||
<Compile Include="Controllers\OrgManagerController.cs" />
|
||||
<Compile Include="Controllers\RoleManagerController.cs" />
|
||||
<Compile Include="Controllers\UserManagerController.cs" />
|
||||
@ -614,6 +615,8 @@
|
||||
<Content Include="Views\Home\Main.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\ModuleManager\Index.cshtml" />
|
||||
<Content Include="Views\ModuleManager\Add.cshtml" />
|
||||
<None Include="Views\OrgManager\AddOrg.cshtml" />
|
||||
<Content Include="Views\OrgManager\LookupParent.cshtml" />
|
||||
<Content Include="Views\UserManager\Index.cshtml" />
|
||||
|
@ -207,6 +207,7 @@
|
||||
<li data-id="100" data-pid="99" data-url="OrgManager/Index" data-tabid="orgManager" data-faicon="caret-right">机构管理</li>
|
||||
<li data-id="101" data-pid="99" data-url="UserManager/Index" data-tabid="userManager" data-faicon="caret-right">用户管理</li>
|
||||
<li data-id="102" data-pid="99" data-url="RoleManager/Index" data-tabid="roleManager" data-faicon="caret-right">角色管理</li>
|
||||
<li data-id="103" data-pid="99" data-url="ModuleManager/Index" data-tabid="moduleManager" data-faicon="caret-right">模块管理</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
217
OpenAuth.Mvc/Views/ModuleManager/Add.cshtml
Normal file
217
OpenAuth.Mvc/Views/ModuleManager/Add.cshtml
Normal file
@ -0,0 +1,217 @@
|
||||
|
||||
@model OpenAuth.App.ViewModel.Module
|
||||
@{
|
||||
ViewBag.Title = "title";
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
<div class="bjui-pageContent">
|
||||
<form action="/ModuleManager/Add" class="pageForm" data-toggle="validate">
|
||||
<table class="table table-condensed table-hover">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="center"><h3>* 添加</h3></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.HiddenFor(m =>m.Id)
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="CascadeId" class="control-label x90">节点语义ID:</label>
|
||||
<input type="text" name="CascadeId" id="CascadeId" value="@Model.CascadeId"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="Name" class="control-label x90">功能模块名称:</label>
|
||||
<input type="text" name="Name" id="Name" value="@Model.Name"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="Url" class="control-label x90">主页面URL:</label>
|
||||
<input type="text" name="Url" id="Url" value="@Model.Url"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="HotKey" class="control-label x90">热键:</label>
|
||||
<input type="text" name="HotKey" id="HotKey" value="@Model.HotKey"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="ParentId" class="control-label x90">父节点流水号:</label>
|
||||
<input type="text" name="ParentId" id="ParentId" value="@Model.ParentId"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<label for="IsLeaf" class="control-label x85">是否叶子节点:</label>
|
||||
|
||||
<select name="IsLeaf" id="IsLeaf" data-toggle="selectpicker" data-rule="required">
|
||||
<option value="0" @if (Model.IsLeaf == 0) { <text> selected="selected" </text> }>否</option>
|
||||
<option value="1" @if (Model.IsLeaf == 1) { <text> selected="selected" </text> }>是</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<label for="IsAutoExpand" class="control-label x85">是否自动展开:</label>
|
||||
|
||||
<select name="IsAutoExpand" id="IsAutoExpand" data-toggle="selectpicker" data-rule="required">
|
||||
<option value="0" @if (Model.IsAutoExpand == 0) { <text> selected="selected" </text> }>否</option>
|
||||
<option value="1" @if (Model.IsAutoExpand == 1) { <text> selected="selected" </text> }>是</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="IconName" class="control-label x90">节点图标文件名称:</label>
|
||||
<input type="text" name="IconName" id="IconName" value="@Model.IconName"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="Status" class="control-label x90">当前状态:</label>
|
||||
<input type="text" name="Status" id="Status" value="@Model.Status"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="ParentName" class="control-label x90">父节点名称:</label>
|
||||
<input type="text" name="ParentName" id="ParentName" value="@Model.ParentName"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="Vector" class="control-label x90">矢量图标:</label>
|
||||
<input type="text" name="Vector" id="Vector" value="@Model.Vector"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
|
||||
<label for="SortNo" class="control-label x90">排序号:</label>
|
||||
<input type="text" name="SortNo" id="SortNo" value="@Model.SortNo"
|
||||
data-rule="required" size="20">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Organizations" class="control-label x90">所属机构:</label>
|
||||
<input id="OrganizationIds" name="OrganizationIds" value="@Model.OrganizationIds" style="display: none" />
|
||||
<input type="text" name="Organizations" id="Organizations"
|
||||
data-toggle="selectztree" size="20" data-tree="#j_select_tree1" value="@Model.Organizations">
|
||||
<ul id="j_select_tree1" class="ztree hide" data-toggle="ztree" >
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div class="bjui-pageFooter">
|
||||
<ul>
|
||||
<li><button type="button" class="btn-close">关闭</button></li>
|
||||
<li><button type="submit" class="btn-green">保存</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
Init();
|
||||
});
|
||||
function Init() {
|
||||
var setting = {
|
||||
view: {
|
||||
selectedMulti: false
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox",
|
||||
chkboxType: { "Y": "", "N": "" } //去掉勾选时级联
|
||||
},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: zTreeOnClick,
|
||||
onCheck: zTreeCheck
|
||||
}
|
||||
};
|
||||
$.getJSON('OrgManager/LoadOrg', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
function zTreeCheck(e, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
||||
nodes = zTree.getCheckedNodes(true);
|
||||
var ids = '', names = '';
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
ids += ',' + nodes[i].Id;
|
||||
names += ',' + nodes[i].Name;
|
||||
}
|
||||
if (ids.length > 0) { //去掉第一个逗号
|
||||
ids = ids.substr(1);
|
||||
names = names.substr(1);
|
||||
}
|
||||
|
||||
var $from = $('#' + treeId).data('fromObj');
|
||||
if ($from && $from.length) $from.val(names);
|
||||
|
||||
$('#OrganizationIds').val(ids);
|
||||
}
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
195
OpenAuth.Mvc/Views/ModuleManager/Index.cshtml
Normal file
195
OpenAuth.Mvc/Views/ModuleManager/Index.cshtml
Normal file
@ -0,0 +1,195 @@
|
||||
@{
|
||||
string _prefix = "Module";
|
||||
var _treeId = _prefix + "Tree";
|
||||
var _gridId = _prefix + "Grid";
|
||||
var _treeDetail = _prefix + "Detail";
|
||||
}
|
||||
<div class="bjui-pageContent">
|
||||
<div class="clearfix">
|
||||
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
||||
<ul id="@_treeId" class="ztree"></ul>
|
||||
</div>
|
||||
|
||||
<div id="@_treeDetail" style="margin-left: 225px;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var gridid = '#@_gridId';
|
||||
var selectedId = 0;
|
||||
$(document).ready(function () {
|
||||
initZtree();
|
||||
loadDataGrid();
|
||||
});
|
||||
//加载数据到datagrid
|
||||
function loadDataGrid() {
|
||||
//b-jui的datagrid需要重新处理HTML
|
||||
$('#@_treeDetail').empty()
|
||||
.append('<table id="@_gridId" class="table table-bordered"></table>');
|
||||
|
||||
$(gridid).datagrid({
|
||||
gridTitle: '列表',
|
||||
showToolbar: true,
|
||||
filterThead: false,
|
||||
toolbarItem: 'refresh, |, del',
|
||||
toolbarCustom: '<a href="/ModuleManager/Add" class="btn btn-green" data-icon ="plus" ' +
|
||||
'data-toggle="dialog" data-id="dialog-mask" data-mask="true" data-on-close="refreshGrid">添加</a>' +
|
||||
'<button class=" btn-green" onclick="editModule()" data-icon="pencil" type="button">编辑</button>',
|
||||
columns: [
|
||||
{
|
||||
name: 'Id',
|
||||
label: '功能模块流水号'
|
||||
, hide: true
|
||||
},
|
||||
{
|
||||
name: 'CascadeId',
|
||||
label: '节点语义ID'
|
||||
},
|
||||
{
|
||||
name: 'Name',
|
||||
label: '功能模块名称'
|
||||
},
|
||||
{
|
||||
name: 'Url',
|
||||
label: '主页面URL'
|
||||
},
|
||||
{
|
||||
name: 'HotKey',
|
||||
label: '热键'
|
||||
},
|
||||
{
|
||||
name: 'ParentId',
|
||||
label: '父节点流水号'
|
||||
},
|
||||
{
|
||||
name: 'IsLeaf',
|
||||
label: '是否叶子节点'
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
items: [{ '0': '否' }, { '1': '是' }]
|
||||
},
|
||||
{
|
||||
name: 'IsAutoExpand',
|
||||
label: '是否自动展开'
|
||||
,type: 'select',
|
||||
align: 'center',
|
||||
width: 80,
|
||||
items: [{ '0': '否' }, { '1': '是' }]
|
||||
},
|
||||
{
|
||||
name: 'IconName',
|
||||
label: '节点图标文件名称'
|
||||
},
|
||||
{
|
||||
name: 'Status',
|
||||
label: '当前状态'
|
||||
},
|
||||
{
|
||||
name: 'ParentName',
|
||||
label: '父节点名称'
|
||||
},
|
||||
{
|
||||
name: 'Vector',
|
||||
label: '矢量图标'
|
||||
},
|
||||
{
|
||||
name: 'SortNo',
|
||||
label: '排序号'
|
||||
},
|
||||
],
|
||||
dataUrl: 'ModuleManager/Load?orgId=' + selectedId,
|
||||
delUrl: 'Module/Delete',
|
||||
delPK: "Id",
|
||||
fullGrid: true,
|
||||
showLinenumber: true,
|
||||
showCheckboxcol: true,
|
||||
paging: true,
|
||||
filterMult: false,
|
||||
showTfoot: true,
|
||||
height: '700',
|
||||
delCallback: function (delResult) {
|
||||
if (delResult.statusCode == "200")
|
||||
loadDataGrid();
|
||||
else {
|
||||
$(this).alertmsg('warn', delResult.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function zTreeOnClick(event, treeId, treeNode) {
|
||||
selectedId = treeNode.Id;
|
||||
loadDataGrid();
|
||||
}
|
||||
|
||||
function initZtree() {
|
||||
var setting = {
|
||||
view: {selectedMulti: false},
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {onClick: zTreeOnClick}
|
||||
};
|
||||
$.getJSON('OrgManager/LoadOrg', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
//获取勾选的值
|
||||
//column:为从0开始的列标识
|
||||
function getSelected(column) {
|
||||
var selected = $(gridid).data('selectedTrs');
|
||||
if (selected == null || selected.length == 0) {
|
||||
$(this).alertmsg('warn', '至少选择一个对象', {
|
||||
displayMode: 'slide',
|
||||
title: '重要提示'
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
//todo:下面这段只能chrome有效
|
||||
var records = new Array();
|
||||
selected.each(function () {
|
||||
records[records.length] = this.children[column].innerText;
|
||||
});
|
||||
|
||||
return records[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//自定义的编辑按钮
|
||||
function editModule() {
|
||||
var selected = getSelected(2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(this).dialog({
|
||||
id: 'editDialog',
|
||||
url: '/ModuleManager/Add?id=' + selected,
|
||||
title: '编辑',
|
||||
onClose:function() {
|
||||
refreshGrid();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function refreshGrid() {
|
||||
$('#@_gridId').datagrid('refresh');
|
||||
// loadDataGrid();
|
||||
}
|
||||
//@@ sourceURL=ModuleManagerIndex.js
|
||||
</script>
|
@ -42,6 +42,7 @@
|
||||
<component type=" OpenAuth.Repository.UserRepository" service=" OpenAuth.Domain.Interface.IUserRepository,OpenAuth.Domain" />
|
||||
<component type=" OpenAuth.Repository.OrgRepository" service="OpenAuth.Domain.Interface.IOrgRepository,OpenAuth.Domain" />
|
||||
<component type=" OpenAuth.Repository.RoleRepository" service="OpenAuth.Domain.Interface.IRoleRepository,OpenAuth.Domain" />
|
||||
<component type=" OpenAuth.Repository.ModuleRepository" service="OpenAuth.Domain.Interface.IModuleRepository,OpenAuth.Domain" />
|
||||
</components>
|
||||
</autofac>
|
||||
|
||||
|
44
OpenAuth.Repository/ModuleRepository.cs
Normal file
44
OpenAuth.Repository/ModuleRepository.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.Repository
|
||||
{
|
||||
public class ModuleRepository :BaseRepository<Module>, IModuleRepository
|
||||
{
|
||||
public IEnumerable<Module> LoadModules(int pageindex, int pagesize)
|
||||
{
|
||||
return Context.Modules.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||
}
|
||||
|
||||
public int GetRoleCntInOrgs(params int[] orgIds)
|
||||
{
|
||||
return LoadInOrgs(orgIds).Count();
|
||||
}
|
||||
|
||||
public int GetModuleCntInOrgs(params int[] orgIds)
|
||||
{
|
||||
return LoadInOrgs(orgIds).Count();
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<Module> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds)
|
||||
{
|
||||
return LoadInOrgs(orgIds).OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
Delete(u =>u.Id == id);
|
||||
}
|
||||
|
||||
public IEnumerable<Module> LoadInOrgs(params int[] orgId)
|
||||
{
|
||||
var result = from role in Context.Modules.Where(u => orgId.Contains(u.ParentId)) select role;
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -69,6 +69,7 @@
|
||||
<Compile Include="Models\OpenAuthDBContext.cs" />
|
||||
<Compile Include="OrgRepository.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ModuleRepository.cs" />
|
||||
<Compile Include="RoleRepository.cs" />
|
||||
<Compile Include="UserRepository.cs" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user