mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-17 01:46:30 +08:00
调整数据库菜单表结构,可以动态加载按钮,注意更新数据库结构并重新初始化数据库
This commit is contained in:
parent
135723f563
commit
af5e04d62f
@ -6,12 +6,12 @@ using System.Linq;
|
|||||||
namespace OpenAuth.Domain
|
namespace OpenAuth.Domain
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系统模块
|
/// 用户ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Module
|
public partial class Module
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模块ID
|
/// 用户ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
@ -29,10 +29,10 @@ namespace OpenAuth.Domain
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 组织类型
|
/// 元素的类型(如:button/a)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 功能模块Id
|
/// 功能模块Id
|
||||||
@ -40,6 +40,30 @@ namespace OpenAuth.Domain
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int ModuleId { get; set; }
|
public int ModuleId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 元素附加属性
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Attr { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 元素调用脚本
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Script { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 元素图标
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Icon { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 元素样式
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Class { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备注
|
/// 备注
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -52,9 +76,13 @@ namespace OpenAuth.Domain
|
|||||||
this.Id= 0;
|
this.Id= 0;
|
||||||
this.DomId= string.Empty;
|
this.DomId= string.Empty;
|
||||||
this.Name= string.Empty;
|
this.Name= string.Empty;
|
||||||
this.Type= 0;
|
this.Type = string.Empty;
|
||||||
this.ModuleId= 0;
|
this.ModuleId= 0;
|
||||||
this.Remark= string.Empty;
|
this.Attr= string.Empty;
|
||||||
|
this.Script= string.Empty;
|
||||||
|
this.Icon= string.Empty;
|
||||||
|
this.Class= string.Empty;
|
||||||
|
this.Remark= string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,56 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenAuth.Domain
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 用户ID
|
|
||||||
/// </summary>
|
|
||||||
public partial class ModuleElementGrant
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 用户ID
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 元素流水号
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int ElementId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 用户流水号
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int UserId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 角色流水号
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int RoleId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 权限类型
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public int GrantType { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public ModuleElementGrant()
|
|
||||||
{
|
|
||||||
this.Id= 0;
|
|
||||||
this.ElementId= 0;
|
|
||||||
this.UserId= 0;
|
|
||||||
this.RoleId= 0;
|
|
||||||
this.GrantType= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -51,7 +51,6 @@
|
|||||||
<Compile Include="Interface\IUserRepository.cs" />
|
<Compile Include="Interface\IUserRepository.cs" />
|
||||||
<Compile Include="Module.cs" />
|
<Compile Include="Module.cs" />
|
||||||
<Compile Include="ModuleElement.cs" />
|
<Compile Include="ModuleElement.cs" />
|
||||||
<Compile Include="ModuleElementGrant.cs" />
|
|
||||||
<Compile Include="Org.cs" />
|
<Compile Include="Org.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Relevance.cs" />
|
<Compile Include="Relevance.cs" />
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Data.Entity.Validation;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using OpenAuth.App;
|
using OpenAuth.App;
|
||||||
@ -42,9 +43,11 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_app.AddOrUpdate(button);
|
var newbtn = new ModuleElement();
|
||||||
|
button.CopyTo(newbtn);
|
||||||
|
_app.AddOrUpdate(newbtn);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (DbEntityValidationException e)
|
||||||
{
|
{
|
||||||
_bjuiResponse.statusCode = "300";
|
_bjuiResponse.statusCode = "300";
|
||||||
_bjuiResponse.message = e.Message;
|
_bjuiResponse.message = e.Message;
|
||||||
|
@ -21,28 +21,36 @@ $('#tableButtons').on('afterdelete.bjui.tabledit', function(e) {
|
|||||||
<table id="tableButtons" class="table table-bordered table-hover table-striped table-top"
|
<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">
|
data-toggle="tabledit" data-initnum="0" data-action="/ModuleElementManager/AddOrEditButton" data-single-noindex="true">
|
||||||
<thead>
|
<thead>
|
||||||
<tr data-idname="Id">
|
<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="Type" data-rule="required" value="button" size="5"></th>
|
||||||
<th width="80" title="按钮显示"><input type="text" name="Name" data-rule="required" value="" size="5"></th>
|
<th width="80" title="按钮标识"><input type="text" name="DomId" data-rule="required" value="" size="5"></th>
|
||||||
<th title="备注"><textarea name="Remark" data-toggle="autoheight"></textarea></th>
|
<th width="80" title="按钮显示"><input type="text" name="Name" data-rule="required" value="" size="5"></th>
|
||||||
<th width="80" title="所属模块ID"><input readonly="readonly" type="text" value="@ViewBag.ModuleId" name="ModuleId"/></th>
|
<th width="120" title="按钮样式"><input type="text" name="Class" data-rule="required" value="btn-green btn-nm" size="5"></th>
|
||||||
<th title="操作" width="100">
|
<th width="80" title="按钮图标"><input type="text" name="Icon" data-rule="required" value="pencil" size="5"></th>
|
||||||
<a href="javascript:;" class="btn btn-green" data-toggle="dosave">增加</a>
|
<th width="120" title="按钮脚本"><textarea name="Script" data-toggle="autoheight" value="javascript:;"></textarea></th>
|
||||||
<a href="javascript:;" class="btn btn-red row-del">取消</a>
|
<th width="120" title="附加属性"><textarea name="Attr" data-toggle="autoheight"></textarea></th>
|
||||||
</th>
|
<th width="80" title="所属模块ID"><input readonly="readonly" type="text" value="@ViewBag.ModuleId"
|
||||||
</tr>
|
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>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var element in Model)
|
@foreach (var element in Model)
|
||||||
{
|
{
|
||||||
<tr data-id="@element.Id">
|
<tr data-id="@element.Id">
|
||||||
|
<td>@element.Type</td>
|
||||||
<td>@element.DomId</td>
|
<td>@element.DomId</td>
|
||||||
<td>@element.Name</td>
|
<td>@element.Name</td>
|
||||||
<td>@element.Remark</td>
|
<td>@element.Class</td>
|
||||||
|
<td>@element.Icon</td>
|
||||||
|
<td>@element.Script</td>
|
||||||
|
<td>@element.Attr</td>
|
||||||
<td>@ViewBag.ModuleId</td>
|
<td>@ViewBag.ModuleId</td>
|
||||||
<td data-noedit="true">
|
<td data-noedit="true">
|
||||||
<input type="text" style="display: none" value="@element.Id" id="element_@element.Id" />
|
<input type="text" style="display: none" value="@element.Id" id="element_@element.Id"/>
|
||||||
<button type="button" class="btn-green" data-toggle="doedit">编辑</button>
|
<button type="button" class="btn-green" data-toggle="doedit">编辑</button>
|
||||||
<a href="/ModuleElementManager/DelButton?id={#element_@element.Id}" class="btn btn-red row-del"
|
<a href="/ModuleElementManager/DelButton?id={#element_@element.Id}" class="btn btn-red row-del"
|
||||||
data-confirm-msg="确定要删除该行信息吗?">删</a>
|
data-confirm-msg="确定要删除该行信息吗?">删</a>
|
||||||
|
@ -186,6 +186,9 @@
|
|||||||
|
|
||||||
$(this).dialog({
|
$(this).dialog({
|
||||||
id: 'editDialog',
|
id: 'editDialog',
|
||||||
|
width: 820,
|
||||||
|
height: 500,
|
||||||
|
mask:true,
|
||||||
url: '/ModuleElementManager/Index?id=' + selected,
|
url: '/ModuleElementManager/Index?id=' + selected,
|
||||||
title: '为模块分配按钮'
|
title: '为模块分配按钮'
|
||||||
});
|
});
|
||||||
|
@ -1,15 +1,37 @@
|
|||||||
@{
|
@using System.Text
|
||||||
|
@{
|
||||||
string _prefix = "user";
|
string _prefix = "user";
|
||||||
var _treeId = _prefix + "Tree";
|
var _treeId = _prefix + "Tree";
|
||||||
var _gridId = _prefix + "Grid";
|
var _gridId = _prefix + "Grid";
|
||||||
var _treeDetail = _prefix + "Detail";
|
var _treeDetail = _prefix + "Detail";
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="bjui-pageContent">
|
<div class="bjui-pageContent">
|
||||||
<div class="clearfix">
|
<div class="clearfix">
|
||||||
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
||||||
<ul id="@_treeId" class="ztree"></ul>
|
<ul id="@_treeId" class="ztree"></ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="bjui-pageHeader" style="margin-left: 225px">
|
||||||
|
<div class="bjui-searchBar">
|
||||||
|
<div class="bjui-searchBar">
|
||||||
|
@{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
foreach (var element in ViewBag.Module.Elements)
|
||||||
|
{
|
||||||
|
sb.Append("<" + element.Type
|
||||||
|
+" data-icon='" + element.Icon+"' "
|
||||||
|
+" class='" + element.Class+"' "
|
||||||
|
+" onclick='" + element.Script+"' " + element.Attr
|
||||||
|
+ ">"+element.Name +"</" + element.Type +">");
|
||||||
|
}
|
||||||
|
@Html.Raw(sb.ToString())
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="@_treeDetail" style="margin-left: 225px;">
|
<div id="@_treeDetail" style="margin-left: 225px;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -29,25 +51,15 @@
|
|||||||
$('#@_treeDetail').empty()
|
$('#@_treeDetail').empty()
|
||||||
.append('<table id="@_gridId" class="table table-bordered"></table>');
|
.append('<table id="@_gridId" class="table table-bordered"></table>');
|
||||||
|
|
||||||
@{
|
|
||||||
string strBtns = string.Empty;
|
|
||||||
foreach (var element in ViewBag.Module.Elements)
|
|
||||||
{
|
|
||||||
strBtns +="<button type=\"button\" class =\"btn btn-green\">"+element.Name +"</button>";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grid = $(gridid).datagrid({
|
grid = $(gridid).datagrid({
|
||||||
gridTitle: '用户列表',
|
showToolbar: false,
|
||||||
showToolbar: true,
|
|
||||||
filterThead: false,
|
filterThead: false,
|
||||||
toolbarItem: 'refresh, |, del',
|
toolbarItem: 'refresh, |, del',
|
||||||
toolbarCustom: '<a href="/UserManager/Add" class="btn btn-green" data-icon ="plus" ' +
|
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>' +
|
'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 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="openModuleAccess(this)">为用户分配模块</button>' +
|
||||||
'<button type="button" class ="btn btn-green" onclick="openRoleAccess(this)">为用户分配角色</button>' + '@strBtns',
|
'<button type="button" class ="btn btn-green" onclick="openRoleAccess(this)">为用户分配角色</button>',
|
||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
name: 'Id',
|
name: 'Id',
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Data.Entity.ModelConfiguration;
|
|
||||||
using OpenAuth.Domain;
|
|
||||||
|
|
||||||
namespace OpenAuth.Repository.Models.Mapping
|
|
||||||
{
|
|
||||||
public class ModuleElementGrantMap : EntityTypeConfiguration<ModuleElementGrant>
|
|
||||||
{
|
|
||||||
public ModuleElementGrantMap()
|
|
||||||
{
|
|
||||||
// Primary Key
|
|
||||||
this.HasKey(t => t.Id);
|
|
||||||
|
|
||||||
// Properties
|
|
||||||
// Table & Column Mappings
|
|
||||||
this.ToTable("ModuleElementGrant");
|
|
||||||
this.Property(t => t.Id).HasColumnName("Id");
|
|
||||||
this.Property(t => t.ElementId).HasColumnName("ElementId");
|
|
||||||
this.Property(t => t.UserId).HasColumnName("UserId");
|
|
||||||
this.Property(t => t.RoleId).HasColumnName("RoleId");
|
|
||||||
this.Property(t => t.GrantType).HasColumnName("GrantType");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,9 +20,25 @@ namespace OpenAuth.Repository.Models.Mapping
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(255);
|
.HasMaxLength(255);
|
||||||
|
|
||||||
|
this.Property(t => t.Attr)
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(500);
|
||||||
|
|
||||||
|
this.Property(t => t.Script)
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(500);
|
||||||
|
|
||||||
|
this.Property(t => t.Icon)
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255);
|
||||||
|
|
||||||
|
this.Property(t => t.Class)
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(255);
|
||||||
|
|
||||||
this.Property(t => t.Remark)
|
this.Property(t => t.Remark)
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasMaxLength(4000);
|
.HasMaxLength(200);
|
||||||
|
|
||||||
// Table & Column Mappings
|
// Table & Column Mappings
|
||||||
this.ToTable("ModuleElement");
|
this.ToTable("ModuleElement");
|
||||||
@ -31,6 +47,10 @@ namespace OpenAuth.Repository.Models.Mapping
|
|||||||
this.Property(t => t.Name).HasColumnName("Name");
|
this.Property(t => t.Name).HasColumnName("Name");
|
||||||
this.Property(t => t.Type).HasColumnName("Type");
|
this.Property(t => t.Type).HasColumnName("Type");
|
||||||
this.Property(t => t.ModuleId).HasColumnName("ModuleId");
|
this.Property(t => t.ModuleId).HasColumnName("ModuleId");
|
||||||
|
this.Property(t => t.Attr).HasColumnName("Attr");
|
||||||
|
this.Property(t => t.Script).HasColumnName("Script");
|
||||||
|
this.Property(t => t.Icon).HasColumnName("Icon");
|
||||||
|
this.Property(t => t.Class).HasColumnName("Class");
|
||||||
this.Property(t => t.Remark).HasColumnName("Remark");
|
this.Property(t => t.Remark).HasColumnName("Remark");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ namespace OpenAuth.Repository.Models
|
|||||||
|
|
||||||
public DbSet<Module> Modules { get; set; }
|
public DbSet<Module> Modules { get; set; }
|
||||||
public DbSet<ModuleElement> ModuleElements { get; set; }
|
public DbSet<ModuleElement> ModuleElements { get; set; }
|
||||||
public DbSet<ModuleElementGrant> ModuleElementGrants { get; set; }
|
|
||||||
public DbSet<Org> Orgs { get; set; }
|
public DbSet<Org> Orgs { get; set; }
|
||||||
public DbSet<Relevance> Relevances { get; set; }
|
public DbSet<Relevance> Relevances { get; set; }
|
||||||
public DbSet<Role> Roles { get; set; }
|
public DbSet<Role> Roles { get; set; }
|
||||||
@ -31,7 +30,6 @@ namespace OpenAuth.Repository.Models
|
|||||||
{
|
{
|
||||||
modelBuilder.Configurations.Add(new ModuleMap());
|
modelBuilder.Configurations.Add(new ModuleMap());
|
||||||
modelBuilder.Configurations.Add(new ModuleElementMap());
|
modelBuilder.Configurations.Add(new ModuleElementMap());
|
||||||
modelBuilder.Configurations.Add(new ModuleElementGrantMap());
|
|
||||||
modelBuilder.Configurations.Add(new OrgMap());
|
modelBuilder.Configurations.Add(new OrgMap());
|
||||||
modelBuilder.Configurations.Add(new RelevanceMap());
|
modelBuilder.Configurations.Add(new RelevanceMap());
|
||||||
modelBuilder.Configurations.Add(new RoleMap());
|
modelBuilder.Configurations.Add(new RoleMap());
|
||||||
|
@ -54,7 +54,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BaseRepository.cs" />
|
<Compile Include="BaseRepository.cs" />
|
||||||
<Compile Include="Models\Mapping\ModuleElementGrantMap.cs" />
|
|
||||||
<Compile Include="Models\Mapping\ModuleElementMap.cs" />
|
<Compile Include="Models\Mapping\ModuleElementMap.cs" />
|
||||||
<Compile Include="Models\Mapping\ModuleMap.cs" />
|
<Compile Include="Models\Mapping\ModuleMap.cs" />
|
||||||
<Compile Include="Models\Mapping\OrgMap.cs" />
|
<Compile Include="Models\Mapping\OrgMap.cs" />
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user