vengine初步实现增删改查

This commit is contained in:
2023-09-06 18:50:20 +08:00
parent b52e48ce9a
commit 64e1a60780
41 changed files with 2820 additions and 2752 deletions

View File

@@ -0,0 +1,155 @@
/////////////////////////////////////////////////////////////////////////////////
// 宁波拓通e智造平台 ToTong Next Builder //
// https://git.tuotong-tech.com/tnb/tnb.server //
/////////////////////////////////////////////////////////////////////////////////
using Tnb.Core;
namespace Tnb.Vengine.Domain;
public class VmBaseInput
{
///// <summary>
///// 视图模型id
///// </summary>
//public string vmid { get; set; } = string.Empty;
}
public class VmGetInput : VmBaseInput
{
/// <summary>
/// 要获取数据的id
/// </summary>
public string? id { get; set; }
/// <summary>
/// 过滤条件
/// </summary>
public string? q { get; set; }
/// <summary>
/// 输出字段
/// </summary>
public string o { get; set; } = "*";
}
public class VmGetListInput : VmBaseInput
{
/// <summary>
/// 当前页数
/// </summary>
public int pnum { get; set; }
/// <summary>
/// 每页记录数
/// </summary>
public int psize { get; set; }
/// <summary>
/// 排序
/// </summary>
public string? sort { get; set; } = null;
/// <summary>
/// 模糊查询
/// </summary>
public string? k { get; set; }
/// <summary>
/// 过滤条件
/// </summary>
public string? q { get; set; }
/// <summary>
/// 输出字段
/// </summary>
public string o { get; set; } = "*";
}
/// <summary>
/// 获取多条数据输入参数
/// </summary>
public class VmQueryInput : VmGetListInput
{
/// <summary>
/// 查询条件
/// </summary>
public new DObject? q { get; set; }
/// <summary>
/// 高级查询
/// </summary>
public DObject? adv { get; set; }
}
/// <summary>
/// 新增数据输入参数
/// </summary>
public class VmCreateInput : VmBaseInput
{
/// <summary>
/// 数据
/// </summary>
public DObject? data { get; set; }
/// <summary>
/// 批量添加
/// </summary>
public List<DObject>? items { get; set; }
}
/// <summary>
/// 修改数据输入参数
/// </summary>
public class VmUpdateInput : VmCreateInput
{
///// <summary>
///// 要更新的数据id
///// </summary>
//public string? id { get; set; }
}
/// <summary>
/// 删除数据输入参数
/// </summary>
public class VmDeleteInput : VmBaseInput
{
/// <summary>
/// 要删除的数据id
/// </summary>
public string? id { get; set; }
/// <summary>
/// 要删除的id列表
/// </summary>
public List<string>? ids { get; set; }
}
/// <summary>
/// 分页列表输出对象
/// </summary>
/// <typeparam name="T"></typeparam>
public class PagedOutput<T>
{
public int total { get; set; }
public List<T> items { get; set; } = new List<T>();
}
/// <summary>
/// 动态分页列表输出对象
/// </summary>
public class VmPagedOutput : PagedOutput<dynamic>
{
}
/// <summary>
/// 查询属性信息
/// </summary>
public class VmSelectProp
{
public const string MAIN_ALIES = "m";
public string code { get; set; } = string.Empty;
public string field { get; set; } = string.Empty;
public string navCode { get; set; } = MAIN_ALIES;
public ePropType propType { get; set; }
public eNavigateType navType { get; set; }
}

View File

