first commit
This commit is contained in:
110
ZR.CodeGenerator/TableMappingHelper.cs
Normal file
110
ZR.CodeGenerator/TableMappingHelper.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Infrastructure.Extensions;
|
||||
using ZR.Common.Extension;
|
||||
|
||||
namespace ZR.CodeGenerator.CodeGenerator
|
||||
{
|
||||
public class TableMappingHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// UserService转成userService
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
public static string FirstLetterLowercase(string instanceName)
|
||||
{
|
||||
instanceName = instanceName.ParseToString();
|
||||
if (!instanceName.IsEmpty())
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(instanceName[0].ToString().ToLower() + instanceName.Substring(1));
|
||||
return sb.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return instanceName;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sys_menu_authorize变成MenuAuthorize
|
||||
/// </summary>
|
||||
public static string GetClassNamePrefix(string tableName)
|
||||
{
|
||||
string[] arr = tableName.Split('_');
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; i < arr.Length; i++)
|
||||
{
|
||||
sb.Append(arr[i][0].ToString().ToUpper() + arr[i].Substring(1));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string GetPropertyDatatype(string sDatatype)
|
||||
{
|
||||
string sTempDatatype = string.Empty;
|
||||
sDatatype = sDatatype.ToLower();
|
||||
switch (sDatatype)
|
||||
{
|
||||
case "int":
|
||||
case "number":
|
||||
case "integer":
|
||||
case "smallint":
|
||||
sTempDatatype = "int?";
|
||||
break;
|
||||
|
||||
case "bigint":
|
||||
sTempDatatype = "long?";
|
||||
break;
|
||||
|
||||
case "tinyint":
|
||||
sTempDatatype = "byte?";
|
||||
break;
|
||||
|
||||
case "numeric":
|
||||
case "real":
|
||||
sTempDatatype = "Single?";
|
||||
break;
|
||||
|
||||
case "float":
|
||||
sTempDatatype = "float?";
|
||||
break;
|
||||
|
||||
case "decimal":
|
||||
case "numer(8,2)":
|
||||
sTempDatatype = "decimal?";
|
||||
break;
|
||||
|
||||
case "bit":
|
||||
sTempDatatype = "bool?";
|
||||
break;
|
||||
|
||||
case "date":
|
||||
case "datetime":
|
||||
case "datetime2":
|
||||
case "smalldatetime":
|
||||
sTempDatatype = "DateTime?";
|
||||
break;
|
||||
|
||||
case "money":
|
||||
case "smallmoney":
|
||||
sTempDatatype = "double?";
|
||||
break;
|
||||
|
||||
case "char":
|
||||
case "varchar":
|
||||
case "nvarchar2":
|
||||
case "text":
|
||||
case "nchar":
|
||||
case "nvarchar":
|
||||
case "ntext":
|
||||
default:
|
||||
sTempDatatype = "string";
|
||||
break;
|
||||
}
|
||||
return sTempDatatype;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
ZR.CodeGenerator/ZR.CodeGenerator.csproj
Normal file
18
ZR.CodeGenerator/ZR.CodeGenerator.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
|
||||
<ProjectReference Include="..\ZR.Common\ZR.Common.csproj" />
|
||||
<ProjectReference Include="..\ZR.Model\ZR.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Model\" />
|
||||
<Folder Include="Template\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user