From 423fa4001ba51c1562528160781df9a53bf7e247 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Fri, 16 Aug 2024 09:54:06 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9T4=E6=A8=A1=E6=9D=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
IRaCIS.Core.Test/IRaCIS.Core.Test.csproj | 11 +++----
.../TT_Template/IRaCIS.Core.Dto.tt | 24 ++++++++-------
.../TT_Template/IRaCIS.Core.Entity.cs | 2 +-
.../TT_Template/IRaCIS.Core.Entity.tt | 30 ++++++++-----------
4 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
index dae984eb7..2d9915d1d 100644
--- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
+++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj
@@ -77,11 +77,6 @@
True
IRaCIS.Core.Dto.tt
-
- True
- True
- IRaCIS.Core.Entity.tt
-
True
True
@@ -102,12 +97,18 @@
True
IRaCIS.Core.Services.tt
+
+ True
+ True
+ IRaCIS.Core.Entity.tt
+
+
diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.tt b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.tt
index bf59c18a7..128807500 100644
--- a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.tt
+++ b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Dto.tt
@@ -42,30 +42,34 @@ using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
namespace IRaCIS.Core.Application.ViewModel
{
- /// <#=tableName#>View 列表视图模型
- public class <#=tableName#>View
+ <# var excludedColumns = new[] { "CreateUserId", "UpdateUserId", "CreateTime", "UpdateTime" };#>
+
+ /// <#=tableName#>View 列表视图
+ public class <#=tableName#>View:<#=tableName#>AddOrEdit
{
<# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){#>
+ <# if (excludedColumns.Contains(column.ColumnName)){ #>
public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
+ <# }#>
<# }#>
}
- ///<#=tableName#>Query 列表查询参数模型
+ ///<#=tableName#>Query 列表查询参数
public class <#=tableName#>Query
{
- <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){#><# if(column.CSharpType=="string"){#>
- /// <#= column.Remark == "" ? column.ColumnName : column.Remark.Replace("\r\n","") #>
- public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
-
- <# }#>
- <# }#>
+ <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){#><# if(column.CSharpType=="string"){#>
+ public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
+ <# }#>
+ <# }#>
}
- /// <#=tableName#>AddOrEdit 列表查询参数模型
+ /// <#=tableName#>AddOrEdit 添加编辑
public class <#=tableName#>AddOrEdit
{
<# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){#>
+ <# if (!excludedColumns.Contains(column.ColumnName)){ #>
public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
+ <#}#>
<# }#>
}
diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs
index 171fad3cb..b28b04f64 100644
--- a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs
+++ b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.cs
@@ -1,3 +1,3 @@
-
+
diff --git a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt
index c15229ffb..248a2d82a 100644
--- a/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt
+++ b/IRaCIS.Core.Test/TT_Template/IRaCIS.Core.Entity.tt
@@ -1,4 +1,4 @@
-<#@ template debug="false" hostspecific="true" language="C#" #>
+<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".cs" #>
<#@ assembly name="System.Core.dll" #>
<#@ assembly name="System.Data.dll" #>
@@ -27,13 +27,13 @@
<# foreach (var item in DbHelper.GetDbTablesNew(config.ConnectionString, config.DbDatabase,config.TableName))
{
var tableName=item.ToString();
- manager.StartBlock(tableName+".cs",OutputPath1);//文件名
+ manager.StartBlock(tableName+".cs",OutputPath1);//ļ
#>
//--------------------------------------------------------------------
-// 此代码由T4模板自动生成 byzhouhang 20210918
-// 生成时间 <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#>
-// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
+// ˴T4ģԶ byzhouhang 20210918
+// ʱ <#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#>
+// ԴļĸĿܻᵼ²ȷΪɴ룬ЩĽᶪʧ
using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
@@ -44,19 +44,15 @@ namespace IRaCIS.Core.Domain.Models
///<#=tableName#>
///
[Table("<#=tableName#>")]
- public class <#=tableName#> : Entity, IAuditUpdate, IAuditAdd
+ public class <#=tableName#> : BaseFullAuditEntity
{
- <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){#>
-
- ///
- /// <#= column.Remark == "" ? column.ColumnName : column.Remark.Replace("\r\n"," ") #>
- ///
- <#
- if(column.IsPrimaryKey)
- {#>[Key]
- <#}#><# if(!column.IsNullable) {#>[Required]
- <# }#>public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
- <#}#>
+ <# var excludedColumns = new[] { "CreateUserId", "Id", "UpdateUserId", "CreateTime", "UpdateTime", "DeleteUserId", "IsDeleted", "DeletedTime" };#>
+ <# foreach(DbColumn column in DbHelper.GetDbColumns(config.ConnectionString, config.DbDatabase, tableName)){ #>
+ <# if (!excludedColumns.Contains(column.ColumnName)){ #>
+ /// <#= column.Remark == "" ? column.ColumnName : column.Remark.Replace("\r\n"," ") #>
+ public <#= column.CSharpType#><# if(column.CommonType.IsValueType && column.IsNullable){#>?<#}#> <#=column.ColumnName#> { get; set; }
+ <#}#>
+ <#}#>
}
public virtual DbSet<<#=tableName#>> <#=tableName#> { get; set; }