@@ -3,6 +3,8 @@
// https://git.tuotong-tech.com/tnb/tnb.server //
/////////////////////////////////////////////////////////////////////////////////
using JNPF.Common.Extension;
using Newtonsoft.Json;
using Yitter.IdGenerator;
namespace Tnb.Vengine.Domain;
@@ -12,138 +14,197 @@ namespace Tnb.Vengine.Domain;
/// </summary>
public class VmDbProp : VmBaseProp
{
#region Properties
/// <summary>
/// 字段名称
/// </summary>
public string field { get; set; } = string.Empty;
#region Properties
/// <summary>
/// 字段名称
/// </summary>
public string field { get; set; } = string.Empty;
/// <summary>
/// 数据类型
/// </summary>
public string dataType { get; set; } = "varchar";
/// <summary>
/// 数据类型
/// </summary>
[JsonIgnore]
public string dataType { get; set; } = "varchar";
/// <summary>
/// 数据类型
/// </summary>
public string? csType { get; set; }
/// <summary>
/// 数据类型
/// </summary>
public string? csType { get; set; }
/// <summary>
/// 长度
/// </summary>
public int length { get; set; }
/// <summary>
/// 长度
/// </summary>
public int length { get; set; }
/// <summary>
/// 精度
/// </summary>
public int digit { get; set; }
/// <summary>
/// 精度
/// </summary>
public int digit { get; set; }
/// <summary>
/// 排序
/// </summary>
public int ordinal { get; set; }
/// <summary>
/// 排序
/// </summary>
public int ordinal { get; set; }
/// <summary>
/// 非空
/// </summary>
public bool required { get; set; }
/// <summary>
/// 非空
/// </summary>
public bool required { get; set; }
/// <summary>
/// 是否主键
/// </summary>
public bool pkey { get; set; }
/// <summary>
/// 是否主键
/// </summary>
public bool pkey { get; set; }
/// <summary>
/// 是否模糊搜索
/// </summary>
public bool fuzzy { get; set; }
/// <summary>
/// 是否模糊搜索
/// </summary>
public bool fuzzy { get; set; }
/// <summary>
/// 默认值
/// </summary>
public string? defValue { get; set; }
/// <summary>
/// 默认值
/// </summary>
public string? defValue { get; set; }
/// <summary>
/// 描述
/// </summary>
public string? descrip { get; set; }
#endregion
/// <summary>
/// 描述
/// </summary>
public string? descrip { get; set; }
#endregion
/// <summary>
/// 获取默认值
/// </summary>
/// <returns></returns>
public object? GetDefaultValue()
{
object? val = null;
if (string.IsNullOrEmpty(defValue))
/// <summary>
/// 获取默认值
/// </summary>
/// <returns></returns>
public object? GetDefaultValue()
{
val = defValue switch
{
"@@snowid" => YitIdHelper.NextId().ToString(),
"@@now" => DateTime.Now,
"@@userid" => YitIdHelper.NextId().ToString(),
"@@orgid" => YitIdHelper.NextId().ToString(),
_ => null
};
object? val = null;
if(!required) { return val; }
if (string.IsNullOrEmpty(defValue))
{
val = csType switch
{
"string" => string.Empty,
"short" or "int" or "long" => 0,
"float" or "double" or "decimal" => 0f,
"DateTime" => DateTime.Now,
_ => null
};
}
else
{
val = defValue switch
{
"@@snowid" => YitIdHelper.NextId().ToString(),
"@@now" => DateTime.Now,
"@@userid" => YitIdHelper.NextId().ToString(),
"@@orgid" => YitIdHelper.NextId().ToString(),
_ => null
};
}
return val;
}
else
{
val = csType switch
{
"string" => string.Empty,
"short" or "int" or "long" => 0,
"float" or "double" or "decimal" => 0f,
"DateTime" => DateTime.Now,
_ => null
};
}
return val;
}
/// <summary>
/// 获取默认宽度
/// </summary>
/// <returns></returns>
public string GetDefaultWidth()
{
return csType switch
/// <summary>
/// 获取默认值文本
/// </summary>
/// <returns></returns>
public object? GetDefaultValueString()
{
"string" => "\"width\": \"auto\"",
"int" or "short" or "long" => "\"width\": 80",
"DateTime" => "\"width\": 150",
_ => ""
};
}
/// <summary>
/// 获取默认组件
/// </summary>
/// <returns></returns>
public CompOption GetDefaultComp()
{
CompOption comp = new CompOption();
if (pkey)
{
comp.attr.Add("disabled", true);
return comp;
string val = "";
if (!required) return val;
if (!string.IsNullOrWhiteSpace(defValue))
{
val = defValue switch
{
"@@snowid" => "YitIdHelper.NextId().ToString()",
"@@now" => "DateTime.Now",
_ => defValue
};
}
if (string.IsNullOrEmpty(val))
{
val = csType switch
{
"string" => "string.Empty;",
"DateTime" => "DateTime.Now;",
_ => ""
};
}
return string.IsNullOrEmpty(val) ? "" : " = " + val;
}
switch (csType)
/// <summary>
/// 获取默认宽度
/// </summary>
/// <returns></returns>
public string GetDefaultWidth()
{
case "string":
comp.attr.Add("clearable", true);
comp.attr.Add("maxlength", length);
comp.attr.Add("showWordLimit", true);
break;
case "int":
case "short":
case "long":
comp.type = "el-input-number";
break;
case "DateTime":
comp.type = "el-date-picker";
break;
};
return comp;
}
return csType switch
{
"string" => "\"width\": \"auto\"",
"int" or "short" or "long" => "\"width\": 80",
"DateTime" => "\"width\": 150",
_ => ""
};
}
/// <summary>
/// 获取默认组件
/// </summary>
/// <returns></returns>
public CompOption GetDefaultComp()
{
CompOption comp = new CompOption();
if (pkey)
{
comp.attr.Add("disabled", true);
return comp;
}
switch (csType)
{
case "string":
comp.attr.Add("clearable", true);
comp.attr.Add("maxlength", length);
comp.attr.Add("showWordLimit", true);
break;
case "int":
case "short":
case "long":
comp.type = "el-input-number";
break;
case "DateTime":
comp.type = "el-date-picker";
break;
};
return comp;
}
/// <summary>
/// 获取SqlSugar特性文本
/// </summary>
/// <returns></returns>
public string GetAttributeString()
{
var attr = "";
var sb = new List<string>();
if (!string.IsNullOrEmpty(field) && code != field) sb.Add($"ColumnName = \"{field}\"");
if (pkey) sb.Add("IsPrimaryKey = true");
//sb.Add("IsIdentity = true");
if (required && !pkey) sb.Add("IsNullable = false");
if (csType == "string" && length > 0)
{
sb.Add($"Length = {CodeHelper.LengthToString(length)}");
}
if (csType == "decimal")
{
if (length > 0) sb.Add($"Length = {length}");
if (digit > 0) sb.Add($"DecimalDigits = {digit}");
}
//if(isJson) sb.Add("IsJson = true")
if (sb.Any()) attr += $"\t[SugarColumn({sb.JoinAsString(", ")})]{Environment.NewLine}";
return attr;
}
}

View File

@@ -1,198 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
// 宁波拓通e智造平台 ToTong Next Builder //
// https://git.tuotong-tech.com/tnb/tnb.server //
/////////////////////////////////////////////////////////////////////////////////
namespace Tnb.Vengine.Domain;
/// <summary>
/// 字典对象
/// </summary>
public class DObject : Dictionary<string, object>
{
public DObject() { }
public DObject(string key, object value)
{
Add(key, value);
}
public DObject(Dictionary<string, object> dictionary) : base(dictionary)
{
}
public void AddCascade(string code, object value)
{
var keys = code.Split('.');
if (keys.Length == 1)
{
Add(code, value);
return;
}
for (int i = 0; i < keys.Length; i++)
{
DObject temp = this;
if (i < keys.Length - 1)
{
if (!ContainsKey(keys[i]))
{
temp = new DObject();
Add(keys[i], temp);
}
else
{
temp = (DObject)temp[keys[i]];
}
}
else
{
temp.Add(keys[i], value);
}
}
}
}
public class VmBaseInput
{
///// <summary>
///// 视图模型id
///// </summary>
//public string vmid { get; set; } = string.Empty;
}
public class VmGetInput : VmBaseInput
{
/// <summary>
/// 要获取数据的id
/// </summary>
public string? id { get; set; }
/// <summary>
/// 过滤条件
/// </summary>
public string? q { get; set; }
/// <summary>
/// 输出字段
/// </summary>
public string o { get; set; } = "*";
}
public class VmGetListInput : VmBaseInput
{
/// <summary>
/// 当前页数
/// </summary>
public int pnum { get; set; }
/// <summary>
/// 每页记录数
/// </summary>
public int psize { get; set; }
/// <summary>
/// 排序
/// </summary>
public string? sort { get; set; } = null;
/// <summary>
/// 模糊查询
/// </summary>
public string? k { get; set; }
/// <summary>
/// 过滤条件
/// </summary>
public string? q { get; set; }
/// <summary>
/// 输出字段
/// </summary>
public string o { get; set; } = "*";
}
/// <summary>
/// 获取多条数据输入参数
/// </summary>
public class VmQueryInput : VmGetListInput
{
/// <summary>
/// 查询条件
/// </summary>
public new DObject? q { get; set; }
/// <summary>
/// 高级查询
/// </summary>
public DObject? adv { get; set; }
}
/// <summary>
/// 新增数据输入参数
/// </summary>
public class VmCreateInput : VmBaseInput
{
/// <summary>
/// 数据
/// </summary>
public DObject? data { get; set; }
/// <summary>
/// 批量添加
/// </summary>
public List<DObject>? items { get; set; }
}
/// <summary>
/// 修改数据输入参数
/// </summary>
public class VmUpdateInput : VmCreateInput
{
///// <summary>
///// 要更新的数据id
///// </summary>
//public string? id { get; set; }
}
/// <summary>
/// 删除数据输入参数
/// </summary>
public class VmDeleteInput : VmBaseInput
{
/// <summary>
/// 要删除的数据id
/// </summary>
public string? id { get; set; }
/// <summary>
/// 要删除的id列表
/// </summary>
public List<string>? ids { get; set; }
}
/// <summary>
/// 分页列表输出对象
/// </summary>
/// <typeparam name="T"></typeparam>
public class PagedOutput<T>
{
public int total { get; set; }
public List<T> items { get; set; } = new List<T>();
}
/// <summary>
/// 动态分页列表输出对象
/// </summary>
public class VmPagedOutput : PagedOutput<dynamic>
{
}
/// <summary>
/// 查询属性信息
/// </summary>
public class VmSelectProp
{
public const string MAIN_ALIES = "m";
public string code { get; set; } = string.Empty;
public string field { get; set; } = string.Empty;
public string navCode { get; set; } = MAIN_ALIES;
public ePropType propType { get; set; }
public eNavigateType navType { get; set; }
}

