模型查询接口增加按子表字段查询

This commit is contained in:
2023-11-02 17:42:12 +08:00
parent 29eb552d3b
commit 5dbbe60682
7 changed files with 205 additions and 49 deletions

View File

@@ -23,6 +23,8 @@ namespace Tnb.Vengine.Domain;
[SugarTable("sys_vmodel")]
public partial class Vmodel : Entity
{
public const string MAIN_ALIES = "m";
#region Properties
/// <summary>
@@ -146,7 +148,8 @@ public partial class Vmodel : Entity
}
#endregion Properties
//private Dictionary<string, string>? _mapField2Prop = null;
//private Dictionary<string, string>? _mapProp2Field = null;
/// <summary>
/// 通过实体创建模型
/// </summary>
@@ -351,11 +354,30 @@ public partial class Vmodel : Entity
if (filter == null) return wheres;
foreach (var item in filter)
{
VmDbProp? prop = null;
// TODO 按子表条件查询
if (item.Key.Contains("."))
{
var codes = item.Key.Split('.');
if (codes.Length >= 2)
{
var navProp = navProps.FirstOrDefault(a => a.code == codes[0]);
if (navProp != null && navProp.naviModel != null)
{
var dbProp = navProp.naviModel.dbProps.FirstOrDefault(a => a.code == codes[1]);
if (dbProp != null)
{
prop = new VmDbProp();
prop.field = codes[0] + "." + dbProp.field;
prop.csType = dbProp.csType;
}
}
}
}
else
{
prop = dbProps.FirstOrDefault(a => a.code == item.Key);
}
var prop = dbProps.FirstOrDefault(a => a.code == item.Key);
if (prop == null) continue;
if (item.Value is JArray val)
{