115 lines
3.2 KiB
Plaintext
115 lines
3.2 KiB
Plaintext
@model GenDbTableDto
|
|
@{
|
|
var className = Model.EntityName;
|
|
var classNameRemark = Model.DisplayName;
|
|
|
|
var ignores = new string[] {
|
|
"Id",
|
|
"CreationTime",
|
|
"CreatorUserId",
|
|
"LastModificationTime",
|
|
"LastModifierUserId" ,
|
|
"DeletionTime",
|
|
"DeleterUserId",
|
|
"IsDeleted",
|
|
"TenantId",
|
|
};
|
|
|
|
var tableInfos = Model.TableInfos
|
|
.Where(w => !ignores.Contains(w.ColumnName))
|
|
.OrderBy(w => w.Position)
|
|
.ToList()
|
|
;
|
|
}
|
|
|
|
@functions
|
|
{
|
|
//获取类型 根据 appTableInfo
|
|
string GetType(DbColumnInfo appTableInfo)
|
|
{
|
|
switch (appTableInfo.DbTypeText)
|
|
{
|
|
case "uniqueidentifier":
|
|
return appTableInfo.IsPrimary ? "Guid" : "Guid?";
|
|
case "bit":
|
|
case "int":
|
|
return appTableInfo.IsPrimary ? "int" : "int?";
|
|
case "datetime":
|
|
return appTableInfo.IsNullable ? "DateTime?" : "DateTime";
|
|
case "float":
|
|
case "money":
|
|
return appTableInfo.IsNullable ? "double?" : "double";
|
|
case "decimal":
|
|
return appTableInfo.IsNullable ? "decimal?" : "decimal";
|
|
default:
|
|
return appTableInfo.IsNullable ? appTableInfo.CsType.Name + "?" : appTableInfo.CsType.Name;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取类型 根据 appTableInfo
|
|
/// </summary>
|
|
/// <param name="appTableInfo"></param>
|
|
/// <returns></returns>
|
|
string GetTypeNew(LowCodeTableInfo appTableInfo)
|
|
{
|
|
if (appTableInfo.CsType.ToLower() == "string")
|
|
{
|
|
return "string?";
|
|
}
|
|
|
|
return appTableInfo.IsNullable ? $"{appTableInfo.CsType}?" : appTableInfo.CsType;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取 id 组件所对应的类型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
string GetIdType()
|
|
{
|
|
var lowCodeTableInfo = Model.TableInfos.Where(w => w.ColumnName == "Id")?.FirstOrDefault();
|
|
|
|
if (Model.DataBase == "MiaoYuChat")
|
|
{
|
|
return "DefaultEntityV4";
|
|
}
|
|
if (lowCodeTableInfo == null) return "DefaultEntity";
|
|
|
|
if (lowCodeTableInfo.CsType.ToLower().Contains("string"))
|
|
return "DefaultEntityStringKey";
|
|
|
|
if (lowCodeTableInfo.CsType.ToLower().Contains("int"))
|
|
return "DefaultEntityIdentityIntKey";
|
|
|
|
if (lowCodeTableInfo.CsType.ToLower().Contains("guid"))
|
|
return "DefaultEntity";
|
|
|
|
return "DefaultEntity<" + lowCodeTableInfo.CsType + ">";
|
|
}
|
|
|
|
|
|
}
|
|
|
|
<pre>
|
|
|
|
namespace @(Model.Namespace).@(Model.DataBase == "MiaoYuChat" ? "Repository.ChatAI.Admin.Entities.Apps;" : "Repository.EntityFramework.Admin.Entities.Apps;")
|
|
|
|
/// <summary>
|
|
/// @(string.IsNullOrWhiteSpace(classNameRemark) ? className : classNameRemark)
|
|
/// </summary>
|
|
public class @className : @(GetIdType())
|
|
{
|
|
|
|
@foreach (var item in tableInfos)
|
|
{
|
|
<pre>
|
|
/// <summary>
|
|
/// @(string.IsNullOrWhiteSpace(item.DisplayName) ? item.ColumnName : item.DisplayName) => 备注: @(string.IsNullOrWhiteSpace(item.Describe) ? item.ColumnName : item.Describe)
|
|
/// </summary>
|
|
public @(GetTypeNew(item)) @item.ColumnName { get; set; }
|
|
</pre>
|
|
}
|
|
|
|
}
|
|
|
|
</pre> |