Skip to content

Commit

Permalink
优化实体树控制器,直接支持设备分组等树形实体类
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 30, 2023
1 parent 9353e85 commit 7fa21a5
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CubeDemo/CubeDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2023.804-beta1202" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2023.829-beta0552" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion CubeDemoNC/CubeDemoNC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="7.0.10" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2023.804-beta1202" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2023.829-beta0552" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions CubeSSO/CubeSSO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.5.2023.806-beta1039" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2023.804-beta1202" />
<PackageReference Include="NewLife.Core" Version="10.5.2023.824-beta1618" />
<PackageReference Include="NewLife.Stardust.Extensions" Version="2.9.2023.829-beta0552" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion NewLife.Cube.Blazor/NewLife.Cube.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="BootstrapBlazor" Version="7.9.2" />
<PackageReference Include="BootstrapBlazor" Version="7.9.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions NewLife.Cube/NewLife.Cube.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@
<Compile Include="..\NewLife.CubeNC\WebMiddleware\TenantMiddleware.cs" Link="WebMiddleware\TenantMiddleware.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.Core" Version="10.5.2023.806-beta1039" />
<PackageReference Include="NewLife.Core" Version="10.5.2023.824-beta1618" />
<PackageReference Include="NewLife.IP" Version="2.1.2023.704-beta0221" />
<PackageReference Include="NewLife.Stardust" Version="2.9.2023.804-beta1202" />
<PackageReference Include="NewLife.XCode" Version="11.9.2023.823-beta1153" />
<PackageReference Include="NewLife.Stardust" Version="2.9.2023.829-beta0552" />
<PackageReference Include="NewLife.XCode" Version="11.9.2023.829-beta0727" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 0 additions & 21 deletions NewLife.CubeNC/Areas/Admin/Controllers/MenuController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,4 @@ static MenuController()
// 过滤要显示的字段
ListFields.RemoveField("Remark");
}

/// <summary>验证实体对象</summary>
/// <param name="entity"></param>
/// <param name="type"></param>
/// <param name="post"></param>
/// <returns></returns>
protected override Boolean Valid(Menu entity, DataObjectMethodType type, Boolean post)
{
var rs = base.Valid(entity, type, post);

// 清空缓存
if (post) XCode.Membership.Menu.Meta.Session.ClearCache($"{type}-{entity}", true);

return rs;
}

public override void OnActionExecuting(ActionExecutingContext filterContext)
{
ViewBag.Fields = OnGetFields(ViewKinds.List, null);
base.OnActionExecuting(filterContext);
}
}
25 changes: 25 additions & 0 deletions NewLife.CubeNC/Common/EntityTreeController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel;
using System.Reflection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using NewLife.Cube.ViewModels;
using NewLife.Reflection;
using NewLife.Web;
Expand Down Expand Up @@ -54,6 +55,30 @@ static EntityTreeController()
//ListFields.AddRange(list);
}

/// <summary>验证实体对象</summary>
/// <param name="entity"></param>
/// <param name="type"></param>
/// <param name="post"></param>
/// <returns></returns>
protected override Boolean Valid(TEntity entity, DataObjectMethodType type, Boolean post)
{
var rs = base.Valid(entity, type, post);

// 清空缓存
if (post) Factory.Session.ClearCache($"{type}-{entity}", true);

return rs;
}

/// <summary>设置字段列表</summary>
/// <param name="filterContext"></param>
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
ViewBag.Fields = OnGetFields(ViewKinds.List, null);

base.OnActionExecuting(filterContext);
}

/// <summary>列表页视图。子控制器可重载,以传递更多信息给视图,比如修改要显示的列</summary>
/// <param name="p"></param>
/// <returns></returns>
Expand Down
2 changes: 1 addition & 1 deletion Test/Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
<None Remove="Entity\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.XCode" Version="11.9.2023.823-beta1153" />
<PackageReference Include="NewLife.XCode" Version="11.9.2023.829-beta0727" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion XUnitTest/XUnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down

0 comments on commit 7fa21a5

Please sign in to comment.