mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-25 01:14:31 +08:00
调整结构
This commit is contained in:
parent
69fdbef881
commit
64756cfd31
@ -1,72 +1,72 @@
|
|||||||
<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
|
<%@ Template Language="C#" TargetLanguage="C#" Debug="True" Encoding="UTF-8" %>
|
||||||
|
|
||||||
<%@ Assembly Src="Model.cs" %>
|
<%@ Assembly Src="Model.cs" %>
|
||||||
<%@ Assembly Src="Extensions.cs" %>
|
<%@ Assembly Src="Extensions.cs" %>
|
||||||
|
|
||||||
<%@ Import Namespace="System.Collections.Generic" %>
|
<%@ Import Namespace="System.Collections.Generic" %>
|
||||||
<%@ Import Namespace="System.Linq" %>
|
<%@ Import Namespace="System.Linq" %>
|
||||||
<%@ Import Namespace="System.Text" %>
|
<%@ Import Namespace="System.Text" %>
|
||||||
<%@ Import Namespace="System.Text.RegularExpressions" %>
|
<%@ Import Namespace="System.Text.RegularExpressions" %>
|
||||||
|
|
||||||
<%@ Import Namespace="SchemaMapper" %>
|
<%@ Import Namespace="SchemaMapper" %>
|
||||||
|
|
||||||
<%@ Property Name="Entity"
|
<%@ Property Name="Entity"
|
||||||
Type="SchemaMapper.Entity" %>
|
Type="SchemaMapper.Entity" %>
|
||||||
|
|
||||||
<%@ Property Name="EntityNamespace"
|
<%@ Property Name="EntityNamespace"
|
||||||
Type="System.String" %>
|
Type="System.String" %>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <autogenerated>
|
// <autogenerated>
|
||||||
// This code was generated by a CodeSmith Template.
|
// This code was generated by a CodeSmith Template.
|
||||||
//
|
//
|
||||||
// DO NOT MODIFY contents of this file. Changes to this
|
// DO NOT MODIFY contents of this file. Changes to this
|
||||||
// file will be lost if the code is regenerated.
|
// file will be lost if the code is regenerated.
|
||||||
// Author:Yubao Li
|
// Author:Yubao Li
|
||||||
// </autogenerated>
|
// </autogenerated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace <%= EntityNamespace %>
|
namespace <%= EntityNamespace %>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <%= Entity.Description %>
|
/// <%= Entity.Description %>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class <%= Entity.ClassName.ToSafeName() %> : Entity
|
public partial class <%= Entity.ClassName.ToSafeName() %> : Entity
|
||||||
{
|
{
|
||||||
public <%= Entity.ClassName.ToSafeName() %>()
|
public <%= Entity.ClassName.ToSafeName() %>()
|
||||||
{
|
{
|
||||||
<% foreach(var p in Entity.Properties) {
|
<% foreach(var p in Entity.Properties) {
|
||||||
if(p.IsPrimaryKey ==true) continue;
|
if(p.IsPrimaryKey ==true) continue;
|
||||||
string type = p.SystemType.ToNullableType(p.IsNullable == true);
|
string type = p.SystemType.ToNullableType(p.IsNullable == true);
|
||||||
if(type =="int" || type=="decimal")
|
if(type =="int" || type=="decimal")
|
||||||
Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= 0;");
|
Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= 0;");
|
||||||
else if(type =="string")
|
else if(type =="string")
|
||||||
Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= string.Empty;");
|
Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= string.Empty;");
|
||||||
else if(type.ToLower().Contains("datetime"))
|
else if(type.ToLower().Contains("datetime"))
|
||||||
Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= DateTime.Now;");
|
Response.WriteLine(" this."+p.PropertyName.ToSafeName()+"= DateTime.Now;");
|
||||||
} // foreach %>
|
} // foreach %>
|
||||||
<% foreach(var r in Entity.Relationships.Where(e => e.ThisCardinality == Cardinality.Many)) { %>
|
<% foreach(var r in Entity.Relationships.Where(e => e.ThisCardinality == Cardinality.Many)) { %>
|
||||||
<%= r.ThisPropertyName.ToSafeName() %> = new List<<%= r.OtherEntity.ToSafeName() %>>();
|
<%= r.ThisPropertyName.ToSafeName() %> = new List<<%= r.OtherEntity.ToSafeName() %>>();
|
||||||
<% } // foreach %>
|
<% } // foreach %>
|
||||||
}
|
}
|
||||||
|
|
||||||
<% foreach(var p in Entity.Properties) {
|
<% foreach(var p in Entity.Properties) {
|
||||||
if(p.IsPrimaryKey ==true) continue;
|
if(p.IsPrimaryKey ==true) continue;
|
||||||
%>
|
%>
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <%=p.Description %>
|
/// <%=p.Description %>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public <%= p.SystemType.ToNullableType(p.IsNullable == true) %> <%= p.PropertyName.ToSafeName() %> { get; set; }
|
public <%= p.SystemType.ToNullableType(p.IsNullable == true) %> <%= p.PropertyName.ToSafeName() %> { get; set; }
|
||||||
<% } // foreach %>
|
<% } // foreach %>
|
||||||
|
|
||||||
<% foreach(var r in Entity.Relationships) { %>
|
<% foreach(var r in Entity.Relationships) { %>
|
||||||
<% if(r.ThisCardinality == Cardinality.Many) { %>
|
<% if(r.ThisCardinality == Cardinality.Many) { %>
|
||||||
public virtual ICollection<<%= r.OtherEntity.ToSafeName() %>> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
|
public virtual ICollection<<%= r.OtherEntity.ToSafeName() %>> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
public virtual <%= r.OtherEntity.ToSafeName() %> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
|
public virtual <%= r.OtherEntity.ToSafeName() %> <%= r.ThisPropertyName.ToSafeName() %> { get; set; }
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } // foreach %>
|
<% } // foreach %>
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -100,4 +100,6 @@ Description="连接的数据库" %>
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="~/BllScripts/grid.js"></script>
|
<script src="~/BllScripts/grid.js"></script>
|
||||||
<script src="~/BllScripts/<%=ModuleName%>.js"></script>
|
<script src="~/BllScripts/<%=ModuleName%>.js"></script>
|
||||||
|
|
||||||
|
|
@ -1,138 +0,0 @@
|
|||||||
<%--
|
|
||||||
Name: Database Table Properties
|
|
||||||
Author: yubaolee
|
|
||||||
Description: Create a list of properties from a database table
|
|
||||||
--%>
|
|
||||||
<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="应用层" %>
|
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
|
||||||
<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %>
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
|
||||||
<%@ Import Namespace="SchemaExplorer" %>
|
|
||||||
<script runat="template">
|
|
||||||
public String GetModelName()
|
|
||||||
{
|
|
||||||
if(NeedViewModel)
|
|
||||||
return ModuleName +"View";
|
|
||||||
else
|
|
||||||
return ModuleName;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<%if(NeedViewModel){ %>
|
|
||||||
using OpenAuth.App.ViewModel;
|
|
||||||
<%} %>
|
|
||||||
using OpenAuth.Domain;
|
|
||||||
using OpenAuth.Domain.Interface;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenAuth.App
|
|
||||||
{
|
|
||||||
public class <%=ModuleName%>ManagerApp
|
|
||||||
{
|
|
||||||
private I<%=ModuleName%>Repository _repository;
|
|
||||||
private IOrgRepository _orgRepository;
|
|
||||||
|
|
||||||
public <%=ModuleName%>ManagerApp(I<%=ModuleName%>Repository repository,
|
|
||||||
IOrgRepository orgRepository)
|
|
||||||
{
|
|
||||||
_repository = repository;
|
|
||||||
_orgRepository = orgRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Get<%=GetModelName()%>CntInOrg(int orgId)
|
|
||||||
{
|
|
||||||
if (orgId == 0)
|
|
||||||
{
|
|
||||||
return _repository.Find(null).Count();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return _repository.Get<%=GetModelName()%>CntInOrgs(GetSubOrgIds(orgId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<<%=GetModelName()%>> LoadAll()
|
|
||||||
{
|
|
||||||
return _repository.Find(null).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载一个节点下面的一个或全部<%=GetModelName()%>s
|
|
||||||
/// </summary>
|
|
||||||
public dynamic Load(int orgId, int pageindex, int pagesize)
|
|
||||||
{
|
|
||||||
IEnumerable<<%=ModuleName%>> <%=ModuleName%>s;
|
|
||||||
int total = 0;
|
|
||||||
if (orgId == 0)
|
|
||||||
{
|
|
||||||
<%=ModuleName%>s = _repository.Load<%=ModuleName%>s(pageindex, pagesize);
|
|
||||||
total = _repository.GetCount();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<%=ModuleName%>s = _repository.LoadInOrgs(pageindex, pagesize,GetSubOrgIds(orgId));
|
|
||||||
total = _repository.Get<%=ModuleName%>CntInOrgs(orgId);
|
|
||||||
}
|
|
||||||
<%if(NeedViewModel){ %>
|
|
||||||
var <%=ModuleName%>views = new List<<%=ModuleName%>View>();
|
|
||||||
foreach (var <%=ModuleName%> in <%=ModuleName%>s)
|
|
||||||
{
|
|
||||||
<%=ModuleName%>View uv = <%=ModuleName%>;
|
|
||||||
uv.Organizations = string.Join(",", _orgRepository.LoadBy<%=ModuleName%>(<%=ModuleName%>.Id).Select(u => u.Name).ToList());
|
|
||||||
<%=ModuleName%>views.Add(uv);
|
|
||||||
}
|
|
||||||
<%} %>
|
|
||||||
|
|
||||||
return new
|
|
||||||
{
|
|
||||||
total = total,
|
|
||||||
list = <%=GetModelName()%>s,
|
|
||||||
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 <%=GetModelName()%> Find(int id)
|
|
||||||
{
|
|
||||||
var <%=ModuleName.ToLower()%> = _repository.FindSingle(u => u.Id == id);
|
|
||||||
if (<%=ModuleName.ToLower()%> == null) return new <%=GetModelName()%>();
|
|
||||||
|
|
||||||
return <%=ModuleName.ToLower() %>;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Delete(int id)
|
|
||||||
{
|
|
||||||
_repository.Delete(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddOrUpdate(<%=GetModelName()%> model)
|
|
||||||
{
|
|
||||||
<%=ModuleName%> <%=ModuleName.ToLower()%> = new <%=ModuleName%>();
|
|
||||||
model.CopyTo(<%=ModuleName.ToLower()%>);
|
|
||||||
|
|
||||||
if (<%=ModuleName.ToLower()%>.Id == 0)
|
|
||||||
{
|
|
||||||
_repository.Add(<%=ModuleName.ToLower()%>);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_repository.Update(<%=ModuleName.ToLower()%>);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,110 +0,0 @@
|
|||||||
<%--
|
|
||||||
Name: Database Table Properties
|
|
||||||
Author: yubaolee
|
|
||||||
Description: Create a list of properties from a database table
|
|
||||||
--%>
|
|
||||||
<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="控制器" %>
|
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
|
||||||
<%@ Property Name="NeedViewModel" Type="Boolean" Category="Context" Default="False" Description="是否需要ViewModel" %>
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
|
||||||
<%@ Import Namespace="SchemaExplorer" %>
|
|
||||||
<script runat="template">
|
|
||||||
public String GetModelName()
|
|
||||||
{
|
|
||||||
if(NeedViewModel)
|
|
||||||
return ModuleName +"View";
|
|
||||||
else
|
|
||||||
return ModuleName;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using Infrastructure;
|
|
||||||
using OpenAuth.App;
|
|
||||||
<%if(NeedViewModel){ %>
|
|
||||||
using OpenAuth.App.ViewModel;
|
|
||||||
<%} %>
|
|
||||||
using OpenAuth.Domain;
|
|
||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
|
||||||
{
|
|
||||||
public class <%=ModuleName%>ManagerController : BaseController
|
|
||||||
{
|
|
||||||
private <%=ModuleName%>ManagerApp _app;
|
|
||||||
|
|
||||||
public <%=ModuleName%>ManagerController()
|
|
||||||
{
|
|
||||||
_app = AutofacExt.GetFromFac<<%=ModuleName%>ManagerApp>();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// GET: /UserManager/
|
|
||||||
public ActionResult Index()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResult Add(int id = 0)
|
|
||||||
{
|
|
||||||
return View(_app.Find(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
//添加或修改<%=ModuleName %>
|
|
||||||
[HttpPost]
|
|
||||||
public string Add(<%=GetModelName()%> model)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_app.AddOrUpdate(model);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
BjuiResponse.statusCode = "300";
|
|
||||||
BjuiResponse.message = ex.Message;
|
|
||||||
}
|
|
||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载节点下面的所有<%=ModuleName %>s
|
|
||||||
/// </summary>
|
|
||||||
public string Load(int parentId, int pageCurrent = 1, int pageSize = 30)
|
|
||||||
{
|
|
||||||
return JsonHelper.Instance.Serialize(_app.Load(parentId, pageCurrent, pageSize));
|
|
||||||
}
|
|
||||||
|
|
||||||
public string LoadForTree()
|
|
||||||
{
|
|
||||||
var models = _app.LoadAll();
|
|
||||||
//添加根节点
|
|
||||||
models.Add(new <%=ModuleName %>
|
|
||||||
{
|
|
||||||
Id = 0,
|
|
||||||
ParentId = -1,
|
|
||||||
Name = "根结点",
|
|
||||||
CascadeId = "0"
|
|
||||||
});
|
|
||||||
return JsonHelper.Instance.Serialize(models);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Delete(int Id)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_app.Delete(Id);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
BjuiResponse.statusCode = "300";
|
|
||||||
BjuiResponse.message = e.Message;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<%--
|
|
||||||
Name: Database Table Properties
|
|
||||||
Author: yubaolee
|
|
||||||
Description: Create a list of properties from a database table
|
|
||||||
--%>
|
|
||||||
<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="创建包含组织机构的接口" %>
|
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
|
||||||
<%@ Import Namespace="SchemaExplorer" %>
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace OpenAuth.Domain.Interface
|
|
||||||
{
|
|
||||||
public interface I<%=ModuleName%>Repository :IRepository<<%=ModuleName%>>
|
|
||||||
{
|
|
||||||
IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize);
|
|
||||||
|
|
||||||
IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId);
|
|
||||||
int Get<%=ModuleName%>CntInOrgs(params int[] orgIds);
|
|
||||||
IEnumerable<<%=ModuleName%>> LoadInOrgs(int pageindex, int pagesize, params int[] orgIds);
|
|
||||||
|
|
||||||
void Delete(int id);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,112 +0,0 @@
|
|||||||
<%--
|
|
||||||
Name: Database Table Properties
|
|
||||||
Author: yubaolee
|
|
||||||
Description: 没有树状导航的datagrid
|
|
||||||
--%>
|
|
||||||
<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="True" Description="Create a list of properties from database table." %>
|
|
||||||
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="Table that the object is based on." %>
|
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
|
||||||
<%@ Import Namespace="SchemaExplorer" %>
|
|
||||||
|
|
||||||
@{
|
|
||||||
string _prefix = "<%=ModuleName%>";
|
|
||||||
var _treeId = _prefix + "Tree";
|
|
||||||
var _gridId = _prefix + "Grid";
|
|
||||||
var _treeDetail = _prefix + "Detail";
|
|
||||||
}
|
|
||||||
|
|
||||||
@{ Html.RenderAction("MenuHeader", "Home");}
|
|
||||||
<div class="bjui-pageContent tableContent">
|
|
||||||
<div class="clearfix">
|
|
||||||
<div id="@_treeDetail" style="margin-left: 225px;">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function () {
|
|
||||||
loadDataGrid();
|
|
||||||
});
|
|
||||||
//加载数据到datagrid
|
|
||||||
function loadDataGrid() {
|
|
||||||
//b-jui的datagrid需要重新处理HTML
|
|
||||||
$('#@_treeDetail').empty()
|
|
||||||
.append('<table id="@_gridId" class="table table-bordered table-hover table-striped table-top"></table>');
|
|
||||||
|
|
||||||
$('#@_gridId').datagrid({
|
|
||||||
showToolbar: false,
|
|
||||||
filterThead: false,
|
|
||||||
columns: [
|
|
||||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
|
||||||
{
|
|
||||||
name: '<%=column.Name%>',
|
|
||||||
label: '<%=column.Description%>',
|
|
||||||
width: 100
|
|
||||||
<%if(column.IsPrimaryKeyMember){ %>
|
|
||||||
, hide: true
|
|
||||||
<%} %>
|
|
||||||
<%else if(CSharpAlias[column.SystemType.FullName] == "System.DateTime") {%>
|
|
||||||
, type: 'date',
|
|
||||||
pattern: 'yyyy-MM-dd HH:mm:ss'
|
|
||||||
<%} %>
|
|
||||||
<%else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
|
||||||
,type: 'select',
|
|
||||||
align: 'center',
|
|
||||||
items: [{ '0': '否' }, { '1': '是' }],
|
|
||||||
<%} %>
|
|
||||||
<%else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
|
|
||||||
,type: 'select',
|
|
||||||
align: 'center',
|
|
||||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
|
||||||
<%} %>
|
|
||||||
},
|
|
||||||
<% } %>
|
|
||||||
],
|
|
||||||
dataUrl: '<%=ModuleName%>Manager/Load?parentId=' + selectedId,
|
|
||||||
fullGrid: true,
|
|
||||||
showLinenumber: true,
|
|
||||||
showCheckboxcol: true,
|
|
||||||
paging: true,
|
|
||||||
filterMult: false,
|
|
||||||
showTfoot: true,
|
|
||||||
height: '700'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//删除
|
|
||||||
function del<%=ModuleName%>() {
|
|
||||||
var selected = getSelected('#@_gridId',2);
|
|
||||||
if (selected == null) return;
|
|
||||||
|
|
||||||
$.getJSON('<%=ModuleName%>Manager/Delete?Id=' + selected, function (data) {
|
|
||||||
if (data.statusCode == "200")
|
|
||||||
loadDataGrid();
|
|
||||||
else {
|
|
||||||
$(this).alertmsg('warn', data.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//自定义的编辑按钮
|
|
||||||
function edit<%=ModuleName%>() {
|
|
||||||
var selected = getSelected('#@_gridId',2);
|
|
||||||
if (selected == null) return;
|
|
||||||
|
|
||||||
$(this).dialog({
|
|
||||||
id: 'editDialog',
|
|
||||||
url: '/<%=ModuleName%>Manager/Add?id=' + selected,
|
|
||||||
title: '编辑',
|
|
||||||
onClose:function() {
|
|
||||||
refresh<%=ModuleName%>Grid();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function refresh<%=ModuleName%>Grid() {
|
|
||||||
$('#@_gridId').datagrid('refresh');
|
|
||||||
// loadDataGrid();
|
|
||||||
}
|
|
||||||
//@@ sourceURL=<%=ModuleName%>ManagerIndex.js
|
|
||||||
</script>
|
|
@ -1,49 +0,0 @@
|
|||||||
<%--
|
|
||||||
Name: 数据访问
|
|
||||||
Author: yubaolee
|
|
||||||
Description:
|
|
||||||
--%>
|
|
||||||
<%@ CodeTemplate Language="C#" Encoding="utf-8" TargetLanguage="C#" Debug="False" Description="数据访问" %>
|
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
|
||||||
<%@ Import Namespace="SchemaExplorer" %>
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenAuth.Domain;
|
|
||||||
using OpenAuth.Domain.Interface;
|
|
||||||
|
|
||||||
namespace OpenAuth.Repository
|
|
||||||
{
|
|
||||||
public class <%=ModuleName%>Repository :BaseRepository<<%=ModuleName%>>, I<%=ModuleName%>Repository
|
|
||||||
{
|
|
||||||
|
|
||||||
public IEnumerable<<%=ModuleName%>> Load<%=ModuleName%>s(int pageindex, int pagesize)
|
|
||||||
{
|
|
||||||
return Context.<%=ModuleName%>s.OrderBy(u => u.Id).Skip((pageindex - 1) * pagesize).Take(pagesize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<<%=ModuleName%>> LoadInOrgs(params int[] orgId)
|
|
||||||
{
|
|
||||||
var result = from <%=ModuleName.ToLower()%> in Context.<%=ModuleName%>s where orgId.Contains(<%=ModuleName.ToLower()%>.Id)
|
|
||||||
select <%=ModuleName.ToLower()%>;
|
|
||||||
return result;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Get<%=ModuleName%>CntInOrgs(params int[] orgIds)
|
|
||||||
{
|
|
||||||
return LoadInOrgs(orgIds).Count();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<<%=ModuleName%>> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using CodeSmith.Engine;
|
|
||||||
using SchemaExplorer;
|
|
||||||
|
|
||||||
namespace Util{
|
|
||||||
public class Tools{
|
|
||||||
public static String GetDescription(ColumnSchema column) { //得到字段的描述
|
|
||||||
if(string.IsNullOrEmpty(column.Description))
|
|
||||||
return column.Name;
|
|
||||||
else
|
|
||||||
return column.Description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool NeedCascade(TableSchema SourceTable){ //判断表中是否需要下拉选择树
|
|
||||||
return SourceTable.Columns.Contains("ParentId")
|
|
||||||
|| SourceTable.Columns.Contains("CascadeId") ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,251 +0,0 @@
|
|||||||
<%--
|
|
||||||
Name: 编辑修改JS
|
|
||||||
Author: yubaolee
|
|
||||||
Description: 编辑修改JS
|
|
||||||
--%>
|
|
||||||
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Debug="False" Encoding="utf-8" Description="添加模块" %>
|
|
||||||
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context"
|
|
||||||
Description="连接的数据库" %>
|
|
||||||
<%@ Property Name="ModuleName" Type="String" Category="Context" Description="模块名称" %>
|
|
||||||
<%@ Map Name="CSharpAlias" Src="System-CSharpAlias" Description="System to C# Type Map" %>
|
|
||||||
<%@ Assembly Name="SchemaExplorer" %>
|
|
||||||
<%@ Import Namespace="SchemaExplorer" %>
|
|
||||||
<%@ Assembly Src="Util.cs" %>
|
|
||||||
<%@ Import Namespace="Util" %>
|
|
||||||
|
|
||||||
|
|
||||||
//grid列表模块
|
|
||||||
function MainGrid() {
|
|
||||||
var url = '/<%=ModuleName%>/Load?parentId=';
|
|
||||||
var selectedId = 0; //ztree选中的模块
|
|
||||||
this.maingrid = $('#maingrid').datagrid({
|
|
||||||
showToolbar: false,
|
|
||||||
filterThead: false,
|
|
||||||
target: $(this),
|
|
||||||
columns: [
|
|
||||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
|
||||||
{
|
|
||||||
name: '<%=column.Name%>',
|
|
||||||
label: '<%=Tools.GetDescription(column)%>',
|
|
||||||
width: 100
|
|
||||||
<%if(column.IsPrimaryKeyMember){ %>
|
|
||||||
, hide: true
|
|
||||||
<%} %>
|
|
||||||
<%else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
|
||||||
,align: 'center',
|
|
||||||
items: [{ 'false': '否' }, { 'true': '是' }],
|
|
||||||
<%} %>
|
|
||||||
<%else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
|
|
||||||
, align: 'center',
|
|
||||||
items: [{ '0': '默认' }, { '1': '状态1' }],
|
|
||||||
<%} %>
|
|
||||||
},
|
|
||||||
<% } %>
|
|
||||||
],
|
|
||||||
dataUrl: url + selectedId,
|
|
||||||
fullGrid: true,
|
|
||||||
showLinenumber: true,
|
|
||||||
showCheckboxcol: true,
|
|
||||||
paging: true,
|
|
||||||
filterMult: false,
|
|
||||||
showTfoot: false,
|
|
||||||
height: '100%'
|
|
||||||
});
|
|
||||||
this.reload = function (id) {
|
|
||||||
if (id != undefined) selectedId = id;
|
|
||||||
this.maingrid.datagrid('reload', { dataUrl: url+ selectedId });
|
|
||||||
};
|
|
||||||
};
|
|
||||||
MainGrid.prototype = new Grid();
|
|
||||||
var list = new MainGrid();
|
|
||||||
|
|
||||||
//左边分类导航树
|
|
||||||
var ztree = function () {
|
|
||||||
var url = '/<%=ModuleName%>/LoadForTree';
|
|
||||||
var setting = {
|
|
||||||
view: { selectedMulti: false },
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: { onClick: zTreeOnClick }
|
|
||||||
};
|
|
||||||
$.getJSON(url, function (json) {
|
|
||||||
$.fn.zTree.init($("#tree"), setting, json).expandAll(true);
|
|
||||||
});
|
|
||||||
function zTreeOnClick(event, treeId, treeNode) {
|
|
||||||
list.reload(treeNode.Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
reload:function() {
|
|
||||||
$.getJSON(url, function (json) {
|
|
||||||
$.fn.zTree.init($("#tree"), setting, json).expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}();
|
|
||||||
|
|
||||||
<%if(Tools.NeedCascade(SourceTable)){ %>
|
|
||||||
//编辑时,选择上级弹出的树
|
|
||||||
var parentTree = function () {
|
|
||||||
var nameDom = "#ParentName";
|
|
||||||
var idDom = "#ParentId";
|
|
||||||
var zTreeObj;
|
|
||||||
var setting = {
|
|
||||||
view: {
|
|
||||||
selectedMulti: false
|
|
||||||
},
|
|
||||||
check: {
|
|
||||||
enable: true,
|
|
||||||
chkStyle: "radio", //单选
|
|
||||||
radioType: "all"
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function zTreeCheck(event, treeId, treeNode) {
|
|
||||||
var nodes = zTreeObj.getCheckedNodes(true);
|
|
||||||
var ids = nodes.map(function (e) { return e.Id; }).join(",");
|
|
||||||
var names = nodes.map(function (e) { return e.Name; }).join(",");
|
|
||||||
|
|
||||||
$(nameDom).val(names);
|
|
||||||
$(idDom).val(ids);
|
|
||||||
}
|
|
||||||
function zTreeOnClick(event, treeId, treeNode) {
|
|
||||||
zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
show:function() {
|
|
||||||
$.getJSON('/<%=ModuleName%>/LoadForTree', function (json) {
|
|
||||||
zTreeObj = $.fn.zTree.init($('#j_select_tree1'), setting, json);
|
|
||||||
var orgstr = $(idDom).val();
|
|
||||||
var name = '';
|
|
||||||
if (orgstr != '') {
|
|
||||||
var nodeIds = orgstr.split(',');
|
|
||||||
$.each(nodeIds, function () {
|
|
||||||
var node = zTreeObj.getNodeByParam("Id", this, null);
|
|
||||||
name += ',' + node.Name;
|
|
||||||
zTreeObj.checkNode(node, true, true);
|
|
||||||
});
|
|
||||||
$(nameDom).val(name.substr(1)); //显示名称
|
|
||||||
}
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
<%} %>
|
|
||||||
|
|
||||||
//添加(编辑)对话框
|
|
||||||
var editDlg = function () {
|
|
||||||
var update = false;
|
|
||||||
var show = function () {
|
|
||||||
BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' });
|
|
||||||
$("#btnSave").on("click", function() {
|
|
||||||
editDlg.save();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
add: function () { //弹出添加
|
|
||||||
update = false;
|
|
||||||
show();
|
|
||||||
$.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用
|
|
||||||
$("#Id").val(0);
|
|
||||||
|
|
||||||
<%if(Tools.NeedCascade(SourceTable)){
|
|
||||||
Response.WriteLine("parentTree.show();");
|
|
||||||
}%>
|
|
||||||
},
|
|
||||||
update: function (ret) { //弹出编辑框
|
|
||||||
update = true;
|
|
||||||
show();
|
|
||||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) { %>
|
|
||||||
<%if(column.IsPrimaryKeyMember){%>
|
|
||||||
$('#<%=column.Name%>').val(ret.<%=column.Name%>);
|
|
||||||
<%}else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
|
||||||
$('#<%=column.Name%>').selectpicker('val', ret.<%=column.Name%>?"true":"false");
|
|
||||||
<%}else if(CSharpAlias[column.SystemType.FullName] == "int") {%>
|
|
||||||
$('#<%=column.Name%>').selectpicker('val', ret.<%=column.Name%>);
|
|
||||||
<%} else{ %>
|
|
||||||
$('#<%=column.Name%>').val(ret.<%=column.Name%>);
|
|
||||||
<%} %>
|
|
||||||
<% } %>
|
|
||||||
<%if(Tools.NeedCascade(SourceTable)){
|
|
||||||
Response.WriteLine("parentTree.show();");
|
|
||||||
}%>
|
|
||||||
},
|
|
||||||
save: function() { //编辑-->保存
|
|
||||||
$('#editForm').isValid(function (v) {
|
|
||||||
if (!v) return; //验证没通过
|
|
||||||
$("#editForm").bjuiajax('ajaxForm', {
|
|
||||||
reload: false,
|
|
||||||
callback:function(json) {
|
|
||||||
list.reload();
|
|
||||||
ztree.reload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
|
|
||||||
//删除
|
|
||||||
function del() {
|
|
||||||
var selected = list.getSelectedObj();
|
|
||||||
if (selected == null) return;
|
|
||||||
|
|
||||||
$.getJSON('/<%=ModuleName%>/Delete?Id=' + selected.Id, function (data) {
|
|
||||||
if (data.statusCode == "200") {
|
|
||||||
list.reload();
|
|
||||||
ztree.reload();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$(this).alertmsg('warn', data.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//自定义的编辑按钮
|
|
||||||
function edit() {
|
|
||||||
var selected = list.getSelectedObj();
|
|
||||||
if (selected == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
editDlg.update(selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
function add() {
|
|
||||||
editDlg.add();
|
|
||||||
}
|
|
||||||
|
|
||||||
function refresh() {
|
|
||||||
list.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
//@@ sourceURL=<%=ModuleName%>.js
|
|
Loading…
Reference in New Issue
Block a user