修复排序错误

This commit is contained in:
2023-11-16 14:55:37 +08:00
parent 5b49890a4f
commit a5f3d473e6
15 changed files with 261 additions and 154 deletions

View File

@@ -0,0 +1,23 @@
namespace Tnb.Vengine;
/// <summary>
/// 字典对象
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class VmodelAttribute : Attribute
{
public string? Id { get; set; }
public string? Area { get; set; }
public string? Code { get; set; }
public VmodelAttribute(string id)
{
Id = id;
}
public VmodelAttribute(string area, string? code)
{
Area = area;
Code = code;
}
}

View File

@@ -1,8 +1,9 @@
using SqlSugar;
using Tnb;
namespace JNPF.Common.Contracts;
public class BaseEntity<TKey> : IEntity where TKey : IEquatable<TKey>
public class BaseEntity<TKey> : Entity, IEntity where TKey : IEquatable<TKey>
{
/// <summary>
/// 获取或设置 编号.
@@ -10,6 +11,8 @@ public class BaseEntity<TKey> : IEntity where TKey : IEquatable<TKey>
[SugarColumn(ColumnName = "id", ColumnDescription = "主键", IsPrimaryKey = true)]
public TKey id { get; set; }
public override object[] GetKeys()
{
return [id];
}
}

View File

@@ -0,0 +1,30 @@
/////////////////////////////////////////////////////////////////////////////////
// 宁波拓通e智造平台 ToTong Next Builder //
// https://git.tuotong-tech.com/tnb/tnb.server //
/////////////////////////////////////////////////////////////////////////////////
using JNPF.Common.Contracts;
namespace Tnb;
[Serializable]
public abstract class Entity : IEntity
{
protected Entity()
{
//EntityHelper.TrySetTenantId(this);
}
/// <inheritdoc/>
public override string ToString()
{
return $"[ENTITY: {GetType().Name}] Keys = {string.Join(", ", GetKeys())}";
}
public abstract object[] GetKeys();
//public bool EntityEquals(IEntity other)
//{
// return EntityHelper.EntityEquals(this, other);
//}
}

View File

@@ -1,4 +1,7 @@
namespace Tnb.Core;
using Mapster;
using SqlSugar;
namespace Tnb.Core;
/// <summary>
/// 字典对象
@@ -13,33 +16,35 @@ public class DObject : Dictionary<string, object>
public DObject(Dictionary<string, object> dictionary) : base(dictionary)
{
}
public void AddCascade(string code, object value)
/// <summary>
/// 将平面结构转换为树形嵌套结构
/// </summary>
/// <param name="codePath">以.号分隔的多级路径</param>
/// <param name="value"></param>
public void AddToCascade(string codePath, object value)
{
var keys = code.Split('.');
var keys = codePath.Split('.');
if (keys.Length == 1)
{
Add(code, value);
Add(codePath, value);
return;
}
DObject temp = this;
for (int i = 0; i < keys.Length; i++)
{
DObject temp = this;
var key = keys[i];
if (i < keys.Length - 1)
{
if (!ContainsKey(keys[i]))
{
temp = new DObject();
Add(keys[i], temp);
}
else
{
temp = (DObject)temp[keys[i]];
}
var obj = new DObject();
temp[key] = obj;
temp = obj;
}
else
{
temp.Add(keys[i], value);
temp[key] = value;
}
}
}
}