View File

@@ -12,43 +12,47 @@ namespace Tnb.Vengine.Domain;
/// </summary>
public class VmNavProp : VmBaseProp
{
/// <summary>
/// 导航属性模型id
/// </summary>
public string vmid { get; set; } = string.Empty;
#region Properties
/// <summary>
/// 导航关联类型
/// </summary>
public eNavigateType navType { get; set; }
/// <summary>
/// 导航属性模型id
/// </summary>
public string vmid { get; set; } = string.Empty;
/// <summary>
/// 源表字段
/// </summary>
public string refCode { get; set; } = VmSelectProp.MAIN_ALIES;
/// <summary>
/// 导航关联类型
/// </summary>
public eNavigateType navType { get; set; }
/// <summary>
/// 被引用字段
/// </summary>
public string refField { get; set; } = string.Empty;
/// <summary>
/// 源表字段
/// </summary>
public string refCode { get; set; } = VmSelectProp.MAIN_ALIES;
/// <summary>
/// 源表字段
/// </summary>
public string fkField { get; set; } = string.Empty;
/// <summary>
/// 被引用字段
/// </summary>
public string refField { get; set; } = string.Empty;
///// <summary>
///// 关联表表名
///// </summary>
//[JsonIgnore]
//public string refTable { get; set; } = string.Empty;
/// <summary>
/// 源表字段
/// </summary>
public string fkField { get; set; } = string.Empty;
///// <summary>
///// 被引用表(中间表)
///// </summary>
//[JsonIgnore]
//public string? midTable { get; set; }
///// <summary>
///// 关联表表名
///// </summary>
//[JsonIgnore]
//public string refTable { get; set; } = string.Empty;
///// <summary>
///// 被引用表(中间表)
///// </summary>
//[JsonIgnore]
//public string? midTable { get; set; }
[JsonIgnore]
public Vmodel? naviModel { get; set; }
#endregion
[JsonIgnore]
public Vmodel? naviModel { get; set; }
}

View File

