Skip to content

Commit ec13d8a

Browse files
committed
fix #37
1 parent b13797c commit ec13d8a

File tree

13 files changed

+84
-30
lines changed

13 files changed

+84
-30
lines changed

build/version.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor>2</VersionMajor>
44
<VersionMinor>2</VersionMinor>
5-
<VersionPatch>55</VersionPatch>
5+
<VersionPatch>56</VersionPatch>
66
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
77
</PropertyGroup>
88
</Project>

doc/SmartCode-Gen-ETL.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TemplateEngine:
1212
Name: Razor
1313
Root: .
1414
Parameters:
15-
ExtractMode: QueryTime
15+
ExtractMode: LastMaxModifyTime
1616
ModifyTime: ModifyTime
1717
ExtractConnectionString: Data Source=localhost;database=SqlServerDB;uid=SmartSql;pwd=SmartSql
1818
LoadDbProvider: PostgreSql

doc/SmartCode.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Output:
1414
Type: File
1515
Path: 'E:\SmartSql-Starter'
1616
Parameters:
17-
SmartSqlVersion: '4.0.58'
18-
SmartSqlSchemaVersion: '4.0.42'
17+
SmartSqlVersion: '4.0.71'
18+
SmartSqlSchemaVersion: '4.0.65'
1919
BuildDir: 'E:\SmartSql-Starter\build'
2020
DockerImage: 'smartsql.starter'
2121

src/SmartCode.Db/SmartCode.Db.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="SmartSql.Options" Version="4.0.58" />
9-
<PackageReference Include="SmartSql.TypeHandler" Version="4.0.58" />
10-
<PackageReference Include="SmartSql.TypeHandler.PostgreSql" Version="4.0.58" />
8+
<PackageReference Include="SmartSql.Options" Version="4.0.71" />
9+
<PackageReference Include="SmartSql.TypeHandler" Version="4.0.71" />
10+
<PackageReference Include="SmartSql.TypeHandler.PostgreSql" Version="4.0.71" />
1111
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
1212
<PackageReference Include="System.Data.SQLite" Version="1.0.110" />
1313
<PackageReference Include="MySql.Data" Version="8.0.16" />

src/SmartCode.ETL.SQLite/SmartCode.ETL.SQLite.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="System.Data.SQLite" Version="1.0.110" />
8+
<PackageReference Include="System.Data.SQLite" Version="1.0.111" />
99
</ItemGroup>
1010

1111
<ItemGroup>

