添加项目文件。
This commit is contained in:
20
HT.Cloud.CodeGenerator/HT.Cloud.CodeGenerator.csproj
Normal file
20
HT.Cloud.CodeGenerator/HT.Cloud.CodeGenerator.csproj
Normal file
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.3.45" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HT.Cloud.Code\HT.Cloud.Code.csproj" />
|
||||
<ProjectReference Include="..\HT.Cloud.Domain\HT.Cloud.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
180
HT.Cloud.CodeGenerator/Model/BaseConfigModel.cs
Normal file
180
HT.Cloud.CodeGenerator/Model/BaseConfigModel.cs
Normal file
@ -0,0 +1,180 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HT.Cloud.CodeGenerator
|
||||
{
|
||||
public class BaseConfigModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库表名sys_menu
|
||||
/// </summary>
|
||||
public string TableName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表名首字母大写Sys_Menu
|
||||
/// </summary>
|
||||
public string TableNameUpper { get; set; }
|
||||
|
||||
public FileConfigModel FileConfig { get; set; }
|
||||
public OutputConfigModel OutputConfig { get; set; }
|
||||
public PageIndexModel PageIndex { get; set; }
|
||||
public PageFormModel PageForm { get; set; }
|
||||
}
|
||||
|
||||
public class FileConfigModel
|
||||
{
|
||||
public string ClassPrefix { get; set; }
|
||||
public string ClassDescription { get; set; }
|
||||
public string CreateUserName { get; set; }
|
||||
public string CreateDate { get; set; }
|
||||
public string EntityName { get; set; }
|
||||
public string ServiceName { get; set; }
|
||||
public string ControllerName { get; set; }
|
||||
public string PageIndexName { get; set; }
|
||||
public string PageFormName { get; set; }
|
||||
public string PageDetailsName { get; set; }
|
||||
}
|
||||
|
||||
public class OutputConfigModel
|
||||
{
|
||||
public string OutputModule { get; set; }
|
||||
public string OutputEntity { get; set; }
|
||||
public string OutputService { get; set; }
|
||||
public string OutputWeb { get; set; }
|
||||
}
|
||||
|
||||
public class PageIndexModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否菜单显示
|
||||
/// </summary>
|
||||
public bool IsMunu { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要搜索框
|
||||
/// </summary>
|
||||
public bool IsSearch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否树形表格
|
||||
/// </summary>
|
||||
public bool IsTree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否字段控制
|
||||
/// </summary>
|
||||
public bool IsFields { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否公共
|
||||
/// </summary>
|
||||
public bool IsPublic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否缓存
|
||||
/// </summary>
|
||||
public bool IsCache { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工具栏按钮(新增 修改 删除 查看)
|
||||
/// </summary>
|
||||
public List<string> ButtonList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否有分页
|
||||
/// </summary>
|
||||
public bool IsPagination { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序字段
|
||||
/// </summary>
|
||||
public string SortColumn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父级字段
|
||||
/// </summary>
|
||||
public string ParentColum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 树形显示字段
|
||||
/// </summary>
|
||||
public string TreeColum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模糊查询字段
|
||||
/// </summary>
|
||||
public List<string> KeywordColum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除字段字段
|
||||
/// </summary>
|
||||
public string DeleteColum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间字段
|
||||
/// </summary>
|
||||
public string CreateColum { get; set; }
|
||||
|
||||
public bool? IsAsc { get; set; }
|
||||
public List<ColumnField> ColumnList { get; set; }
|
||||
}
|
||||
|
||||
public class PageFormModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 1表示显示成1列,2表示显示成2列
|
||||
/// </summary>
|
||||
public int ShowMode { get; set; }
|
||||
|
||||
public Dictionary<string, string> FieldList { get; set; }
|
||||
}
|
||||
|
||||
public class ColumnField
|
||||
{
|
||||
/// <summary>
|
||||
/// 字段
|
||||
/// </summary>
|
||||
public string field { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 列名
|
||||
/// </summary>
|
||||
public string title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 宽度
|
||||
/// </summary>
|
||||
public int? width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否minWidth
|
||||
/// </summary>
|
||||
public bool? isAotuWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否排序
|
||||
/// </summary>
|
||||
public bool? isSorted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否过滤
|
||||
/// </summary>
|
||||
public bool? isFilter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 过滤类型
|
||||
/// </summary>
|
||||
public string filterType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 格式化显示
|
||||
/// </summary>
|
||||
public string templet { get; set; }
|
||||
|
||||
public bool? isShow { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始值
|
||||
/// </summary>
|
||||
public string value { get; set; }
|
||||
}
|
||||
}
|
8
HT.Cloud.CodeGenerator/Properties/launchSettings.json
Normal file
8
HT.Cloud.CodeGenerator/Properties/launchSettings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"WaterCloud.CodeGenerator": {
|
||||
"commandName": "Project",
|
||||
"nativeDebugging": true
|
||||
}
|
||||
}
|
||||
}
|
142
HT.Cloud.CodeGenerator/TableMappingHelper.cs
Normal file
142
HT.Cloud.CodeGenerator/TableMappingHelper.cs
Normal file
@ -0,0 +1,142 @@
|
||||
using System.Text;
|
||||
using HT.Cloud.Code;
|
||||
|
||||
namespace HT.Cloud.CodeGenerator
|
||||
{
|
||||
public class TableMappingHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// sys_role转成SysRole
|
||||
/// </summary>
|
||||
/// <param name="lowercase"></param>
|
||||
/// <returns></returns>
|
||||
public static string ConvertToUppercase(string lowercase)
|
||||
{
|
||||
lowercase = lowercase.ParseToString();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string[] arr = lowercase.Split('_');
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
sb.Append(arr[i][0].ToString().ToUpper() + arr[i].Substring(1));
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sys_role转成Sys_Role
|
||||
/// </summary>
|
||||
/// <param name="lowercase"></param>
|
||||
/// <returns></returns>
|
||||
public static string ConvertTo_Uppercase(string lowercase)
|
||||
{
|
||||
lowercase = lowercase.ParseToString();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string[] arr = lowercase.Split('_');
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
arr[i] = arr[i][0].ToString().ToUpper() + arr[i].Substring(1);
|
||||
}
|
||||
return string.Join("_", arr);
|
||||
}
|
||||
|
||||
/// <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();
|
||||
sDatatype = System.Text.RegularExpressions.Regex.Replace(sDatatype, @"\d", "");
|
||||
sDatatype = sDatatype.Replace(",", "");
|
||||
sDatatype = sDatatype.Replace("(", "");
|
||||
sDatatype = sDatatype.Replace(")", "");
|
||||
switch (sDatatype)
|
||||
{
|
||||
case "int":
|
||||
case "integer":
|
||||
case "smallint":
|
||||
sTempDatatype = "int";
|
||||
break;
|
||||
|
||||
case "bigint":
|
||||
sTempDatatype = "long";
|
||||
break;
|
||||
|
||||
case "numeric":
|
||||
case "real":
|
||||
sTempDatatype = "Single";
|
||||
break;
|
||||
|
||||
case "float":
|
||||
case "number":
|
||||
sTempDatatype = "float";
|
||||
break;
|
||||
|
||||
case "decimal":
|
||||
sTempDatatype = "decimal";
|
||||
break;
|
||||
|
||||
case "tinyint":
|
||||
case "bit":
|
||||
sTempDatatype = "bool";
|
||||
break;
|
||||
|
||||
case "datetime":
|
||||
case "datetime2":
|
||||
case "date":
|
||||
case "smalldatetime":
|
||||
case "timestamp":
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
1558
HT.Cloud.CodeGenerator/Template/SingleTableTemplate.cs
Normal file
1558
HT.Cloud.CodeGenerator/Template/SingleTableTemplate.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user