@@ -3,13 +3,16 @@
// https://git.tuotong-tech.com/tnb/tnb.server //
/////////////////////////////////////////////////////////////////////////////////
using JNPF.Common.Core.Manager;
using JNPF.Common.Extension;
using Mapster;
using Newtonsoft.Json.Linq;
using SqlSugar;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Reflection;
using Mapster;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.Core;
using Yitter.IdGenerator;
namespace Tnb.Vengine.Domain;
@@ -20,424 +23,486 @@ namespace Tnb.Vengine.Domain;
[SugarTable("sys_vmodel")]
public partial class Vmodel : Entity
{
#region Properties
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; } = YitIdHelper.NextId().ToString();
#region Properties
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; } = YitIdHelper.NextId().ToString();
/// <summary>
/// 模块代码
/// </summary>
[SugarColumn(ColumnName = "area", Length = DbConsts.LengthS)]
public string area { get; set; } = "edp";
/// <summary>
/// 模块代码
/// </summary>
[SugarColumn(ColumnName = "area_code", Length = DbConsts.LengthS)]
public string areaCode { get; set; } = "edp";
/// <summary>
/// 视图代码
/// </summary>
[SugarColumn(ColumnName = "vm_code", IsNullable = false, Length = DbConsts.LengthM)]
public string vmCode { get; set; } = string.Empty;
/// <summary>
/// 视图代码
/// </summary>
[SugarColumn(ColumnName = "vm_code", IsNullable = false, Length = DbConsts.LengthM)]
public string vmCode { get; set; } = string.Empty;
/// <summary>
/// 视图名称
/// </summary>
[SugarColumn(ColumnName = "vm_name", IsNullable = false, Length = DbConsts.LengthM)]
public string vmName { get; set; } = string.Empty;
/// <summary>
/// 视图名称
/// </summary>
[SugarColumn(ColumnName = "vm_name", IsNullable = false, Length = DbConsts.LengthM)]
public string vmName { get; set; } = string.Empty;
/// <summary>
/// 数据库连接
/// </summary>
[SugarColumn(ColumnName = "db_code", Length = DbConsts.LengthS)]
public string? dbCode { get; set; }
/// <summary>
/// 数据库连接
/// </summary>
[SugarColumn(ColumnName = "db_code", Length = DbConsts.LengthS)]
public string? dbCode { get; set; }
/// <summary>
/// 主表名称
/// </summary>
[SugarColumn(ColumnName = "table_name", IsNullable = false, Length = DbConsts.LengthS)]
public string tableName { get; set; } = string.Empty;
/// <summary>
/// 主表名称
/// </summary>
[SugarColumn(ColumnName = "table_name", IsNullable = false, Length = DbConsts.LengthS)]
public string tableName { get; set; } = string.Empty;
/// <summary>
/// 表字段属性
/// </summary>
[SugarColumn(ColumnName = "db_props", IsNullable = false, IsJson = true)]
public List<VmDbProp> dbProps { get; set; } = new List<VmDbProp>();
/// <summary>
/// 表字段属性
/// </summary>
[SugarColumn(ColumnName = "db_props", IsNullable = false, IsJson = true)]
public List<VmDbProp> dbProps { get; set; } = new List<VmDbProp>();
/// <summary>
/// 导航属性
/// </summary>
[SugarColumn(ColumnName = "nav_props", IsNullable = true, IsJson = true)]
public List<VmNavProp> navProps { get; set; } = new List<VmNavProp>();
/// <summary>
/// 导航属性
/// </summary>
[SugarColumn(ColumnName = "nav_props", IsNullable = true, IsJson = true)]
public List<VmNavProp> navProps { get; set; } = new List<VmNavProp>();
/// <summary>
/// 计算属性
/// </summary>
[SugarColumn(ColumnName = "cal_props", IsNullable = true, IsJson = true)]
public List<VmCalProp> calProps { get; set; } = new List<VmCalProp>();
/// <summary>
/// 计算属性
/// </summary>
[SugarColumn(ColumnName = "cal_props", IsNullable = true, IsJson = true)]
public List<VmCalProp> calProps { get; set; } = new List<VmCalProp>();
/// <summary>
/// 排序
/// </summary>
[SugarColumn(ColumnName = "ordinal", IsNullable = false)]
public int ordinal { get; set; }
/// <summary>
/// 排序
/// </summary>
[SugarColumn(ColumnName = "ordinal", IsNullable = false)]
public int ordinal { get; set; }
/// <summary>
/// 软删除
/// </summary>
[SugarColumn(ColumnName = "soft_delete", IsNullable = false)]
public short softDelete { get; set; }
/// <summary>
/// 软删除
/// </summary>
[SugarColumn(ColumnName = "soft_delete", IsNullable = false)]
public short softDelete { get; set; }
/// <summary>
/// 是否激活
/// </summary>
[SugarColumn(ColumnName = "enabled", IsNullable = false)]
public short enabled { get; set; } = 1;
/// <summary>
/// 是否激活
/// </summary>
[SugarColumn(ColumnName = "enabled", IsNullable = false)]
public short enabled { get; set; } = 1;
/// <summary>
/// 是否删除
/// </summary>
[SugarColumn(ColumnName = "deleted", IsNullable = false)]
public short deleted { get; set; }
/// <summary>
/// 是否删除
/// </summary>
[SugarColumn(ColumnName = "deleted", IsNullable = false)]
public short deleted { get; set; }
/// <summary>
/// 描述
/// </summary>
[SugarColumn(ColumnName = "descrip", Length = DbConsts.LengthL)]
public string? descrip { get; set; }
/// <summary>
/// 描述
/// </summary>
[SugarColumn(ColumnName = "descrip", Length = DbConsts.LengthL)]
public string? descrip { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "create_time", IsNullable = false)]
public DateTime createTime { get; set; } = DateTime.Now;
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "create_time", IsNullable = false)]
public DateTime createTime { get; set; } = DateTime.Now;
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnName = "create_id", Length = DbConsts.LengthS)]
public string? createId { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnName = "create_id", Length = DbConsts.LengthS)]
public string? createId { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[SugarColumn(ColumnName = "modify_time", Length = DbConsts.LengthS)]
public DateTime? modifyTime { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[SugarColumn(ColumnName = "modify_time", Length = DbConsts.LengthS)]
public DateTime? modifyTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
[SugarColumn(ColumnName = "modify_id", Length = DbConsts.LengthS)]
public string? modifyId { get; set; }
/// <summary>
/// 修改人
/// </summary>
[SugarColumn(ColumnName = "modify_id", Length = DbConsts.LengthS)]
public string? modifyId { get; set; }
/// <summary>
/// 主键
/// </summary>
public override object[] GetKeys()
{
return new object[] { id };
}
#endregion
[SugarColumn(IsIgnore = true)]
public string fullCode { get { return areaCode + "/" + vmCode; } }
/// <summary>
/// 通过实体创建模型
/// </summary>
/// <param name="tpEntity"></param>
/// <param name="dbCode"></param>
/// <returns></returns>
public static Vmodel CreateByEntity(Type tpEntity, string? dbCode = null)
{
Vmodel model = new() { dbCode = dbCode, vmCode = tpEntity.Name };
var sugarTableAttr = tpEntity.GetCustomAttribute<SugarTable>();
if (sugarTableAttr != null)
/// <summary>
/// 主键
/// </summary>
public override object[] GetKeys()
{
model.tableName = sugarTableAttr.TableName;
model.vmName = sugarTableAttr.TableDescription;
return new object[] { id };
}
if (string.IsNullOrEmpty(model.tableName))
{
model.tableName = tpEntity.GetCustomAttribute<TableAttribute>()?.Name ?? tpEntity.Name;
}
if (string.IsNullOrEmpty(model.vmName))
{
model.vmName = tpEntity.GetCustomAttribute<DisplayAttribute>()?.Name ?? tpEntity.GetCustomAttribute<DescriptionAttribute>()?.Description ?? model.vmCode;
}
var props = tpEntity.GetProperties(BindingFlags.Public);
int n = 1;
foreach (var p in props)
{
VmDbProp prop = new();
var sugarColumn = p.GetCustomAttribute<SugarColumn>();
if (sugarColumn != null)
{
prop = sugarColumn.Adapt<VmDbProp>();
}
prop.code = p.Name;
prop.ordinal = n++;
model.dbProps.Add(prop);
}
return model;
}
#endregion
/// <summary>
/// 获取模型的主键字段属性
/// </summary>
/// <returns></returns>
public VmDbProp GetPrimary()
{
return dbProps.First(a => a.pkey);
}
/// <summary>
/// 根据属性名获取字段名
/// </summary>
/// <param name="propCode"></param>
/// <returns></returns>
public string? PropCodeToFieldCode(string propCode)
{
return dbProps.Where(a => a.code == propCode).Select(a => a.field).FirstOrDefault();
}
/// <summary>
/// 根据字段名获取属性名
/// </summary>
/// <param name="fieldCode"></param>
/// <returns></returns>
public string? FieldCodeToPropCode(string fieldCode)
{
return dbProps.Where(a => a.field == fieldCode).Select(a => a.code).FirstOrDefault();
}
/// <summary>
/// 属性代码转换为字段代码
/// </summary>
/// <param name="input"></param>
/// <param name="ignoreNotMapped"></param>
/// <returns></returns>
public DObject PropToField(DObject input, bool ignoreNotMapped = true)
{
DObject ret = new();
foreach (var item in input)
/// <summary>
/// 通过实体创建模型
/// </summary>
/// <param name="tpEntity"></param>
/// <param name="dbCode"></param>
/// <returns></returns>
public static Vmodel CreateByEntity(Type tpEntity, string? dbCode = null)
{
var fcode = PropCodeToFieldCode(item.Key);
if (!string.IsNullOrEmpty(fcode))
{
ret.Add(fcode, item.Value);
}
else if (!ignoreNotMapped)
{
ret.Add(item.Key, item.Value);
}
}
return ret;
}
/// <summary>
/// 字段代码转换为属性代码
/// </summary>
/// <param name="input"></param>
/// <param name="ignoreNotMapped"></param>
/// <returns></returns>
public DObject FieldToProp(DObject input, bool ignoreNotMapped = true)
{
DObject ret = new();
foreach (var item in input)
{
var pcode = FieldCodeToPropCode(item.Key);
if (!string.IsNullOrEmpty(pcode))
{
ret.Add(pcode, item.Value);
}
else if (!ignoreNotMapped)
{
ret.Add(item.Key, item.Value);
}
}
return ret;
}
/// <summary>
/// 获取查询字段的属性信息
/// </summary>
/// <param name="outputProps"></param>
/// <returns></returns>
public List<VmSelectProp> GetVmSelectProps(string? outputProps)
{
if (string.IsNullOrEmpty(outputProps) || outputProps == "*")
{
return dbProps.Select(a => new VmSelectProp { code = a.code, field = a.field }).ToList();
}
List<VmSelectProp> selProps = new();
var outputs = outputProps.Split(',').Distinct().ToList();
foreach (var propCode in outputs)
{
if (!propCode.Contains("."))
{
var fieldCode = PropCodeToFieldCode(propCode);
if (!string.IsNullOrEmpty(fieldCode))
Vmodel model = new() { dbCode = dbCode, vmCode = tpEntity.Name };
var sugarTableAttr = tpEntity.GetCustomAttribute<SugarTable>();
if (sugarTableAttr != null)
{
selProps.Add(new VmSelectProp { code = propCode, field = fieldCode });
model.tableName = sugarTableAttr.TableName;
model.vmName = sugarTableAttr.TableDescription;
}
continue;
}
var codes = propCode.Split('.');
if (codes.Length != 2) continue;
if (codes[0] == VmSelectProp.MAIN_ALIES)
{
var fieldCode = PropCodeToFieldCode(propCode);
if (!string.IsNullOrEmpty(fieldCode))
if (string.IsNullOrEmpty(model.tableName))
{
selProps.Add(new VmSelectProp { code = propCode, field = fieldCode });
model.tableName = tpEntity.GetCustomAttribute<TableAttribute>()?.Name ?? tpEntity.Name;
}
continue;
}
var navProp = navProps.FirstOrDefault(a => a.code == codes[0]);
if (navProp?.naviModel != null)
{
var fieldCode = navProp.naviModel.PropCodeToFieldCode(codes[1]);
if (!string.IsNullOrEmpty(fieldCode))
if (string.IsNullOrEmpty(model.vmName))
{
selProps.Add(new VmSelectProp { code = codes[1], field = fieldCode, navCode = codes[0], propType = ePropType.Navigate, navType = navProp.navType });
model.vmName = tpEntity.GetCustomAttribute<DisplayAttribute>()?.Name ?? tpEntity.GetCustomAttribute<DescriptionAttribute>()?.Description ?? model.vmCode;
}
}
}
return selProps;
}
/// <summary>
/// 获取联表配置信息
/// </summary>
/// <param name="selProps"></param>
/// <returns></returns>
public List<JoinInfoParameter> GetJoinInfos(List<VmSelectProp> selProps)
{
var navigates = selProps.Where(a => a.propType == ePropType.Navigate).Select(a => a.navCode).Distinct().ToList();
List<JoinInfoParameter> joins = new();
foreach (var navCode in navigates)
{
if (navCode == VmSelectProp.MAIN_ALIES) continue;
var navProp = navProps.First(a => a.code == navCode);
if (navProp.naviModel == null || navProp.navType != eNavigateType.OneToOne) continue;
JoinInfoParameter join = new JoinInfoParameter { TableName = navProp.naviModel.tableName, ShortName = navCode, Type = JoinType.Inner };
var fkField = navProp.naviModel.PropCodeToFieldCode(navProp.fkField);
var refField = navProp.refField;
if (navProp.refCode != VmSelectProp.MAIN_ALIES)
{
var refProp = navProps.First(a => a.code == navProp.refCode);
refField = refProp.naviModel!.PropCodeToFieldCode(navProp.refField);
}
join.Models = ObjectFuncModel.Create("Equals", $"{navCode}.{fkField}", $"{navProp.refCode}.{refField}");
joins.Add(join);
}
return joins;
}
/// <summary>
/// 转换为查询过滤条件
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public List<IConditionalModel> GetConditionalModels(DObject? filter)
{
List<IConditionalModel> wheres = new List<IConditionalModel>();
if (filter == null) return wheres;
foreach (var item in filter)
{
// TODO 按子表条件查询
if (item.Key.Contains("."))
{
}
var prop = dbProps.FirstOrDefault(a => a.code == item.Key);
if (prop == null) continue;
if (item.Value is JArray val)
{
var op = val[0].ToString();
switch (op)
var props = tpEntity.GetProperties(BindingFlags.Public);
int n = 1;
foreach (var p in props)
{
case "><":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThan });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThan });
break;
case ">=<":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThanOrEqual });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThan });
break;
case "><=":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThan });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThanOrEqual });
break;
case ">=<=":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThanOrEqual });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThanOrEqual });
break;
case "in":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val.Skip(1).ToString(), ConditionalType = ConditionalType.In });
break;
default: op = string.Empty; break;
}
}
else
{
//if (item.Value == null) continue;
var conditionalType = ConditionalType.Equal;
string? value = item.Value?.ToString();
if (string.IsNullOrEmpty(value)) continue;
if (value.Length >= 2)
{
var op = value.Substring(0, 2);
switch (op)
{
case "%%": conditionalType = ConditionalType.Like; break;
case ">>": conditionalType = ConditionalType.GreaterThan; break;
case "<<": conditionalType = ConditionalType.LessThan; break;
case ">=": conditionalType = ConditionalType.GreaterThanOrEqual; break;
case "<=": conditionalType = ConditionalType.LessThanOrEqual; break;
case "==": conditionalType = ConditionalType.Equal; break;
default: op = string.Empty; break;
}
if (!string.IsNullOrEmpty(op))
{
value = value.RemovePreFix(op);
if (value.ToLower() == "null")
VmDbProp prop = new();
var sugarColumn = p.GetCustomAttribute<SugarColumn>();
if (sugarColumn != null)
{
value = null;
prop = sugarColumn.Adapt<VmDbProp>();
}
}
prop.code = p.Name;
prop.ordinal = n++;
model.dbProps.Add(prop);
}
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = value, ConditionalType = conditionalType });
}
return model;
}
return wheres;
}
/// <summary>
/// 转换为查询字段列表
/// </summary>
/// <param name="selProps"></param>
/// <returns></returns>
public List<SelectModel> GetSelectModels(List<VmSelectProp> selProps)
{
return selProps.Where(a => a.navType != eNavigateType.OneToMany && a.navType != eNavigateType.ManyToMany).Select(a => new SelectModel
/// <summary>
/// 获取模型的主键字段属性
/// </summary>
/// <returns></returns>
public VmDbProp GetPrimary()
{
FiledName = (a.navCode == VmSelectProp.MAIN_ALIES ? "" : a.navCode + ".") + a.field,
AsName = (a.navCode == VmSelectProp.MAIN_ALIES ? "" : a.navCode + "_") + a.code
}).ToList();
}
/// <summary>
/// 获取默认对象
/// </summary>
/// <returns></returns>
public DObject GetDefaultDObject()
{
DObject obj = new();
foreach (var p in dbProps)
{
obj.Add(p.code, p.GetDefaultValue()!);
return dbProps.First(a => a.pkey);
}
return obj;
}
/// <summary>
/// 根据属性名获取字段名
/// </summary>
/// <param name="propCode"></param>
/// <returns></returns>
public string? PropCodeToFieldCode(string propCode)
{
return dbProps.Where(a => a.code == propCode).Select(a => a.field).FirstOrDefault();
}
/// <summary>
/// 根据字段名获取属性名
/// </summary>
/// <param name="fieldCode"></param>
/// <returns></returns>
public string? FieldCodeToPropCode(string fieldCode)
{
return dbProps.Where(a => a.field == fieldCode).Select(a => a.code).FirstOrDefault();
}
/// <summary>
/// 属性代码转换为字段代码
/// </summary>
/// <param name="input"></param>
/// <param name="ignoreNotMapped"></param>
/// <returns></returns>
public DObject PropToField(DObject input, bool ignoreNotMapped = true)
{
DObject ret = new();
foreach (var item in input)
{
var fcode = PropCodeToFieldCode(item.Key);
if (!string.IsNullOrEmpty(fcode))
{
ret.Add(fcode, item.Value);
}
else if (!ignoreNotMapped)
{
ret.Add(item.Key, item.Value);
}
}
return ret;
}
/// <summary>
/// 字段代码转换为属性代码
/// </summary>
/// <param name="input"></param>
/// <param name="ignoreNotMapped"></param>
/// <returns></returns>
public DObject FieldToProp(DObject input, bool ignoreNotMapped = true)
{
DObject ret = new();
foreach (var item in input)
{
var pcode = FieldCodeToPropCode(item.Key);
if (!string.IsNullOrEmpty(pcode))
{
ret.Add(pcode, item.Value);
}
else if (!ignoreNotMapped)
{
ret.Add(item.Key, item.Value);
}
}
return ret;
}
/// <summary>
/// 获取查询字段的属性信息
/// </summary>
/// <param name="outputProps"></param>
/// <returns></returns>
public List<VmSelectProp> GetVmSelectProps(string? outputProps)
{
if (string.IsNullOrEmpty(outputProps) || outputProps == "*")
{
return dbProps.Select(a => new VmSelectProp { code = a.code, field = a.field }).ToList();
}
List<VmSelectProp> selProps = new();
var outputs = outputProps.Split(',').Distinct().ToList();
foreach (var propCode in outputs)
{
if (!propCode.Contains("."))
{
var fieldCode = PropCodeToFieldCode(propCode);
if (!string.IsNullOrEmpty(fieldCode))
{
selProps.Add(new VmSelectProp { code = propCode, field = fieldCode });
}
continue;
}
var codes = propCode.Split('.');
if (codes.Length != 2) continue;
if (codes[0] == VmSelectProp.MAIN_ALIES)
{
var fieldCode = PropCodeToFieldCode(propCode);
if (!string.IsNullOrEmpty(fieldCode))
{
selProps.Add(new VmSelectProp { code = propCode, field = fieldCode });
}
continue;
}
var navProp = navProps.FirstOrDefault(a => a.code == codes[0]);
if (navProp?.naviModel != null)
{
var fieldCode = navProp.naviModel.PropCodeToFieldCode(codes[1]);
if (!string.IsNullOrEmpty(fieldCode))
{
selProps.Add(new VmSelectProp { code = codes[1], field = fieldCode, navCode = codes[0], propType = ePropType.Navigate, navType = navProp.navType });
}
}
}
return selProps;
}
/// <summary>
/// 获取联表配置信息
/// </summary>
/// <param name="selProps"></param>
/// <returns></returns>
public List<JoinInfoParameter> GetJoinInfos(List<VmSelectProp> selProps)
{
var navigates = selProps.Where(a => a.propType == ePropType.Navigate).Select(a => a.navCode).Distinct().ToList();
List<JoinInfoParameter> joins = new();
foreach (var navCode in navigates)
{
if (navCode == VmSelectProp.MAIN_ALIES) continue;
var navProp = navProps.First(a => a.code == navCode);
if (navProp.naviModel == null || navProp.navType != eNavigateType.OneToOne) continue;
JoinInfoParameter join = new JoinInfoParameter { TableName = navProp.naviModel.tableName, ShortName = navCode, Type = JoinType.Inner };
var fkField = navProp.naviModel.PropCodeToFieldCode(navProp.fkField);
var refField = navProp.refField;
if (navProp.refCode != VmSelectProp.MAIN_ALIES)
{
var refProp = navProps.First(a => a.code == navProp.refCode);
refField = refProp.naviModel!.PropCodeToFieldCode(navProp.refField);
}
join.Models = ObjectFuncModel.Create("Equals", $"{navCode}.{fkField}", $"{navProp.refCode}.{refField}");
joins.Add(join);
}
return joins;
}
/// <summary>
/// 转换为查询过滤条件
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public List<IConditionalModel> GetConditionalModels(DObject? filter)
{
List<IConditionalModel> wheres = new List<IConditionalModel>();
if (filter == null) return wheres;
foreach (var item in filter)
{
// TODO 按子表条件查询
if (item.Key.Contains("."))
{
}
var prop = dbProps.FirstOrDefault(a => a.code == item.Key);
if (prop == null) continue;
if (item.Value is JArray val)
{
var op = val[0].ToString();
switch (op)
{
case "><":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThan, CSharpTypeName = prop.csType });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThan, CSharpTypeName = prop.csType });
break;
case ">=<":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThanOrEqual, CSharpTypeName = prop.csType });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThan, CSharpTypeName = prop.csType });
break;
case "><=":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThan, CSharpTypeName = prop.csType });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThanOrEqual, CSharpTypeName = prop.csType });
break;
case ">=<=":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThanOrEqual, CSharpTypeName = prop.csType });
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThanOrEqual, CSharpTypeName = prop.csType });
break;
case "in":
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val.Skip(1).ToString(), ConditionalType = ConditionalType.In, CSharpTypeName = prop.csType });
break;
default: op = string.Empty; break;
}
}
else
{
//if (item.Value == null) continue;
var conditionalType = ConditionalType.Equal;
string? value = item.Value?.ToString();
if (string.IsNullOrEmpty(value)) continue;
if (value.Length >= 2)
{
var op = value.Substring(0, 2);
switch (op)
{
case "%%": conditionalType = ConditionalType.Like; break;
case ">>": conditionalType = ConditionalType.GreaterThan; break;
case "<<": conditionalType = ConditionalType.LessThan; break;
case ">=": conditionalType = ConditionalType.GreaterThanOrEqual; break;
case "<=": conditionalType = ConditionalType.LessThanOrEqual; break;
case "==": conditionalType = ConditionalType.Equal; break;
default: op = string.Empty; break;
}
if (!string.IsNullOrEmpty(op))
{
value = value.RemovePreFix(op);
if (value.ToLower() == "null")
{
value = null;
}
}
}
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = value, ConditionalType = conditionalType, CSharpTypeName = prop.csType });
}
}
return wheres;
}
/// <summary>
/// 转换为查询字段列表
/// </summary>
/// <param name="selProps"></param>
/// <returns></returns>
public List<SelectModel> GetSelectModels(List<VmSelectProp> selProps)
{
return selProps.Where(a => a.navType != eNavigateType.OneToMany && a.navType != eNavigateType.ManyToMany).Select(a => new SelectModel
{
FiledName = (a.navCode == VmSelectProp.MAIN_ALIES ? "" : a.navCode + ".") + a.field,
AsName = (a.navCode == VmSelectProp.MAIN_ALIES ? "" : a.navCode + "_") + a.code
}).ToList();
}
/// <summary>
/// 获取默认对象
/// </summary>
/// <returns></returns>
public DObject GetDefaultDObject()
{
DObject obj = new();
foreach (var p in dbProps)
{
obj.Add(p.code, p.GetDefaultValue()!);
}
return obj;
}
/// <summary>
/// 转换为待新增的实体对象
/// </summary>
/// <returns></returns>
public DObject ToCreateEntity(DObject input, IUserManager user)
{
DObject obj = new();
foreach (var p in dbProps)
{
if (input.ContainsKey(p.code))
{
obj.Add(p.field, input[p.code]);
}
//当提交的数据与内置规则有重复时采用内置规则如果要优先采用提交的数据这里要使用else if
if ((p.pkey && p.code == "id") || p.defValue == "@snowid")
{
obj[p.field] = YitIdHelper.NextId().ToString();
}
else if (p.csType == "DateTime" && (p.code == "createTime" || p.defValue == "@createTime"))
{
obj[p.field] = DateTime.Now;
}
else if (p.csType == "string" && (p.code == "createId" || p.defValue == "@createId"))
{
obj[p.field] = user.UserId;
}
else if (obj.GetOrDefault(p.field) == null && (p.required || !string.IsNullOrEmpty(p.defValue)))
{
obj[p.field] = p.GetDefaultValue()!;
}
}
return obj;
}
/// <summary>
/// 转换为待修改的实体对象
/// </summary>
/// <returns></returns>
public DObject ToUpdateEntity(DObject input, IUserManager user)
{
DObject obj = new();
foreach (var p in dbProps)
{
if (input.ContainsKey(p.code))
{
obj.Add(p.field, input[p.code]);
}
//当提交的数据与内置规则有重复时采用内置规则如果要优先采用提交的数据这里要使用else if
if (p.csType == "DateTime" && (p.code == "updateTime" || p.code == "modifyTime" || p.defValue == "@updateTime"))
{
obj[p.field] = DateTime.Now;
}
else if (p.csType == "string" && (p.code == "updateId" || p.code == "modifyId" || p.defValue == "@updateId"))
{
obj[p.field] = user.UserId;
}
}
return obj;
}
}

