树形构造器修改

This commit is contained in:
chenchun
2022-09-11 16:49:40 +08:00
parent ef35e1cfd9
commit c65e76bbc3
15 changed files with 62 additions and 36 deletions

View File

@@ -9,7 +9,7 @@ namespace Yi.Framework.Common.Helper
{
public static class TreeHelper
{
public static IList<T> SetTree<T>(IList<T> list, Action<T> action = null)
public static List<T> SetTree<T>(List<T> list, Action<T> action = null)
{
if (list != null && list.Count > 0)
{
@@ -30,7 +30,7 @@ namespace Yi.Framework.Common.Helper
SetTreeChildren(list, children, model, action);
}
}
return result.OrderBy(m => (m as ITreeModel<T>).Sort).ToList();
return result.OrderBy(m => (m as ITreeModel<T>).OrderNum).ToList();
}
return null;
}
@@ -52,7 +52,7 @@ namespace Yi.Framework.Common.Helper
SetTreeChildren(list, _children, item, action);
}
}
mm.Children = mm.Children.OrderBy(m => (m as ITreeModel<T>).Sort).ToList();
mm.Children = mm.Children.OrderBy(m => (m as ITreeModel<T>).OrderNum).ToList();
}
}
}

View File

@@ -8,10 +8,10 @@ namespace Yi.Framework.Common.Models
{
public interface ITreeModel<T>
{
public int Id { get; set; }
public int ParentId { get; set; }
public int Sort { get; set; }
public long Id { get; set; }
public long ParentId { get; set; }
public int OrderNum { get; set; }
public IList<T> Children { get; set; }
public List<T> Children { get; set; }
}
}

View File

@@ -8,9 +8,9 @@ namespace Yi.Framework.Common.Models
{
public class VueRouterModel : ITreeModel<VueRouterModel>
{
public int Id { get; set; }
public int ParentId { get; set; }
public int Sort { get; set; }
public long Id { get; set; }
public long ParentId { get; set; }
public int OrderNum { get; set; }
public string Name { get; set; }
public string Path { get; set; }
@@ -19,7 +19,7 @@ namespace Yi.Framework.Common.Models
public string Component { get; set; }
public bool AlwaysShow { get; set; }
public Meta Meta { get; set; }
public IList<VueRouterModel> Children { get; set; }
public List<VueRouterModel> Children { get; set; }
}