diff --git a/build/version.props b/build/version.props
index ab16751..29ef071 100644
--- a/build/version.props
+++ b/build/version.props
@@ -2,7 +2,7 @@
2
2
- 50
+ 52
$(VersionMajor).$(VersionMinor).$(VersionPatch)
diff --git a/doc/SmartCode.yml b/doc/SmartCode.yml
index 642fee9..30b5256 100644
--- a/doc/SmartCode.yml
+++ b/doc/SmartCode.yml
@@ -14,7 +14,7 @@ Output:
Type: File
Path: 'E:\SmartSql-Starter'
Parameters:
- SmartSqlVersion: '4.0.56'
+ SmartSqlVersion: '4.0.58'
SmartSqlSchemaVersion: '4.0.42'
BuildDir: 'E:\SmartSql-Starter\build'
DockerImage: 'smartsql.starter'
@@ -44,6 +44,10 @@ NamingConverter:
Delimiter: '_'
Converter:
Type: Pascal
+
+TableFilter:
+ IgnoreNoPKTable: true
+ IgnoreView: true
# 构建任务
Build:
@@ -101,6 +105,8 @@ Build:
Module: Entity
TemplateEngine:
Path: Entity.cshtml
+ IgnoreNoPKTable: false
+ IgnoreView: false
Output:
Path: 'src/{{Project.Module}}.{{Build.Module}}'
Name: '{{Items.CurrentTable.ConvertedName}}'
@@ -111,8 +117,6 @@ Build:
Module: Repository
TemplateEngine:
Path: Repository.cshtml
- IgnoreNoPKTable: true
- IgnoreView: true
Output:
Path: 'src/{{Project.Module}}.{{Build.Module}}'
Name: 'I{{Items.CurrentTable.ConvertedName}}Repository'
@@ -123,8 +127,6 @@ Build:
Module: Service
TemplateEngine:
Path: Service.cshtml
- IgnoreNoPKTable: true
- IgnoreView: true
Output:
Path: 'src/{{Project.Module}}.{{Build.Module}}'
Name: '{{Items.CurrentTable.ConvertedName}}Service'
@@ -135,8 +137,6 @@ Build:
Module: API
TemplateEngine:
Path: API/APIController.cshtml
- IgnoreNoPKTable: true
- IgnoreView: true
Output:
Path: 'src/{{Project.Module}}.{{Build.Module}}/Controllers'
Name: '{{Items.CurrentTable.ConvertedName}}Controller'
@@ -150,8 +150,6 @@ Build:
Path: 'src/{{Project.Module}}.Repository/Maps'
Name: '{{Items.CurrentTable.ConvertedName}}'
Extension: .xml
- IgnoreNoPKTable: true
- IgnoreView: true
# Please install dotnet-format first!
# dotnet tool install -g dotnet-format
diff --git a/src/SmartCode.Generator/BuildTasks/AbstractDbBuildTask.cs b/src/SmartCode.Generator/BuildTasks/AbstractDbBuildTask.cs
index 71826d6..e4c2d5f 100644
--- a/src/SmartCode.Generator/BuildTasks/AbstractDbBuildTask.cs
+++ b/src/SmartCode.Generator/BuildTasks/AbstractDbBuildTask.cs
@@ -34,26 +34,32 @@ protected IList
FilterTable(IEnumerable tables, string buildKey, B
{
_logger.LogInformation($"FilterTable Build:{buildKey} Start!");
IEnumerable buildTables = CopyTables(tables);
- if (build.IgnoreNoPKTable)
+ if (build.IgnoreNoPKTable.HasValue && build.IgnoreNoPKTable.Value)
{
_logger.LogInformation($"FilterTable Build:{buildKey} IgnoreNoPKTable!");
buildTables = buildTables.Where(m => m.PKColumn != null);
}
- if (build.IgnoreView)
+
+ if (build.IgnoreView.HasValue && build.IgnoreView.Value)
{
_logger.LogInformation($"FilterTable Build:{buildKey} IgnoreView!");
buildTables = buildTables.Where(m => m.Type != Table.TableType.View);
}
+
if (build.IgnoreTables != null)
{
- _logger.LogInformation($"FilterTable Build:{buildKey} IgnoreTables: [{String.Join(",", build.IgnoreTables)}]!");
+ _logger.LogInformation(
+ $"FilterTable Build:{buildKey} IgnoreTables: [{String.Join(",", build.IgnoreTables)}]!");
buildTables = buildTables.Where(m => !build.IgnoreTables.Contains(m.Name));
}
+
if (build.IncludeTables != null)
{
- _logger.LogInformation($"FilterTable Build:{buildKey} IncludeTables: [{String.Join(",", build.IncludeTables)}]!");
+ _logger.LogInformation(
+ $"FilterTable Build:{buildKey} IncludeTables: [{String.Join(",", build.IncludeTables)}]!");
buildTables = buildTables.Where(m => build.IncludeTables.Contains(m.Name));
}
+
_logger.LogInformation($"FilterTable Build:{buildKey} End!");
return buildTables.ToList();
}
@@ -83,4 +89,4 @@ protected IList CopyTables(IEnumerable tables)
}).ToList();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/SmartCode/Configuration/Build.cs b/src/SmartCode/Configuration/Build.cs
index 991c8ba..72a75aa 100644
--- a/src/SmartCode/Configuration/Build.cs
+++ b/src/SmartCode/Configuration/Build.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Text;
namespace SmartCode.Configuration
@@ -16,8 +17,8 @@ public class Build
public Output Output { get; set; }
public IEnumerable IncludeTables { get; set; }
public IEnumerable IgnoreTables { get; set; }
- public bool IgnoreNoPKTable { get; set; }
- public bool IgnoreView { get; set; }
+ public bool? IgnoreNoPKTable { get; set; }
+ public bool? IgnoreView { get; set; }
public NamingConverter NamingConverter { get; set; }
///
/// 自定义构建参数
diff --git a/src/SmartCode/Configuration/ConfigBuilders/ConfigBuilder.cs b/src/SmartCode/Configuration/ConfigBuilders/ConfigBuilder.cs
index a0ded4d..3027bb3 100644
--- a/src/SmartCode/Configuration/ConfigBuilders/ConfigBuilder.cs
+++ b/src/SmartCode/Configuration/ConfigBuilders/ConfigBuilder.cs
@@ -88,6 +88,26 @@ protected void InitDefault()
buildTask.NamingConverter.Column = Project.NamingConverter.Column;
}
}
+
+ if (Project.TableFilter != null)
+ {
+ if (buildTask.IgnoreTables == null)
+ {
+ buildTask.IgnoreTables = Project.TableFilter.IgnoreTables;
+ }
+ if (buildTask.IncludeTables == null)
+ {
+ buildTask.IncludeTables = Project.TableFilter.IncludeTables;
+ }
+ if (!buildTask.IgnoreView.HasValue)
+ {
+ buildTask.IgnoreView = Project.TableFilter.IgnoreView;
+ }
+ if (!buildTask.IgnoreNoPKTable.HasValue)
+ {
+ buildTask.IgnoreNoPKTable = Project.TableFilter.IgnoreNoPKTable;
+ }
+ }
}
}
}
diff --git a/src/SmartCode/Configuration/Project.cs b/src/SmartCode/Configuration/Project.cs
index 2dfd07b..87c2d7e 100644
--- a/src/SmartCode/Configuration/Project.cs
+++ b/src/SmartCode/Configuration/Project.cs
@@ -20,5 +20,6 @@ public class Project
public IDictionary BuildTasks { get; set; }
public String OutputPath => Output.Path;
public NamingConverter NamingConverter { get; set; }
+ public TableFilter TableFilter { get; set; }
}
}
diff --git a/src/SmartCode/Configuration/TableFilter.cs b/src/SmartCode/Configuration/TableFilter.cs
new file mode 100644
index 0000000..ca79f5a
--- /dev/null
+++ b/src/SmartCode/Configuration/TableFilter.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace SmartCode.Configuration
+{
+ public class TableFilter
+ {
+ public IEnumerable IncludeTables { get; set; }
+ public IEnumerable IgnoreTables { get; set; }
+ public bool? IgnoreNoPKTable { get; set; }
+ public bool? IgnoreView { get; set; }
+ }
+}
\ No newline at end of file