mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-09 19:04:44 +08:00
代码生成器增加同步数据结构;
修复sql server 生成float类型; 修复非system用户【代码生成器中找不到xxx的定义】; 修复用户已处理流程列表中看不到【不同意】的流程;
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
// ***********************************************************************
|
// ***********************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
@@ -122,6 +123,17 @@ namespace OpenAuth.App
|
|||||||
public List<BuilderTableColumn> GetTableColumns(string moduleCode)
|
public List<BuilderTableColumn> GetTableColumns(string moduleCode)
|
||||||
{
|
{
|
||||||
var allprops = UnitWork.Find<BuilderTableColumn>(u => u.TableName.ToLower() == moduleCode.ToLower());
|
var allprops = UnitWork.Find<BuilderTableColumn>(u => u.TableName.ToLower() == moduleCode.ToLower());
|
||||||
|
//如果是子表,直接返回所有字段
|
||||||
|
var builderTable = UnitWork.FirstOrDefault<BuilderTable>(u => u.TableName.ToLower() == moduleCode.ToLower());
|
||||||
|
if (builderTable == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"代码生成器中找不到{moduleCode.ToLower()}的定义");
|
||||||
|
}
|
||||||
|
//如果是子表,因为不能在模块界面分配,所以直接返回所有字段,后期可以优化。
|
||||||
|
if (builderTable.ParentTableId != null)
|
||||||
|
{
|
||||||
|
return allprops.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
//如果是系统模块,直接返回所有字段。防止开发者把模块配置成系统模块,还在外层调用loginContext.GetProperties("xxxx");
|
//如果是系统模块,直接返回所有字段。防止开发者把模块配置成系统模块,还在外层调用loginContext.GetProperties("xxxx");
|
||||||
bool? isSysModule = UnitWork.FirstOrDefault<Module>(u => u.Code == moduleCode)?.IsSys;
|
bool? isSysModule = UnitWork.FirstOrDefault<Module>(u => u.Code == moduleCode)?.IsSys;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_webProject))
|
if (!string.IsNullOrEmpty(_webProject))
|
||||||
return _webProject;
|
return _webProject;
|
||||||
_webProject = ProjectPath.GetLastIndexOfDirectoryName(".WebApi") ??
|
_webProject = ProjectPath.GetLastIndexOfDirectoryName(".WebApi") ??
|
||||||
ProjectPath.GetLastIndexOfDirectoryName("Api") ??
|
ProjectPath.GetLastIndexOfDirectoryName("Api") ??
|
||||||
@@ -563,6 +563,7 @@ namespace OpenAuth.App
|
|||||||
,{"string", typeof(string)}
|
,{"string", typeof(string)}
|
||||||
,{"bool", typeof(bool)}
|
,{"bool", typeof(bool)}
|
||||||
,{"byte", typeof(byte)}
|
,{"byte", typeof(byte)}
|
||||||
|
,{"float", typeof(float)}
|
||||||
,{"char", typeof(char)}
|
,{"char", typeof(char)}
|
||||||
,{"decimal", typeof(decimal)}
|
,{"decimal", typeof(decimal)}
|
||||||
,{"double", typeof(double)}
|
,{"double", typeof(double)}
|
||||||
|
|||||||
@@ -16,9 +16,12 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
public class BuilderTableColumnApp : BaseStringApp<BuilderTableColumn,OpenAuthDBContext>
|
public class BuilderTableColumnApp : BaseStringApp<BuilderTableColumn,OpenAuthDBContext>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private DbExtension _dbExtension;
|
||||||
public BuilderTableColumnApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<BuilderTableColumn,OpenAuthDBContext> repository,
|
public BuilderTableColumnApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<BuilderTableColumn,OpenAuthDBContext> repository,
|
||||||
IAuth auth) : base(unitWork, repository,auth)
|
IAuth auth, DbExtension dbExtension) : base(unitWork, repository,auth)
|
||||||
{
|
{
|
||||||
|
_dbExtension = dbExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -82,6 +85,48 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步数据结构
|
||||||
|
/// <para>读取数据库结构与当前结构的差异,如果数据库有新增的字段,则自动加入</para>
|
||||||
|
/// </summary>
|
||||||
|
public void Sync(SyncStructureReq req)
|
||||||
|
{
|
||||||
|
var columns = _dbExtension.GetDbTableStructure(req.TableName);
|
||||||
|
if (!columns.Any())
|
||||||
|
{
|
||||||
|
throw new Exception($"未能找到{req.TableName}表结构定义");
|
||||||
|
}
|
||||||
|
|
||||||
|
var exists = Find(req.Id).Select(u=>u.ColumnName);
|
||||||
|
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
if(exists.Contains(column.ColumnName)) continue;
|
||||||
|
var builderColumn = new BuilderTableColumn
|
||||||
|
{
|
||||||
|
ColumnName = column.ColumnName,
|
||||||
|
Comment = column.Comment,
|
||||||
|
ColumnType = column.ColumnType,
|
||||||
|
EntityType = column.EntityType,
|
||||||
|
EntityName = column.ColumnName,
|
||||||
|
|
||||||
|
IsKey = column.IsKey == 1,
|
||||||
|
IsRequired = column.IsNull != 1,
|
||||||
|
IsEdit = true,
|
||||||
|
IsInsert = true,
|
||||||
|
IsList = true,
|
||||||
|
MaxLength = column.MaxLength,
|
||||||
|
TableName = req.TableName,
|
||||||
|
TableId = req.Id,
|
||||||
|
|
||||||
|
CreateTime = DateTime.Now
|
||||||
|
};
|
||||||
|
UnitWork.Add(builderColumn);
|
||||||
|
}
|
||||||
|
UnitWork.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
29
OpenAuth.App/BuilderTable/Request/SyncStructureReq.cs
Normal file
29
OpenAuth.App/BuilderTable/Request/SyncStructureReq.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <autogenerated>
|
||||||
|
// This code was generated by a CodeSmith Template.
|
||||||
|
//
|
||||||
|
// DO NOT MODIFY contents of this file. Changes to this
|
||||||
|
// file will be lost if the code is regenerated.
|
||||||
|
// Author:Yubao Li
|
||||||
|
// </autogenerated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace OpenAuth.App.Request
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 同步表结构
|
||||||
|
/// </summary>
|
||||||
|
public class SyncStructureReq
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id为空则为添加
|
||||||
|
/// </summary>
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 表英文全称
|
||||||
|
/// </summary>
|
||||||
|
public string TableName { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -278,7 +278,7 @@ select utc.column_name as COLUMNNAME,
|
|||||||
THEN 'DateTime'
|
THEN 'DateTime'
|
||||||
WHEN ColumnType IN('smallmoney', 'DECIMAL', 'numeric',
|
WHEN ColumnType IN('smallmoney', 'DECIMAL', 'numeric',
|
||||||
'money') THEN 'decimal'
|
'money') THEN 'decimal'
|
||||||
WHEN ColumnType = 'float' THEN 'float'
|
WHEN ColumnType = 'float' THEN 'double'
|
||||||
ELSE 'string'
|
ELSE 'string'
|
||||||
END as EntityType,
|
END as EntityType,
|
||||||
ColumnType,
|
ColumnType,
|
||||||
|
|||||||
@@ -280,13 +280,16 @@ namespace OpenAuth.App
|
|||||||
flowInstance.IsFinish = (wfruntime.nextNodeType == 4
|
flowInstance.IsFinish = (wfruntime.nextNodeType == 4
|
||||||
? FlowInstanceStatus.Finished
|
? FlowInstanceStatus.Finished
|
||||||
: FlowInstanceStatus.Running);
|
: FlowInstanceStatus.Running);
|
||||||
AddTransHistory(wfruntime);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flowInstance.IsFinish = FlowInstanceStatus.Disagree; //表示该节点不同意
|
flowInstance.IsFinish = FlowInstanceStatus.Disagree; //表示该节点不同意
|
||||||
|
wfruntime.nextNodeId = "-1";
|
||||||
|
wfruntime.nextNodeType = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AddTransHistory(wfruntime);
|
||||||
|
|
||||||
flowInstanceOperationHistory.Content = "【" + wfruntime.currentNode.name
|
flowInstanceOperationHistory.Content = "【" + wfruntime.currentNode.name
|
||||||
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
|
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
|
||||||
+ "】" + (tag.Taged == 1 ? "同意" : "不同意") + ",备注:"
|
+ "】" + (tag.Taged == 1 ? "同意" : "不同意") + ",备注:"
|
||||||
@@ -689,7 +692,7 @@ namespace OpenAuth.App
|
|||||||
FromNodeName = wfruntime.currentNode.name,
|
FromNodeName = wfruntime.currentNode.name,
|
||||||
FromNodeType = wfruntime.currentNodeType,
|
FromNodeType = wfruntime.currentNodeType,
|
||||||
ToNodeId = wfruntime.nextNodeId,
|
ToNodeId = wfruntime.nextNodeId,
|
||||||
ToNodeName = wfruntime.nextNode.name,
|
ToNodeName = wfruntime.nextNode?.name,
|
||||||
ToNodeType = wfruntime.nextNodeType,
|
ToNodeType = wfruntime.nextNodeType,
|
||||||
IsFinish = wfruntime.nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
|
IsFinish = wfruntime.nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
|
||||||
TransitionSate = 0
|
TransitionSate = 0
|
||||||
|
|||||||
@@ -57,6 +57,28 @@ namespace OpenAuth.WebApi.Controllers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 同步数据结构
|
||||||
|
/// <para>读取数据库结构与当前结构的差异,如果数据库有新增的字段,则自动加入</para>
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
public Response Sync(SyncStructureReq obj)
|
||||||
|
{
|
||||||
|
var result = new Response();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_app.Sync(obj);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载列表
|
/// 加载列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user