src/SmartCode.ETL/SmartCode.ETL.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="SmartSql.Bulk.MySql" Version="4.0.58" />
9-
<PackageReference Include="SmartSql.Bulk.PostgreSql" Version="4.0.58" />
10-
<PackageReference Include="SmartSql.Bulk.SqlServer" Version="4.0.58" />
8+
<PackageReference Include="SmartSql.Bulk.MySql" Version="4.0.71" />
9+
<PackageReference Include="SmartSql.Bulk.PostgreSql" Version="4.0.71" />
10+
<PackageReference Include="SmartSql.Bulk.SqlServer" Version="4.0.71" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
namespace SmartCode.Generator.Entity {
2-
3-
public static class ColumnExtensions {
1+
using System;
2+
using System.Text;
43

4+
namespace SmartCode.Generator.Entity
5+
{
6+
public static class ColumnExtensions
7+
{
58
/// <summary>
69
/// 获取列的摘要说明,如果 Description 不为空, 则返回 Description;
710
/// 否则返回 Name + DbType
811
/// </summary>
9-
public static string GetSummary(this Column column) {
10-
if (!string.IsNullOrEmpty(column.Description)) {
12+
public static string GetSummary(this Column column)
13+
{
14+
if (!string.IsNullOrEmpty(column.Description))
15+
{
1116
return column.Description;
1217
}
18+
1319
return column.Name + ", " + column.DbType;
1420
}
1521
}
16-
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Text;
3+
using SmartCode.Generator.Entity;
4+
5+
namespace SmartCode.Generator.Extensions
6+
{
7+
public static class SummaryExtensions
8+
{
9+
public static string GetCSharpSummary(this Column column)
10+
{
11+
var summary = column.GetSummary();
12+
return GetCSharpSummary(summary);
13+
}
14+
15+
public static string GetCSharpSummary(this Table table)
16+
{
17+
var summary = table.GetSummary();
18+
return GetCSharpSummary(summary);
19+
}
20+
public static string GetCSharpSummary(this string summary)
21+
{
22+
StringBuilder csharpSummary = new StringBuilder();
23+
csharpSummary.AppendLine("///<summary>");
24+
if (summary.Contains(Environment.NewLine))
25+
{
26+
foreach (var summaryLine in summary.Split(Environment.NewLine.ToCharArray()))
27+
{
28+
if (String.IsNullOrEmpty(summaryLine))
29+
{
30+
continue;
31+
}
32+
33+
csharpSummary.AppendLine($"/// {summaryLine}");
34+
}
35+
}
36+
else
37+
{
38+
csharpSummary.AppendLine($"/// {summary}");
39+
}
40+
41+
csharpSummary.Append("///</summary>");
42+
return csharpSummary.ToString();
43+
}
44+
}
45+
}

src/SmartCode.Generator/RazorTemplates/CSharp/API/APIController.cshtml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using SmartCode
2+
@using SmartCode.Generator.Extensions
23
@model BuildContext
34
@{
45
Layout = "../_CSharpLayout.cshtml";
@@ -25,6 +26,7 @@ using @(project.Module).API.Messages;
2526

2627
namespace @(project.Module).API.Controllers
2728
{
29+
@table.GetCSharpSummary()
2830
[ApiController]
2931
[Route("[controller]/[action]")]
3032
public class @(table.ConvertedName)Controller : Controller

src/SmartCode.Generator/RazorTemplates/CSharp/API/LaunchSettings.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"environmentVariables": {
1414
"ASPNETCORE_ENVIRONMENT": "Development"
1515
},
16-
"applicationUrl": "http://localhost:8088/"
16+
"applicationUrl": "http://localhost:8088"
1717
}
1818
}
1919
}

src/SmartCode.Generator/RazorTemplates/CSharp/Entity.cshtml

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using SmartCode
2+
@using SmartCode.Generator.Extensions
23
@model BuildContext
34
@{
45
Layout = "_CSharpLayout.cshtml";
@@ -31,21 +32,17 @@ public string ConvertLangType(SmartCode.Generator.Entity.Column column)
3132
using System;
3233
namespace @(project.Module).@buildTask.Module
3334
{
34-
@Html.PadLeft(4)@("///<summary>")
35-
@Html.PadLeft(4)@($"///{table.Description ?? table.ConvertedName}")
36-
@Html.PadLeft(4)@("///</summary>")
35+
36+
@table.GetCSharpSummary()
3737
public class @table.ConvertedName
3838
{
3939
@foreach (var column in table.Columns)
4040
{
41-
@Html.PadLeft(8)@("///<summary>")
42-
@Html.PadLeft(8)@Html.NewLine()
43-
@Html.PadLeft(8)@($"///{column.Description ?? column.ConvertedName}")
44-
@Html.PadLeft(8)@Html.NewLine()
45-
@Html.PadLeft(8)@("///</summary>")
46-
@Html.PadLeft(8)@Html.NewLine()
47-
@Html.PadLeft(8)<text>public</text> <text>@(ConvertLangType(column))</text> <text>@column.ConvertedName</text> <text>{ get; set; }</text>
48-
@Html.PadLeft(8)@Html.NewLine()
41+
42+
@column.GetCSharpSummary()
43+
@Html.NewLine()
44+
<text>public</text> <text>@(ConvertLangType(column))</text> <text>@column.ConvertedName</text> <text>{ get; set; }</text>
45+
@Html.NewLine()
4946
}
5047
}
5148
}

src/SmartCode.Generator/RazorTemplates/CSharp/Repository.cshtml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@using SmartCode
22
@using SmartCode.Db;
3+
@using SmartCode.Generator.Extensions
34
@model BuildContext
45
@{
56
Layout = "_CSharpLayout.cshtml";
@@ -29,6 +30,7 @@ using @(project.Module).Entity;
2930

3031
namespace @(project.Module).@buildTask.Module
3132
{
33+
@table.GetCSharpSummary()
3234
public interface I@(table.ConvertedName)Repository : IRepository<@(table.ConvertedName), @(primaryKeyType)>
3335
,IRepositoryAsync<@(table.ConvertedName), @(primaryKeyType)>
3436
{

src/SmartCode.Generator/RazorTemplates/CSharp/Service.cshtml

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using SmartCode
2+
@using SmartCode.Generator.Extensions
23
@model BuildContext
34
@{
45
Layout = "_CSharpLayout.cshtml";
@@ -25,6 +26,7 @@ using @(project.Module).Repository;
2526

2627
namespace @(project.Module).Service
2728
{
29+
@table.GetCSharpSummary()
2830
public class @serviceName
2931
{
3032
public I@(repositoryName) @repositoryName { get; }

0 commit comments

Comments
 (0)