完善通用接口输入参数
This commit is contained in:
@@ -24,6 +24,7 @@ namespace Tnb.Vengine.Domain;
|
||||
public partial class Vmodel : Entity
|
||||
{
|
||||
private static string[] SOFT_DELETED = new string[] { "deleted", "isDeleted", "softDeleted" };
|
||||
private static string[] AUTO_FILL_PROP = new string[] { "createTime", "createId", "updateTime", "modifyTime", "updateId", "modifyId" };
|
||||
|
||||
#region Properties
|
||||
|
||||
@@ -195,7 +196,7 @@ public partial class Vmodel : Entity
|
||||
/// <returns></returns>
|
||||
public VmDbProp GetPrimary()
|
||||
{
|
||||
var key = dbProps.FirstOrDefault(a => a.pkey);
|
||||
var key = dbProps.FirstOrDefault(a => a.pkey);
|
||||
ThrowIf.IsNull(key, $"模型({fullCode})没有定义主键属性");
|
||||
return key;
|
||||
}
|
||||
@@ -238,7 +239,7 @@ public partial class Vmodel : Entity
|
||||
/// <returns></returns>
|
||||
public DObject GetDefaultDObject()
|
||||
{
|
||||
DObject obj = new ();
|
||||
DObject obj = new();
|
||||
foreach (VmDbProp p in dbProps)
|
||||
{
|
||||
obj.Add(p.code, p.GetDefaultValue()!);
|
||||
@@ -246,13 +247,30 @@ public partial class Vmodel : Entity
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取属性字符串
|
||||
/// </summary>
|
||||
/// <param name="isCreate"></param>
|
||||
/// <returns></returns>
|
||||
public string GetPropStr(bool includePkey, bool includeAutoProp)
|
||||
{
|
||||
var strs = new List<string>();
|
||||
foreach (var col in dbProps.OrderBy(a => a.ordinal))
|
||||
{
|
||||
if (!includeAutoProp && AUTO_FILL_PROP.Contains(col.code)) continue;
|
||||
if (!includePkey && col.pkey) continue;
|
||||
strs.Add(col.GetCsType() + " " + col.code);
|
||||
}
|
||||
return string.Join(", ", strs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转换为待新增的实体对象
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DObject ToCreateEntity(DObject input, IUserManager user)
|
||||
{
|
||||
DObject obj = new ();
|
||||
DObject obj = new();
|
||||
foreach (VmDbProp p in dbProps)
|
||||
{
|
||||
if (input.ContainsKey(p.code))
|
||||
@@ -286,7 +304,7 @@ public partial class Vmodel : Entity
|
||||
/// <returns></returns>
|
||||
public DObject ToUpdateEntity(DObject input, IUserManager user)
|
||||
{
|
||||
DObject obj = new ();
|
||||
DObject obj = new();
|
||||
foreach (VmDbProp p in dbProps)
|
||||
{
|
||||
if (input.ContainsKey(p.code))
|
||||
|
||||
Reference in New Issue
Block a user