diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
index a7dd4771..2e26584c 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
@@ -218,7 +218,7 @@
-
+
停止任务
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs
index b188ef9b..a7fb4a16 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/TestController.cs
@@ -165,7 +165,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{JobConst.method,"get" },
{JobConst.url,"https://www.baidu.com" }
};
- await _quartzInvoker.StartAsync("*/5 * * * * ?", "HttpJob",jobName:"test",jobGroup:"my", data: data);
+ await _quartzInvoker.StartAsync("*/5 * * * * ?", "HttpJob", jobName: "test", jobGroup: "my", data: data);
return Result.Success();
}
@@ -174,10 +174,27 @@ namespace Yi.Framework.ApiMicroservice.Controllers
///
///
[HttpPut]
- public async Task stopJob()
+ public async Task StopJob()
{
await _quartzInvoker.StopAsync(new Quartz.JobKey("test", "my"));
return Result.Success();
}
+
+ ///
+ /// 树形结构测试
+ ///
+ ///
+ [HttpGet]
+ public Result TreeTest()
+ {
+ List vueRouterModels = new()
+ {
+ new VueRouterModel { Id = 1, Sort = 1, ParentId = 0, Name = "001" },
+ new VueRouterModel { Id = 2, Sort = 1, ParentId = 1, Name = "001001" },
+ new VueRouterModel { Id = 3, Sort = 1, ParentId = 1, Name = "001002" }
+ };
+ var treeData = Common.Helper.TreeHelper.SetTree(vueRouterModels);
+ return Result.Success().SetData(treeData);
+ }
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs b/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs
index 85f49f26..b6b9c03f 100644
--- a/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Helper/TreeHelper.cs
@@ -14,8 +14,8 @@ namespace Yi.Framework.Common.Helper
if (list != null && list.Count > 0)
{
IList result = new List();
- long pid = list.Min(m => (m as ITreeModel).parentId);
- IList t = list.Where(m => (m as ITreeModel).parentId == pid).ToList();
+ long pid = list.Min(m => (m as ITreeModel).ParentId);
+ IList t = list.Where(m => (m as ITreeModel).ParentId == pid).ToList();
foreach (T model in t)
{
if (action != null)
@@ -24,35 +24,35 @@ namespace Yi.Framework.Common.Helper
}
result.Add(model);
var item = (model as ITreeModel);
- IList children = list.Where(m => (m as ITreeModel).parentId == item.id).ToList();
+ IList children = list.Where(m => (m as ITreeModel).ParentId == item.Id).ToList();
if (children.Count > 0)
{
SetTreeChildren(list, children, model, action);
}
}
- return result.OrderBy(m => (m as ITreeModel).sort).ToList();
+ return result.OrderBy(m => (m as ITreeModel).Sort).ToList();
}
return null;
}
private static void SetTreeChildren(IList list, IList children, T model, Action action = null)
{
var mm = (model as ITreeModel);
- mm.children = new List();
+ mm.Children = new List();
foreach (T item in children)
{
if (action != null)
{
action(item);
}
- mm.children.Add(item);
+ mm.Children.Add(item);
var _item = (item as ITreeModel);
- IList _children = list.Where(m => (m as ITreeModel).parentId == _item.id).ToList();
+ IList _children = list.Where(m => (m as ITreeModel).ParentId == _item.Id).ToList();
if (_children.Count > 0)
{
SetTreeChildren(list, _children, item, action);
}
}
- mm.children = mm.children.OrderBy(m => (m as ITreeModel).sort).ToList();
+ mm.Children = mm.Children.OrderBy(m => (m as ITreeModel).Sort).ToList();
}
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/ITreeModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/ITreeModel.cs
index 8bc92a00..be450770 100644
--- a/Yi.Framework.Net6/Yi.Framework.Common/Models/ITreeModel.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/ITreeModel.cs
@@ -8,10 +8,10 @@ namespace Yi.Framework.Common.Models
{
public interface ITreeModel
{
- public int id { get; set; }
- public int parentId { get; set; }
- public int sort { get; set; }
+ public int Id { get; set; }
+ public int ParentId { get; set; }
+ public int Sort { get; set; }
- public IList children { get; set; }
+ public IList Children { get; set; }
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/VueRouterModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/VueRouterModel.cs
new file mode 100644
index 00000000..ed1fb350
--- /dev/null
+++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/VueRouterModel.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Yi.Framework.Common.Models
+{
+ public class VueRouterModel : ITreeModel
+ {
+ public int Id { get; set; }
+ public int ParentId { get; set; }
+ public int Sort { get; set; }
+
+ public string Name { get; set; }
+ public string Path { get; set; }
+ public bool Hidden { get; set; }
+ public string Redirect { get; set; }
+ public string Component { get; set; }
+ public bool AlwaysShow { get; set; }
+ public Meta Meta { get; set; }
+ public IList Children { get; set; }
+ }
+
+
+ public class Meta
+ {
+ public string Title { get; set; }
+ public string Icon { get; set; }
+ public string NoCache { get; set; }
+ public string link { get; set; }
+ }
+}