Skip to content

Commit acf8dc2

Browse files
authored
Merge pull request #70 from xiangxiren/dotnet6
java模板报错修改。C#模板优化。
2 parents 4e142b4 + b15b2ca commit acf8dc2

44 files changed

Lines changed: 194 additions & 233 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/SmartCode.Generator/RazorTemplates/CSharp/SqlMap-Partials/CURD/SqlMap-IsExist.cshtml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
<Statement Id="IsExist">
1010
Select Count(1) From @table.Name T
1111
<Include RefId="QueryParams" />
12-
</Statement>
13-
12+
</Statement>

‎src/SmartCode.Generator/RazorTemplates/CSharp/SqlMap-Partials/CURD/SqlMap-QueryByPage.cshtml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121

2222
<!--获取分页数据-->
2323
<Statement Id="QueryByPage" @queryStatementResultMap>
24-
Select
25-
<Include RefId="AllCols"/>
24+
Select
25+
<Include RefId="AllCols" />
2626
From @table.Name As T
2727
<Include RefId="QueryParams" />
2828
<Switch Prepend="Order By" Property="OrderBy">
2929
<Default>
3030
T.@pkCol.Name Desc
3131
</Default>
3232
</Switch>
33-
Limit @(dbPrefix)PageSize Offset @(dbPrefix)Offset
33+
Limit @(dbPrefix)PageSize Offset @(dbPrefix)Offset
3434
</Statement>

‎src/SmartCode.Generator/RazorTemplates/CSharp/SqlMap-Partials/SqlMap-MySql.cshtml‎

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,12 @@
2424
@Include("SqlMap-ResultMaps.cshtml", Model)
2525
<Statements>
2626
@Include("SqlMap-Columns.cshtml", Model)
27-
28-
<Statement Id="QueryParams">
29-
<Where>
30-
@foreach (var col in table.Columns)
31-
{
32-
<IsNotEmpty Prepend="And" Property="@col.ConvertedName">
33-
T.@col.Name = @dbPrefix@col.ConvertedName
34-
</IsNotEmpty>
35-
}
36-
</Where>
37-
</Statement>
27+
@Include("SqlMap-WhereQueryParams.cshtml", Model)
3828
@Include("./CURD/SqlMap-Insert.cshtml", Model)
3929
@Include("./CURD/SqlMap-Delete.cshtml", Model)
4030
@Include("./CURD/SqlMap-Update.cshtml", Model)
4131
@Include("./CURD/SqlMap-Query.cshtml", Model)
42-
43-
<!--获取分页数据-->
44-
<Statement Id="QueryByPage" @(queryStatementResultMap)>
45-
Select
46-
<Include RefId="AllCols" />
47-
From @table.Name As T
48-
<Include RefId="QueryParams" />
49-
<Switch Prepend="Order By" Property="OrderBy">
50-
<Default>
51-
T.@pkCol.Name Desc
52-
</Default>
53-
</Switch>
54-
Limit @(dbPrefix)Offset,@(dbPrefix)PageSize
55-
</Statement>
32+
@Include("./CURD/SqlMap-QueryByPage.cshtml", Model)
5633
@Include("./CURD/SqlMap-GetRecord.cshtml", Model)
5734
@Include("./CURD/SqlMap-GetEntity.cshtml", Model)
5835
@Include("./CURD/SqlMap-IsExist.cshtml", Model)

‎src/SmartCode.Generator/RazorTemplates/CSharp/SqlMap-Partials/SqlMap-Oracle.cshtml‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,7 @@
2424
@Include("SqlMap-ResultMaps.cshtml", Model)
2525
<Statements>
2626
@Include("SqlMap-Columns.cshtml", Model)
27-
28-
<Statement Id="QueryParams">
29-
<Where>
30-
@foreach (var col in table.Columns)
31-
{
32-
<IsNotEmpty Prepend="And" Property="@col.ConvertedName">
33-
T.@col.Name = @dbPrefix@col.ConvertedName
34-
</IsNotEmpty>
35-
}
36-
</Where>
37-
</Statement>
27+
@Include("SqlMap-WhereQueryParams.cshtml", Model)
3828
@Include("./CURD/SqlMap-Insert.cshtml", Model)
3929
@Include("./CURD/SqlMap-Delete.cshtml", Model)
4030
@Include("./CURD/SqlMap-Update.cshtml", Model)

