This commit is contained in:
xiaowei.song
2024-06-06 13:19:24 +08:00
parent c93711290e
commit 127c428a9e
919 changed files with 93 additions and 86 deletions

View File

@@ -0,0 +1,136 @@
using SqlSugar;
using System.Collections.Generic;
namespace ZR.Model.System.Generate
{
/// <summary>
/// 代码生成表
/// </summary>
[SugarTable("gen_table", "代码生成表")]
[Tenant("0")]
public class GenTable : SysBase
{
/// <summary>
/// 表id
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long TableId { get; set; }
/// <summary>
/// 数据库名
/// </summary>
[SugarColumn(Length = 50)]
public string DbName { get; set; }
/// <summary>
/// 表名
/// </summary>
[SugarColumn(Length = 150)]
public string TableName { get; set; }
/// <summary>
/// 表描述
/// </summary>
[SugarColumn(Length = 150)]
public string TableComment { get; set; }
/// <summary>
/// 关联父表的表名
/// </summary>
[SugarColumn(Length = 150)]
public string SubTableName { get; set; }
/// <summary>
/// 本表关联父表的外键名
/// </summary>
[SugarColumn(Length = 150)]
public string SubTableFkName { get; set; }
/// <summary>
/// csharp类名
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 使用的模板crud单表操作 tree树表操作 sub主子表操作
/// </summary>
[SugarColumn(Length = 50, DefaultValue = "crud")]
public string TplCategory { get; set; }
/// <summary>
/// 基本命名空间前缀
/// </summary>
[SugarColumn(Length = 100)]
public string BaseNameSpace { get; set; }
/// <summary>
/// 生成模块名
/// </summary>
[SugarColumn(Length = 50)]
public string ModuleName { get; set; }
/// <summary>
/// 生成业务名
/// </summary>
[SugarColumn(Length = 50)]
public string BusinessName { get; set; }
/// <summary>
/// 生成功能名
/// </summary>
public string FunctionName { get; set; }
/// <summary>
/// 生成作者名
/// </summary>
public string FunctionAuthor { get; set; }
/// <summary>
/// 生成代码方式0zip压缩包 1自定义路径
/// </summary>
[SugarColumn(Length = 1, DefaultValue = "0")]
public string GenType { get; set; }
/// <summary>
/// 代码生成保存路径
/// </summary>
[SugarColumn(Length = 200, DefaultValue = "/")]
public string GenPath { get; set; }
/// <summary>
/// 其他生成选项
/// </summary>
[SugarColumn(IsJson = true)]
public Options Options { get; set; }
#region
/// <summary>
/// 表列信息
/// </summary>
[SugarColumn(IsIgnore = true)]
public List<GenTableColumn> Columns { get; set; }
/// <summary>
/// 字表信息
/// </summary>
[SugarColumn(IsIgnore = true)]
public GenTable SubTable { get; set; }
#endregion
}
public class Options
{
public long ParentMenuId { get; set; }
public string SortType { get; set; } = "asc";
public string SortField { get; set; } = string.Empty;
public string TreeCode { get; set; } = string.Empty;
public string TreeName { get; set; } = string.Empty;
public string TreeParentCode { get; set; } = string.Empty;
public string PermissionPrefix { get; set; } = string.Empty;
/// <summary>
/// 额外参数字符串
/// </summary>
public int[] CheckedBtn { get; set; } = new int[] { 1, 2, 3 };
/// <summary>
/// 列大小 12,24
/// </summary>
public int ColNum { get; set; } = 12;
/// <summary>
/// 是否生成仓储层
/// </summary>
public int GenerateRepo { get; set; }
/// <summary>
/// 自动生成菜单
/// </summary>
public bool GenerateMenu { get; set; }
/// <summary>
/// 操作按钮样式
/// </summary>
public int OperBtnStyle { get; set; } = 1;
}
}

View File

@@ -0,0 +1,160 @@
using SqlSugar;
using System;
using System.Linq;
namespace ZR.Model.System.Generate
{
/// <summary>
/// 代码生成表字段
/// </summary>
[SugarTable("gen_table_column", "代码生成表字段")]
[Tenant("0")]
public class GenTableColumn : SysBase
{
/// <summary>
/// 列id
/// </summary>
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public long ColumnId { get; set; }
/// <summary>
/// 导入代码生成表列名 首字母转了小写
/// </summary>
public string ColumnName { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public long TableId { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public string TableName { get; set; }
/// <summary>
/// 列说明
/// </summary>
private string columnComment;
public string ColumnComment
{
get
{
return string.IsNullOrEmpty(columnComment) ? CsharpField : columnComment;
}
set
{
columnComment = value;
}
}
/// <summary>
/// 数据库列类型
/// </summary>
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public string ColumnType { get; set; }
/// <summary>
/// C#类型
/// </summary>
public string CsharpType { get; set; }
/// <summary>
/// C# 字段名 首字母大写
/// </summary>
public string CsharpField { get; set; }
/// <summary>
/// 是否主键1是
/// </summary>
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public bool IsPk { get; set; }
/// <summary>
/// 是否必填1是
/// </summary>
public bool IsRequired { get; set; }
/// <summary>
/// 是否自增1是
/// </summary>
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public bool IsIncrement { get; set; }
/// <summary>
/// 是否插入1是
/// </summary>
public bool IsInsert { get; set; }
/// <summary>
/// 是否需要编辑1是
/// </summary>
public bool IsEdit { get; set; }
/// <summary>
/// 是否显示列表1是
/// </summary>
public bool IsList { get; set; }
/// <summary>
/// 是否查询1是
/// </summary>
public bool IsQuery { get; set; }
/// <summary>
/// 是否排序1是
/// </summary>
public bool IsSort { get; set; }
/// <summary>
/// 是否导出1是
/// </summary>
public bool IsExport { get; set; }
/// <summary>
/// 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
/// </summary>
public string HtmlType { get; set; }
/// <summary>
/// 查询类型(等于、不等于、大于、小于、范围)
/// </summary>
[SugarColumn(DefaultValue = "EQ")]
public string QueryType { get; set; } = "EQ";
public int Sort { get; set; }
/// <summary>
/// 字典类型
/// </summary>
public string DictType { get; set; } = "";
/// <summary>
/// 自动填充类型 1、添加 2、编辑 3、添加编辑
/// </summary>
public int AutoFillType { get; set; }
#region
[SugarColumn(IsIgnore = true)]
public string RequiredStr
{
get
{
string[] arr = new string[] { "int", "long" };
return (!IsRequired && HtmlType != "selectMulti" && (arr.Any(f => f.Contains(CsharpType))) || typeof(DateTime).Name == CsharpType) ? "?" : "";
}
}
/// <summary>
/// 前端排序字符串
/// </summary>
[SugarColumn(IsIgnore = true)]
public string SortStr
{
get
{
return IsSort ? " sortable" : "";
}
}
/// <summary>
/// C# 字段名 首字母小写,用于前端
/// </summary>
[SugarColumn(IsIgnore = true)]
public string CsharpFieldFl
{
get
{
return CsharpField[..1].ToLower() + CsharpField[1..];
}
}
/// <summary>
/// 前端 只读字段
/// </summary>
[SugarColumn(IsIgnore = true)]
public string DisabledStr
{
get
{
return ((IsPk) && !IsRequired) ? " :disabled=\"true\"" : "";
}
}
#endregion
}
}