mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-30 04:45:56 +08:00
代码生成器增加同步数据结构;
修复sql server 生成float类型; 修复非system用户【代码生成器中找不到xxx的定义】; 修复用户已处理流程列表中看不到【不同意】的流程;
This commit is contained in:
parent
9fd0405721
commit
c8caf9dee3
@ -15,6 +15,7 @@
|
||||
// ***********************************************************************
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Infrastructure;
|
||||
@ -122,7 +123,18 @@ namespace OpenAuth.App
|
||||
public List<BuilderTableColumn> GetTableColumns(string moduleCode)
|
||||
{
|
||||
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");
|
||||
bool? isSysModule = UnitWork.FirstOrDefault<Module>(u => u.Code == moduleCode)?.IsSys;
|
||||
if (isSysModule!= null && isSysModule.Value)
|
||||
|
@ -61,7 +61,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_webProject))
|
||||
if (!string.IsNullOrEmpty(_webProject))
|
||||
return _webProject;
|
||||
_webProject = ProjectPath.GetLastIndexOfDirectoryName(".WebApi") ??
|
||||
ProjectPath.GetLastIndexOfDirectoryName("Api") ??
|
||||
@ -563,6 +563,7 @@ namespace OpenAuth.App
|
||||
,{"string", typeof(string)}
|
||||
,{"bool", typeof(bool)}
|
||||
,{"byte", typeof(byte)}
|
||||
,{"float", typeof(float)}
|
||||
,{"char", typeof(char)}
|
||||
,{"decimal", typeof(decimal)}
|
||||
,{"double", typeof(double)}
|
||||
|
@ -16,9 +16,12 @@ namespace OpenAuth.App
|
||||
{
|
||||
public class BuilderTableColumnApp : BaseStringApp<BuilderTableColumn,OpenAuthDBContext>
|
||||
{
|
||||
|
||||
private DbExtension _dbExtension;
|
||||
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>
|
||||
@ -81,6 +84,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'
|
||||
WHEN ColumnType IN('smallmoney', 'DECIMAL', 'numeric',
|
||||
'money') THEN 'decimal'
|
||||
WHEN ColumnType = 'float' THEN 'float'
|
||||
WHEN ColumnType = 'float' THEN 'double'
|
||||
ELSE 'string'
|
||||
END as EntityType,
|
||||
ColumnType,
|
||||
|
@ -280,12 +280,15 @@ namespace OpenAuth.App
|
||||
flowInstance.IsFinish = (wfruntime.nextNodeType == 4
|
||||
? FlowInstanceStatus.Finished
|
||||
: FlowInstanceStatus.Running);
|
||||
AddTransHistory(wfruntime);
|
||||
}
|
||||
else
|
||||
{
|
||||
flowInstance.IsFinish = FlowInstanceStatus.Disagree; //表示该节点不同意
|
||||
wfruntime.nextNodeId = "-1";
|
||||
wfruntime.nextNodeType = 4;
|
||||
}
|
||||
|
||||
AddTransHistory(wfruntime);
|
||||
|
||||
flowInstanceOperationHistory.Content = "【" + wfruntime.currentNode.name
|
||||
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")
|
||||
@ -689,7 +692,7 @@ namespace OpenAuth.App
|
||||
FromNodeName = wfruntime.currentNode.name,
|
||||
FromNodeType = wfruntime.currentNodeType,
|
||||
ToNodeId = wfruntime.nextNodeId,
|
||||
ToNodeName = wfruntime.nextNode.name,
|
||||
ToNodeName = wfruntime.nextNode?.name,
|
||||
ToNodeType = wfruntime.nextNodeType,
|
||||
IsFinish = wfruntime.nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
|
||||
TransitionSate = 0
|
||||
|
@ -56,6 +56,28 @@ namespace OpenAuth.WebApi.Controllers
|
||||
|
||||
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>
|
||||
/// 加载列表
|
||||
|
Loading…
Reference in New Issue
Block a user