‎src/SmartCode.Generator/RazorTemplates/CSharp/SqlMap-Partials/SqlMap-PostgreSql.cshtml‎

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,12 @@
2525
@Include("SqlMap-ResultMaps.cshtml", Model)
2626
<Statements>
2727
@Include("SqlMap-Columns.cshtml", Model)
28-
29-
<Statement Id="QueryParams">
30-
<Where>
31-
@foreach (var col in table.Columns)
32-
{
33-
<IsNotEmpty Prepend="And" Property="@col.ConvertedName">
34-
T.@col.Name = @dbPrefix@col.ConvertedName
35-
</IsNotEmpty>
36-
}
37-
</Where>
38-
</Statement>
28+
@Include("SqlMap-WhereQueryParams.cshtml", Model)
3929
@Include("./CURD/SqlMap-Insert.cshtml", Model)
4030
@Include("./CURD/SqlMap-Delete.cshtml", Model)
4131
@Include("./CURD/SqlMap-Update.cshtml", Model)
4232
@Include("./CURD/SqlMap-Query.cshtml", Model)
43-
44-
<!--获取分页数据-->
45-
<Statement Id="QueryByPage" @queryStatementResultMap>
46-
Select
47-
<Include RefId="AllCols" />
48-
From @table.Name As T
49-
<Include RefId="QueryParams" />
50-
<Switch Prepend="Order By" Property="OrderBy">
51-
<Default>
52-
T.@pkCol.Name Desc
53-
</Default>
54-
</Switch>
55-
Limit @(dbPrefix)PageSize Offset @(dbPrefix)Offset
56-
</Statement>
33+
@Include("./CURD/SqlMap-QueryByPage.cshtml", Model)
5734
@Include("./CURD/SqlMap-GetRecord.cshtml", Model)
5835
@Include("./CURD/SqlMap-GetEntity.cshtml", Model)
5936
@Include("./CURD/SqlMap-IsExist.cshtml", Model)

‎src/SmartCode.Generator/RazorTemplates/CSharp/SqlMap-Partials/SqlMap-SQLite.cshtml‎

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,12 @@
2424
@Include("SqlMap-ResultMaps.cshtml", Model)
2525
<Statements>
2626
@Include("SqlMap-Columns.cshtml", Model)
27-
28-
<Statement Id="QueryParams">
29-
<Where>
30-
@foreach (var col in table.Columns)
31-
{
32-
<IsNotEmpty Prepend="And" Property="@col.ConvertedName">
33-
T.@col.Name = @dbPrefix@col.ConvertedName
34-
</IsNotEmpty>
35-
}
36-
</Where>
37-
</Statement>
27+
@Include("SqlMap-WhereQueryParams.cshtml", Model)
3828
@Include("./CURD/SqlMap-Insert.cshtml", Model)
3929
@Include("./CURD/SqlMap-Delete.cshtml", Model)
4030
@Include("./CURD/SqlMap-Update.cshtml", Model)
4131
@Include("./CURD/SqlMap-Query.cshtml", Model)
42-
43-
<!--获取分页数据-->
44-
<Statement Id="QueryByPage" @queryStatementResultMap>
45-
Select
46-
<Include RefId="AllCols" />
47-
From @table.Name As T
48-
<Include RefId="QueryParams" />
49-
<Switch Prepend="Order By" Property="OrderBy">
50-
<Default>
51-
T.@pkCol.Name Desc
52-
</Default>
53-
</Switch>
54-
Limit @(dbPrefix)PageSize Offset @(dbPrefix)Offset
55-
</Statement>
32+
@Include("./CURD/SqlMap-QueryByPage.cshtml", Model)
5633
@Include("./CURD/SqlMap-GetRecord.cshtml", Model)
5734
@Include("./CURD/SqlMap-GetEntity.cshtml", Model)
5835
@Include("./CURD/SqlMap-IsExist.cshtml", Model)

