mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-15 14:04:41 +08:00
完成模块分配按钮
This commit is contained in:
parent
87712e2b49
commit
000df6d1d3
53
OpenAuth.App/ModuleElementManagerApp.cs
Normal file
53
OpenAuth.App/ModuleElementManagerApp.cs
Normal file
@ -0,0 +1,53 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : OpenAuth.App
|
||||
// Author : Yubao Li
|
||||
// Created : 12-02-2015
|
||||
//
|
||||
// Last Modified By : Yubao Li
|
||||
// Last Modified On : 12-02-2015
|
||||
// ***********************************************************************
|
||||
// <copyright file="ModuleElementManagerApp.cs" company="">
|
||||
// Copyright (c) . All rights reserved.
|
||||
// </copyright>
|
||||
// <summary>模块元素</summary>
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Domain.Interface;
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class ModuleElementManagerApp
|
||||
{
|
||||
private readonly IRepository<ModuleElement> _repository;
|
||||
|
||||
public ModuleElementManagerApp(IRepository<ModuleElement> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
public void AddOrUpdate(ModuleElement model)
|
||||
{
|
||||
if (model.Id == 0)
|
||||
{
|
||||
_repository.Add(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_repository.Update(model);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<ModuleElement> LoadByModuleId(int id)
|
||||
{
|
||||
var modules = _repository.Find(u => u.ModuleId == id);
|
||||
return modules;
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
_repository.Delete(u =>u.Id ==id);
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LoginApp.cs" />
|
||||
<Compile Include="ModuleElementManagerApp.cs" />
|
||||
<Compile Include="ModuleManagerApp.cs" />
|
||||
<Compile Include="RoleManagerApp.cs" />
|
||||
<Compile Include="UserManagerApp.cs" />
|
||||
|
@ -18,6 +18,8 @@ using Autofac.Integration.Mvc;
|
||||
using OpenAuth.App;
|
||||
using System.Reflection;
|
||||
using System.Web.Mvc;
|
||||
using OpenAuth.Domain.Interface;
|
||||
using OpenAuth.Repository;
|
||||
|
||||
namespace OpenAuth.Mvc
|
||||
{
|
||||
@ -27,12 +29,20 @@ namespace OpenAuth.Mvc
|
||||
{
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
//泛型注册
|
||||
builder.RegisterGeneric(typeof(BaseRepository<>)).As(typeof(IRepository<>));
|
||||
|
||||
//应用层注册
|
||||
builder.RegisterModule(new ConfigurationSettingsReader("autofac"));
|
||||
builder.RegisterType<LoginApp>();
|
||||
builder.RegisterType<OrgManagerApp>();
|
||||
builder.RegisterType<UserManagerApp>();
|
||||
builder.RegisterType<RoleManagerApp>();
|
||||
builder.RegisterType<ModuleManagerApp>();
|
||||
builder.RegisterType<ModuleElementManagerApp>();
|
||||
|
||||
|
||||
|
||||
// Register your MVC controllers.
|
||||
builder.RegisterControllers(typeof(MvcApplication).Assembly);
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
var loginUser = SessionHelper.GetSessionUser<LoginUserVM>();
|
||||
if (loginUser == null)
|
||||
{
|
||||
Response.Redirect("/Login/Index");
|
||||
filterContext.Result = new RedirectResult("/Login/Index");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
&& !url.Contains("Git")
|
||||
&& !loginUser.Modules.Any(u => url.Contains(u.Url)))
|
||||
{
|
||||
Response.Redirect("/Error/NoAccess");
|
||||
filterContext.Result = new RedirectResult("/Login/Index");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
69
OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
Normal file
69
OpenAuth.Mvc/Controllers/ModuleElementManagerController.cs
Normal file
@ -0,0 +1,69 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : OpenAuth.Mvc
|
||||
// Author : Yubao Li
|
||||
// Created : 12-02-2015
|
||||
//
|
||||
// Last Modified By : Yubao Li
|
||||
// Last Modified On : 12-02-2015
|
||||
// ***********************************************************************
|
||||
// <copyright file="ModuleElementManagerController.cs" company="">
|
||||
// Copyright (c) . All rights reserved.
|
||||
// </copyright>
|
||||
// <summary>模块元素管理,无需权限控制</summary>
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Mvc.Models;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class ModuleElementManagerController : Controller
|
||||
{
|
||||
private readonly BjuiResponse _bjuiResponse = new BjuiResponse();
|
||||
private ModuleElementManagerApp _app;
|
||||
|
||||
public ModuleElementManagerController()
|
||||
{
|
||||
_app = (ModuleElementManagerApp) DependencyResolver.Current.GetService(typeof (ModuleElementManagerApp));
|
||||
}
|
||||
|
||||
public ActionResult Index(int id = 0)
|
||||
{
|
||||
ViewBag.ModuleId = id;
|
||||
return View(_app.LoadByModuleId(id));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public string AddOrEditButton(ModuleElement button)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.AddOrUpdate(button);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_bjuiResponse.statusCode = "300";
|
||||
_bjuiResponse.message = e.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
||||
}
|
||||
|
||||
public string DelButton(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Delete(id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_bjuiResponse.statusCode = "300";
|
||||
_bjuiResponse.message = e.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
||||
}
|
||||
}
|
||||
}
|
@ -122,7 +122,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
#region 命令操作
|
||||
#region 添加编辑模块
|
||||
public ActionResult Add(int id = 0)
|
||||
{
|
||||
return View(_app.Find(id));
|
||||
@ -162,5 +162,6 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -128,6 +128,7 @@
|
||||
<Compile Include="Controllers\ErrorController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\LoginController.cs" />
|
||||
<Compile Include="Controllers\ModuleElementManagerController.cs" />
|
||||
<Compile Include="Controllers\ModuleManagerController.cs" />
|
||||
<Compile Include="Controllers\OrgManagerController.cs" />
|
||||
<Compile Include="Controllers\RoleManagerController.cs" />
|
||||
@ -622,6 +623,7 @@
|
||||
<Content Include="Views\ModuleManager\Add.cshtml" />
|
||||
<Content Include="Views\ModuleManager\LookupMultiForUser.cshtml" />
|
||||
<Content Include="Views\ModuleManager\LookupMultiForRole.cshtml" />
|
||||
<None Include="Views\ModuleElementManager\Index.cshtml" />
|
||||
<None Include="Views\OrgManager\AddOrg.cshtml" />
|
||||
<Content Include="Views\OrgManager\LookupParent.cshtml" />
|
||||
<Content Include="Views\UserManager\Index.cshtml" />
|
||||
|
@ -171,7 +171,8 @@
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">我的账户 <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="changepwd.html" data-toggle="dialog" data-id="changepwd_page" data-mask="true" data-width="400" data-height="260"> <span class="glyphicon glyphicon-lock"></span> 修改密码 </a></li>
|
||||
<li><a href="changepwd.html" data-toggle="dialog" data-id="changepwd_page" data-mask="true"
|
||||
data-width="400" data-height="260"> <span class="glyphicon glyphicon-lock"></span> 修改密码 </a></li>
|
||||
<li><a href="#"> <span class="glyphicon glyphicon-user"></span> 我的资料</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="/Login/Logout" class="red"> <span class="glyphicon glyphicon-off"></span> 注销登陆</a></li>
|
||||
@ -225,12 +226,10 @@
|
||||
<i class="fa fa-cog"></i> 系统设置 <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li><a href="#">角色权限</a></li>
|
||||
<li><a href="#">用户列表</a></li>
|
||||
<li><a href="https://git.oschina.net/yubaolee/OpenAuth.Net" target="_blank">关于OpenAuth.Net</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#">关于我们</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="#">友情链接</a></li>
|
||||
<li><a href="http://www.cnblogs.com/yubaolee" target="_blank">官方博客</a></li>
|
||||
<li><a href="http://b-jui.com/index_tree.html" target="_blank">友情链接</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -9,18 +9,17 @@
|
||||
<div class="bjui-pageHeader" style="background:#FFF;">
|
||||
<div style="padding: 0 15px;">
|
||||
<h4 style="margin-bottom:20px;">
|
||||
基于经典DDD架构的权限管理系统 <small>轻松开发,专注您的业务!</small>
|
||||
基于经典DDD架构的权限管理系统
|
||||
</h4>
|
||||
|
||||
<div style=" margin-top:22px; padding-left:6px;">
|
||||
|
||||
<span style="padding-left:30px;">官方博客:</span><a href="http://www.cnblogs.com/yubaolee/" target="_blank">http://www.cnblogs.com/yubaolee/</a>
|
||||
<span style="padding-left: 30px;">官方博客:</span>
|
||||
<a href="http://www.cnblogs.com/yubaolee/" target="_blank">http://www.cnblogs.com/yubaolee/</a>
|
||||
</div>
|
||||
<div class="row" style=" margin-top:10px;">
|
||||
<div class="col-md-6" style="padding:5px;">
|
||||
<div class="alert alert-info" role="alert" style="margin:0 0 5px; padding:5px 15px;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
61
OpenAuth.Mvc/Views/ModuleElementManager/Index.cshtml
Normal file
61
OpenAuth.Mvc/Views/ModuleElementManager/Index.cshtml
Normal file
@ -0,0 +1,61 @@
|
||||
@model IEnumerable<OpenAuth.Domain.ModuleElement>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
//删除回调
|
||||
$('#tableButtons').on('afterdelete.bjui.tabledit', function(e) {
|
||||
var $tbody = $(e.relatedTarget);
|
||||
console.log('你删除了一条数据,还有['+ $tbody.find('> tr').length +']条数据!');
|
||||
})
|
||||
</script>
|
||||
<div class="bjui-pageHeader">
|
||||
<div class="bjui-searchBar">
|
||||
<div class="alert alert-info search-inline"><i class="fa fa-info-circle"></i> 双击行可编辑</div>
|
||||
<button type="button" class="btn-green" data-toggle="tableditadd" data-target="#tableButtons" data-num="1" data-icon="plus">
|
||||
添加新按钮
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bjui-pageContent tableContent">
|
||||
<form id="j_custom_form" class="pageForm" data-toggle="validate" method="post">
|
||||
<table id="tableButtons" class="table table-bordered table-hover table-striped table-top"
|
||||
data-toggle="tabledit" data-initnum="0" data-action="/ModuleElementManager/AddOrEditButton" data-single-noindex="true">
|
||||
<thead>
|
||||
<tr data-idname="Id">
|
||||
<th width="80" title="按钮标识"><input type="text" name="DomId" data-rule="required" value="" size="5"></th>
|
||||
<th width="80" title="按钮显示"><input type="text" name="Name" data-rule="required" value="" size="5"></th>
|
||||
<th title="备注"><textarea name="Remark" data-toggle="autoheight"></textarea></th>
|
||||
<th width="80" title="所属模块ID"><input readonly="readonly" type="text" value="@ViewBag.ModuleId" name="ModuleId"/></th>
|
||||
<th title="操作" width="100">
|
||||
<a href="javascript:;" class="btn btn-green" data-toggle="dosave">增加</a>
|
||||
<a href="javascript:;" class="btn btn-red row-del">取消</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var element in Model)
|
||||
{
|
||||
<tr data-id="@element.Id">
|
||||
|
||||
<td>@element.DomId</td>
|
||||
<td>@element.Name</td>
|
||||
<td>@element.Remark</td>
|
||||
<td>@ViewBag.ModuleId</td>
|
||||
<td data-noedit="true">
|
||||
<input type="text" style="display: none" value="@element.Id" id="element_@element.Id" />
|
||||
<button type="button" class="btn-green" data-toggle="doedit">编辑</button>
|
||||
<a href="/ModuleElementManager/DelButton?id={#element_@element.Id}" class="btn btn-red row-del"
|
||||
data-confirm-msg="确定要删除该行信息吗?">删</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<div class="bjui-pageFooter">
|
||||
<ul>
|
||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
||||
</ul>
|
||||
</div>
|
@ -36,7 +36,8 @@
|
||||
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>',
|
||||
'<button class=" btn-green" onclick="editModule()" data-icon="pencil" type="button">编辑</button>' +
|
||||
'<button class=" btn-green" onclick="assignButton()" data-icon="pencil" type="button">为模块分配按钮</button>',
|
||||
columns: [
|
||||
{
|
||||
name: 'Id',
|
||||
@ -178,6 +179,19 @@
|
||||
|
||||
}
|
||||
|
||||
//为模块分配按钮
|
||||
function assignButton() {
|
||||
var selected = getSelected(2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(this).dialog({
|
||||
id: 'editDialog',
|
||||
url: '/ModuleElementManager/Index?id=' + selected,
|
||||
title: '为模块分配按钮'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function refreshGrid() {
|
||||
$('#@_gridId').datagrid('refresh');
|
||||
// loadDataGrid();
|
||||
|
@ -37,7 +37,7 @@
|
||||
toolbarCustom: '<a href="/RoleManager/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="editRole()" data-icon="pencil" type="button">编辑</button>'+
|
||||
'<button type="button" class="btn btn-green" onclick="openModuleAccess(this)">角色模块</button>',
|
||||
'<button type="button" class="btn btn-green" onclick="openModuleAccess(this)">为角色分配模块</button>',
|
||||
columns: [
|
||||
{
|
||||
name: 'Id',
|
||||
|
@ -37,8 +37,8 @@
|
||||
toolbarCustom: '<a href="/UserManager/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="editOrg()" data-icon="pencil" type="button">编辑</button>' +
|
||||
'<button type="button" class="btn btn-green" onclick="openModuleAccess(this)">用户模块授权</button>'+
|
||||
'<button type="button" class ="btn btn-green" onclick="openRoleAccess(this)">用户角色授权</button>',
|
||||
'<button type="button" class="btn btn-green" onclick="openModuleAccess(this)">为用户分配模块</button>'+
|
||||
'<button type="button" class ="btn btn-green" onclick="openRoleAccess(this)">为用户分配角色</button>',
|
||||
columns: [
|
||||
{
|
||||
name: 'Id',
|
||||
|
Loading…
Reference in New Issue
Block a user