mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 01:58:01 +08:00
代码生成器增加同步数据结构;
修复sql server 生成float类型; 修复非system用户【代码生成器中找不到xxx的定义】; 修复用户已处理流程列表中看不到【不同意】的流程;
This commit is contained in:
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user