View File

@@ -1,34 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
// 宁波拓通e智造平台 ToTong Next Builder //
// https://git.tuotong-tech.com/tnb/tnb.server //
/////////////////////////////////////////////////////////////////////////////////
namespace Tnb.Vengine.Domain;
public class VmodelCreateFromTableInput
{
public string? dbCode { get; set; }
public string tableName { get; set; } = string.Empty;
public string? removePrefix { get; set; }
public string area { get; set; } = "edp";
}
public class CreatePageFromVmodelInput
{
public Guid? viewId { get; set; }
public string? vmid { get; set; }
}
public class VmodelGetInput
{
public long? id { get; set; }
public string? moduleCode { get; set; }
public string? vmCode { get; set; }
public string? dbCode { get; set; }
public string? tableName { get; set; }
public bool drill { get; set; }
}

View File

@@ -4,6 +4,7 @@
/////////////////////////////////////////////////////////////////////////////////
using SqlSugar;
using Tnb.Core;
using Yitter.IdGenerator;
namespace Tnb.Vengine.Domain;
@@ -14,36 +15,36 @@ namespace Tnb.Vengine.Domain;
[SugarTable("sys_vmodel_link")]
public partial class VmodelLink : Entity
{
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; } = YitIdHelper.NextId().ToString();
/// <summary>
/// 数据库连接
/// </summary>
[SugarColumn(ColumnName = "db_code", Length = DbConsts.LengthS)]
public string? dbCode { get; set; }
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; } = YitIdHelper.NextId().ToString();
/// <summary>
/// 数据库连接
/// </summary>
[SugarColumn(ColumnName = "db_code", IsNullable = false, Length = DbConsts.LengthS)]
public string dbCode { get; set; } = "PostgreSQL";
/// <summary>
/// 数据库类型
/// </summary>
[SugarColumn(ColumnName = "db_type", IsNullable = false)]
public eDbType dbType { get; set; }
/// <summary>
/// 数据库类型
/// </summary>
[SugarColumn(ColumnName = "db_type", IsNullable = false, Length = DbConsts.LengthS)]
public string dbType { get; set; } = "PostgreSQL";
/// <summary>
/// 连接串
/// </summary>
[SugarColumn(ColumnName = "db_connection", IsNullable = false, Length = DbConsts.LengthXL)]
public string dbConnection { get; set; } = "";
/// <summary>
/// 连接串
/// </summary>
[SugarColumn(ColumnName = "db_connection", IsNullable = false, Length = DbConsts.LengthXL)]
public string dbConnection { get; set; } = "";
/// <summary>
/// 主键
/// </summary>
public override object[] GetKeys()
{
return new object[] { id };
}
/// <summary>
/// 主键
/// </summary>
public override object[] GetKeys()
{
return new object[] { id };
}
}