‎src/SmartCode.Generator/RazorTemplates/CSharp/SqlMap-Partials/SqlMap-SqlServer.cshtml‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,7 @@
3434
@Include("SqlMap-ResultMaps.cshtml", Model)
3535
<Statements>
3636
@Include("SqlMap-Columns.cshtml", Model)
37-
38-
<Statement Id="QueryParams">
39-
<Where>
40-
@foreach (var col in table.Columns)
41-
{
42-
<IsNotEmpty Prepend="And" Property="@col.ConvertedName">
43-
T.@col.Name = @dbPrefix@col.ConvertedName
44-
</IsNotEmpty>
45-
}
46-
</Where>
47-
</Statement>
37+
@Include("SqlMap-WhereQueryParams.cshtml", Model)
4838
@Include("./CURD/SqlMap-Insert.cshtml", Model)
4939
@Include("./CURD/SqlMap-Delete.cshtml", Model)
5040
@Include("./CURD/SqlMap-Update.cshtml", Model)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@using SmartCode
2+
@using SmartCode.Db
3+
@inherits SmartCode.TemplateEngine.Impl.RazorCoreTemplate<BuildContext>
4+
@{
5+
var dbSource = Model.GetDataSource<DbSource>();
6+
var table = Model.GetCurrentTable();
7+
var dbPrefix = dbSource.DbProvider.ParameterPrefix;
8+
}
9+
10+
<Statement Id="QueryParams">
11+
<Where>
12+
@foreach (var col in table.Columns)
13+
{
14+
<IsNotEmpty Prepend="And" Property="@col.ConvertedName">
15+
T.@col.Name = @dbPrefix@col.ConvertedName
16+
</IsNotEmpty>
17+
}
18+
</Where>
19+
</Statement>

‎src/SmartCode.Generator/RazorTemplates/ETL/ToMysqlTable.cshtml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
@using SmartCode
1+
@using System
2+
@using System.Collections.Generic
3+
@using System.Linq
4+
@using SmartCode
25
@using SmartCode.Db
3-
@model BuildContext
6+
@inherits SmartCode.TemplateEngine.Impl.RazorCoreTemplate<BuildContext>
47
@{
58
var project = Model.Project;
69
var dbSource = Model.GetDataSource<DbSource>();
@@ -63,7 +66,7 @@ DataSource:
6366
AutoIncrement: @(PKColumn.AutoIncrement ? "true" : "false")
6467
@if (!String.IsNullOrEmpty(modifyTime))
6568
{
66-
<text>@Html.PadLeft(4)ModifyTime: @modifyTime</text>
69+
<text>@PadLeft(4)ModifyTime: @modifyTime</text>
6770
}
6871

6972

@@ -113,6 +116,6 @@ Build:
113116
<text>{Column: @col.Name,Mapping: @col.ConvertedName}</text>
114117
if (colIndex < table.Columns.Count() - 1)
115118
{@(",")}
116-
@Html.NewLine()
119+
@NewLine()
117120
}
118121
]

‎src/SmartCode.Generator/RazorTemplates/ETL/ToPGBuild.cshtml‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
@using SmartCode
1+
@using System
2+
@using System.Collections.Generic
3+
@using System.Linq
4+
@using SmartCode
25
@using SmartCode.Db
3-
@model BuildContext
6+
@inherits SmartCode.TemplateEngine.Impl.RazorCoreTemplate<BuildContext>
47
@{
58
var project = Model.Project;
69
var dbSource = Model.GetDataSource<DbSource>();
@@ -59,7 +62,7 @@ DataSource:
5962
AutoIncrement: @(PKColumn.AutoIncrement ? "true" : "false")
6063
@if (!String.IsNullOrEmpty(modifyTime))
6164
{
62-
<text>@Html.PadLeft(4)ModifyTime: @modifyTime</text>
65+
<text>@PadLeft(4)ModifyTime: @modifyTime</text>
6366
}
6467

6568

@@ -107,6 +110,6 @@ Build:
107110
<text>{Column: @col.Name,Mapping: @col.ConvertedName}</text>
108111
if (colIndex < table.Columns.Count() - 1)
109112
{@(",")}
110-
@Html.NewLine()
113+
@NewLine()
111114
}
112115
]

0 commit comments

Comments
 (0)