mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 10:08:04 +08:00
转移.net core 3.1,为.NET 5做准备
This commit is contained in:
@@ -1,53 +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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.App.SSO;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class <%=ModuleName%>App : BaseApp<<%=ModuleName%>>
|
||||
{
|
||||
public RevelanceManagerApp ReleManagerApp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public TableData Load(Query<%=ModuleName%>ListReq request)
|
||||
{
|
||||
return new TableData
|
||||
{
|
||||
count = Repository.GetCount(null),
|
||||
data = Repository.Find(request.page, request.limit, "Id desc")
|
||||
};
|
||||
}
|
||||
|
||||
public void Add(<%=ModuleName%> obj)
|
||||
{
|
||||
Repository.Add(obj);
|
||||
}
|
||||
|
||||
public void Update(<%=ModuleName%> obj)
|
||||
{
|
||||
UnitWork.Update<<%=ModuleName%>>(u => u.Id == obj.Id, u => new <%=ModuleName%>
|
||||
{
|
||||
//todo:要修改的字段赋值
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -10,34 +10,39 @@ Description: Create a list of properties from a database table
|
||||
<%@ Import Namespace="SchemaExplorer" %>
|
||||
|
||||
using System;
|
||||
using System.Web.Http;
|
||||
using System.Web.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Mvc.Models;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
public class <%=ModuleName%>sController : BaseController
|
||||
{
|
||||
public <%=ModuleName%>App App { get; set; }
|
||||
private readonly <%=ModuleName%>App _app;
|
||||
|
||||
//
|
||||
[Authenticate]
|
||||
public <%=ModuleName%>sController(<%=ModuleName%>App app, IAuth auth) : base(auth)
|
||||
{
|
||||
_app = app;
|
||||
}
|
||||
|
||||
//主页
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
//添加或修改
|
||||
[System.Web.Mvc.HttpPost]
|
||||
[HttpPost]
|
||||
public string Add(<%=ModuleName%> obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
App.Add(obj);
|
||||
_app.Add(obj);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -49,12 +54,12 @@ namespace OpenAuth.Mvc.Controllers
|
||||
}
|
||||
|
||||
//添加或修改
|
||||
[System.Web.Mvc.HttpPost]
|
||||
[HttpPost]
|
||||
public string Update(<%=ModuleName%> obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
App.Update(obj);
|
||||
_app.Update(obj);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -68,17 +73,17 @@ namespace OpenAuth.Mvc.Controllers
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public string Load([FromUri]Query<%=ModuleName%>ListReq request)
|
||||
public string Load([FromQuery]Query<%=ModuleName%>ListReq request)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(App.Load(request));
|
||||
return JsonHelper.Instance.Serialize(_app.Load(request));
|
||||
}
|
||||
|
||||
[System.Web.Mvc.HttpPost]
|
||||
[HttpPost]
|
||||
public string Delete(string[] ids)
|
||||
{
|
||||
try
|
||||
{
|
||||
App.Delete(ids);
|
||||
_app.Delete(ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -21,45 +21,34 @@ Description="连接的数据库" %>
|
||||
<blockquote class="layui-elem-quote news_search toolList" id="menus">
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs2">
|
||||
<ul id="tree" class="ztree"
|
||||
style="padding: 2px; border: 1px solid #ddd; overflow: auto;">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="layui-col-xs10">
|
||||
<table class="layui-table"
|
||||
lay-data="{height: 'full-80', page:true, id:'mainList'}"
|
||||
lay-filter="list" lay-size="sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th lay-data="{checkbox:true, fixed: true}"></th>
|
||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) {%>
|
||||
<th lay-data="{field:'<%=column.Name%>', width:150}"><%=Tools.GetDescription(column)%></th>
|
||||
<% }%>
|
||||
<th lay-data="{fixed: 'right', width:160, align:'center', toolbar: '#barList'}"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card">
|
||||
|
||||
<script type="text/html" id="barList">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
|
||||
</script>
|
||||
<table class="layui-table" id="mainList"
|
||||
lay-data="{height: 'full-80', page:true, id:'mainList'}"
|
||||
lay-filter="list" lay-size="sm">
|
||||
</table>
|
||||
|
||||
<script type="text/html" id="Disable">
|
||||
{{# if(d.Disable){ }}
|
||||
<span class="layui-badge">已禁用</span>
|
||||
{{# } else{}}
|
||||
<span class="layui-badge layui-bg-green">正常</span>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<!--添加/编辑窗口-->
|
||||
<div id="divEdit" style="display: none">
|
||||
<form class="layui-form" action="" id="formEdit">
|
||||
<% foreach (ColumnSchema column in this.SourceTable.Columns) {
|
||||
if(column.IsPrimaryKeyMember){%>
|
||||
<input type="hidden" name="<%=column.Name%>" v-model="<%=column.Name%>" />
|
||||
<input type="hidden" name="<%=column.Name%>" v-model="tmp.<%=column.Name%>" />
|
||||
<%}else if(CSharpAlias[column.SystemType.FullName] == "bool") {%>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="<%=column.Name%>" v-model="<%=column.Name%>" lay-skin="switch" value="1">
|
||||
<input type="checkbox" name="<%=column.Name%>" v-model="tmp.<%=column.Name%>" lay-skin="switch" value="1">
|
||||
</div>
|
||||
</div>
|
||||
<%}else if(CSharpAlias[column.SystemType.FullName] == "int" ) {%>
|
||||
@@ -74,7 +63,7 @@ Description="连接的数据库" %>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><%=Tools.GetDescription(column)%></label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="<%=column.Name%>" v-model="<%=column.Name%>" required lay-verify="required"
|
||||
<input type="text" name="<%=column.Name%>" v-model="tmp.<%=column.Name%>" required lay-verify="required"
|
||||
placeholder="<%=Tools.GetDescription(column)%>" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
@@ -104,6 +93,6 @@ Description="连接的数据库" %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/userJs/<%=ModuleName%>s.js"></script>
|
||||
<script type="text/javascript" src="/userJs/<%=ModuleName.ToLower()%>s.js"></script>
|
||||
|
||||
|
||||
|
@@ -1,17 +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" %>
|
||||
namespace OpenAuth.App.Request
|
||||
{
|
||||
public class Query<%=ModuleName%>ListReq : PageReq
|
||||
{
|
||||
public string orgId { get; set; }
|
||||
}
|
||||
}
|
@@ -13,73 +13,63 @@ Author: yubaolee
|
||||
|
||||
layui.config({
|
||||
base: "/js/"
|
||||
}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth', 'utils'], function () {
|
||||
}).use(['form', 'vue', 'ztree', 'layer', 'jquery', 'table', 'droptree', 'openauth', 'utils'], function () {
|
||||
var form = layui.form,
|
||||
layer = layui.layer,
|
||||
$ = layui.jquery;
|
||||
var table = layui.table;
|
||||
var openauth = layui.openauth;
|
||||
var toplayer = (top == undefined || top.layer === undefined) ? layer : top.layer; //顶层的LAYER
|
||||
layui.droptree("/UserSession/GetOrgs", "#Organizations", "#OrganizationIds");
|
||||
|
||||
$("#menus").loadMenus("<%=ModuleName%>");
|
||||
|
||||
|
||||
|
||||
//加载表头
|
||||
$.getJSON('/<%=ModuleName%>s/Load',
|
||||
{ page: 1, limit: 1 },
|
||||
function (data) {
|
||||
var columns = data.columnHeaders.map(function (e) {
|
||||
return {
|
||||
field: e.Key,
|
||||
title: e.Description
|
||||
};
|
||||
});
|
||||
columns.unshift({
|
||||
type: 'checkbox',
|
||||
fixed: 'left'
|
||||
});
|
||||
table.render({
|
||||
elem: '#mainList',
|
||||
page: true,
|
||||
url: '/<%=ModuleName%>s/Load',
|
||||
cols: [columns]
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//主列表加载,可反复调用进行刷新
|
||||
var config= {}; //table的参数,如搜索key,点击tree的id
|
||||
var mainList = function (options) {
|
||||
var config = {}; //table的参数,如搜索key,点击tree的id
|
||||
var mainList = function(options) {
|
||||
if (options != undefined) {
|
||||
$.extend(config, options);
|
||||
}
|
||||
table.reload('mainList', {
|
||||
url: '/<%=ModuleName%>s/Load',
|
||||
where: config
|
||||
});
|
||||
}
|
||||
//左边树状机构列表
|
||||
var ztree = function () {
|
||||
var url = '/UserSession/GetOrgs';
|
||||
var zTreeObj;
|
||||
var setting = {
|
||||
view: { selectedMulti: false },
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: function (event, treeId, treeNode) {
|
||||
mainList({ orgId: treeNode.Id });
|
||||
}
|
||||
}
|
||||
};
|
||||
var load = function () {
|
||||
$.getJSON(url, function (json) {
|
||||
zTreeObj = $.fn.zTree.init($("#tree"), setting);
|
||||
var newNode = { Name: "根节点", Id: null, ParentId: "" };
|
||||
json.push(newNode);
|
||||
zTreeObj.addNodes(null, json);
|
||||
mainList({ orgId: "" });
|
||||
zTreeObj.expandAll(true);
|
||||
table.reload('mainList',
|
||||
{
|
||||
url: '/<%=ModuleName%>s/Load',
|
||||
where: config
|
||||
, response: {
|
||||
statusCode: 200 //规定成功的状态码,默认:0
|
||||
}
|
||||
});
|
||||
};
|
||||
load();
|
||||
return {
|
||||
reload: load
|
||||
}
|
||||
}();
|
||||
|
||||
};
|
||||
mainList();
|
||||
|
||||
//添加(编辑)对话框
|
||||
var editDlg = function() {
|
||||
var vm = new Vue({
|
||||
el: "#formEdit"
|
||||
});
|
||||
var editDlg = function () {
|
||||
var vm;
|
||||
var update = false; //是否为更新
|
||||
var show = function (data) {
|
||||
var title = update ? "编辑信息" : "添加";
|
||||
@@ -88,21 +78,46 @@ layui.config({
|
||||
area: ["500px", "400px"],
|
||||
type: 1,
|
||||
content: $('#divEdit'),
|
||||
success: function() {
|
||||
vm.$set('$data', data);
|
||||
success: function () {
|
||||
if(vm == undefined){
|
||||
vm = new Vue({
|
||||
el: "#formEdit",
|
||||
data(){
|
||||
return {
|
||||
tmp:data //使用一个tmp封装一下,后面可以直接用vm.tmp赋值
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
tmp(val){
|
||||
this.$nextTick(function () {
|
||||
form.render(); //刷新select等
|
||||
layui.droptree("/Applications/GetList", "#AppName", "#AppId", false);
|
||||
|
||||
})
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
form.render();
|
||||
layui.droptree("/Applications/GetList", "#AppName", "#AppId", false);
|
||||
|
||||
}
|
||||
});
|
||||
}else{
|
||||
vm.tmp = Object.assign({}, vm.tmp,data)
|
||||
}
|
||||
},
|
||||
end: mainList
|
||||
});
|
||||
var url = "/<%=ModuleName%>s/Add";
|
||||
if (update) {
|
||||
url = "/<%=ModuleName%>s/Update";
|
||||
url = "/<%=ModuleName%>s/Update";
|
||||
}
|
||||
//提交数据
|
||||
form.on('submit(formSubmit)',
|
||||
function(data) {
|
||||
function (data) {
|
||||
$.post(url,
|
||||
data.field,
|
||||
function(data) {
|
||||
function (data) {
|
||||
layer.msg(data.Message);
|
||||
},
|
||||
"json");
|
||||
@@ -110,25 +125,25 @@ layui.config({
|
||||
});
|
||||
}
|
||||
return {
|
||||
add: function() { //弹出添加
|
||||
add: function () { //弹出添加
|
||||
update = false;
|
||||
show({
|
||||
Id: ''
|
||||
});
|
||||
},
|
||||
update: function(data) { //弹出编辑框
|
||||
update: function (data) { //弹出编辑框
|
||||
update = true;
|
||||
show(data);
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
|
||||
//监听表格内部按钮
|
||||
table.on('tool(list)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'detail') { //查看
|
||||
layer.msg('ID:' + data.Id + ' 的查看操作');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -144,20 +159,20 @@ layui.config({
|
||||
, btnAdd: function () { //添加
|
||||
editDlg.add();
|
||||
}
|
||||
, btnEdit: function () { //编辑
|
||||
var checkStatus = table.checkStatus('mainList')
|
||||
, data = checkStatus.data;
|
||||
if (data.length != 1) {
|
||||
layer.msg("请选择编辑的行,且同时只能编辑一行");
|
||||
return;
|
||||
}
|
||||
editDlg.update(data[0]);
|
||||
}
|
||||
, btnEdit: function () { //编辑
|
||||
var checkStatus = table.checkStatus('mainList')
|
||||
, data = checkStatus.data;
|
||||
if (data.length != 1) {
|
||||
layer.msg("请选择编辑的行,且同时只能编辑一行");
|
||||
return;
|
||||
}
|
||||
editDlg.update(data[0]);
|
||||
}
|
||||
|
||||
, search: function () { //搜索
|
||||
mainList({ key: $('#key').val() });
|
||||
}
|
||||
, btnRefresh: function() {
|
||||
, btnRefresh: function () {
|
||||
mainList();
|
||||
}
|
||||
};
|
||||
@@ -168,4 +183,4 @@ layui.config({
|
||||
});
|
||||
|
||||
//监听页面主按钮操作 end
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user