View File

@@ -5,6 +5,7 @@
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.Core;
using Yitter.IdGenerator;
namespace Tnb.Vengine.Domain;
@@ -15,93 +16,92 @@ namespace Tnb.Vengine.Domain;
[SugarTable("sys_vmodel_page")]
public partial class VmodelPage : Entity
{
#region Properties
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; } = YitIdHelper.NextId().ToString();
#region Properties
/// <summary>
/// 主键标识
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public string id { get; set; } = YitIdHelper.NextId().ToString();
/// <summary>
/// 模型id
/// </summary>
[SugarColumn(ColumnName = "vmid", Length = DbConsts.LengthS)]
public string? vmid { get; set; }
/// <summary>
/// 模型id
/// </summary>
[SugarColumn(ColumnName = "vmid", Length = DbConsts.LengthS)]
public string? vmid { get; set; }
/// <summary>
/// 页面代码
/// </summary>
[SugarColumn(ColumnName = "code", Length = DbConsts.LengthS)]
public string code { get; set; } = string.Empty;
/// <summary>
/// 页面代码
/// </summary>
[SugarColumn(ColumnName = "code", Length = DbConsts.LengthS)]
public string code { get; set; } = string.Empty;
/// <summary>
/// 页面名称
/// </summary>
[SugarColumn(ColumnName = "name", Length = DbConsts.LengthM)]
public string name { get; set; } = string.Empty;
/// <summary>
/// 页面名称
/// </summary>
[SugarColumn(ColumnName = "name", Length = DbConsts.LengthM)]
public string name { get; set; } = string.Empty;
/// <summary>
/// 页面类型
/// </summary>
[SugarColumn(ColumnName = "page_type", Length = DbConsts.LengthS)]
public string pageType { get; set; } = string.Empty;
/// <summary>
/// 页面类型
/// </summary>
[SugarColumn(ColumnName = "page_type", Length = DbConsts.LengthS)]
public string pageType { get; set; } = string.Empty;
/// <summary>
/// 页面配置
/// </summary>
[SugarColumn(ColumnName = "page_schema", Length = DbConsts.LengthS, IsJson = true)]
public JObject pageSchema { get; set; } = new JObject();
/// <summary>
/// 页面配置
/// </summary>
[SugarColumn(ColumnName = "page_schema", Length = DbConsts.LengthS, IsJson = true)]
public JObject pageSchema { get; set; } = new JObject();
/// <summary>
/// 页面配置
/// </summary>
[SugarColumn(ColumnName = "option", Length = DbConsts.LengthS)]
public string? option { get; set; } = string.Empty;
/// <summary>
/// 页面配置
/// </summary>
[SugarColumn(ColumnName = "option", Length = DbConsts.LengthS)]
public string? option { get; set; } = string.Empty;
/// <summary>
/// 是否启用
/// </summary>
[SugarColumn(ColumnName = "enabled")]
public short enabled { get; set; } = 1;
/// <summary>
/// 是否启用
/// </summary>
[SugarColumn(ColumnName = "enabled")]
public short enabled { get; set; } = 1;
/// <summary>
/// 是否删除
/// </summary>
[SugarColumn(ColumnName = "deleted")]
public short deleted { get; set; }
/// <summary>
/// 是否删除
/// </summary>
[SugarColumn(ColumnName = "deleted")]
public short deleted { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "create_time")]
public DateTime createTime { get; set; } = DateTime.Now;
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "create_time")]
public DateTime createTime { get; set; } = DateTime.Now;
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnName = "create_id", Length = DbConsts.LengthS)]
public string? createId { get; set; }
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnName = "create_id", Length = DbConsts.LengthS)]
public string? createId { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[SugarColumn(ColumnName = "modify_time", Length = DbConsts.LengthS)]
public DateTime? modifyTime { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[SugarColumn(ColumnName = "modify_time", Length = DbConsts.LengthS)]
public DateTime? modifyTime { get; set; }
/// <summary>
/// 修改人
/// </summary>
[SugarColumn(ColumnName = "modify_id", Length = DbConsts.LengthS)]
public string? modifyId { get; set; }
/// <summary>
/// 主键
/// </summary>
public override object[] GetKeys()
{
return new object[] { id };
}
#endregion
/// <summary>
/// 修改人
/// </summary>
[SugarColumn(ColumnName = "modify_id", Length = DbConsts.LengthS)]
public string? modifyId { get; set; }
/// <summary>
/// 主键
/// </summary>
public override object[] GetKeys()
{
return new object[] { id };
}
#endregion
}