Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/EasyAbp/Abp.Trees
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlcf88 committed Apr 13, 2024
2 parents 7ca675f + 27d09f4 commit 1c47483
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 13 deletions.
11 changes: 11 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ An abp module that provides standard tree structure entity implement.
options.TreeEntity<Resource>(x => x.CodeLength = 10);//set CodeLength for each Entity(Default:5)
});
```
## CheckPoints

1.Check the module `DependsOn(typeof(AbpTreesXxxModule))` dependencies are config

`XxxEntityFrameworkCoreModule`, `XxxDomainSharedModule`, `XxxDomainModule`

2.Check `IYourRepository : ITreeRepository<YourEntity>`

3.Be sure `YourEntity:XxxEntity<Guid>,ITree<YourEntity>`

4.Be sure `XxxEntityFrameworkCoreModule` has config `options.AddDefaultTreeRepositories();`

## Sample

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/EasyAbp.Abp.Trees.Domain/EasyAbp/Abp/Trees/ITree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface ITree<TEntity> : IEntity<Guid>
string Code { get; set; }
int Level { get; set; }
Guid? ParentId { get; set; }
TEntity Parent { get; set; }
TEntity? Parent { get; set; }
ICollection<TEntity> Children { get; set; }
string DisplayName { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace />
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>EasyAbp.Abp.Trees</RootNamespace>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>EasyAbp.Abp.Trees</RootNamespace>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Xunit;

namespace EasyAbp.Abp.Trees.Samples
{
public class TreeRepository_Tests : TreesDomainTestBase
{
private readonly ITreeRepository<OrganizationUnit> _treeRepository;
private readonly IGuidGenerator _guidGenerator;
public TreeRepository_Tests()
{
_treeRepository = GetRequiredService<ITreeRepository<OrganizationUnit>>();
_guidGenerator = GetRequiredService<IGuidGenerator>();
}

[Fact]
Expand All @@ -23,8 +26,8 @@ await WithUnitOfWorkAsync(async () =>
{
List<OrganizationUnit> testDatas = new List<OrganizationUnit>()
{
new OrganizationUnit(){DisplayName="1" },
new OrganizationUnit(){DisplayName="2" }
new OrganizationUnit(_guidGenerator.Create()){DisplayName="1" },
new OrganizationUnit(_guidGenerator.Create()){DisplayName="2" }
};
foreach (var d in testDatas)
{
Expand All @@ -48,8 +51,8 @@ await WithUnitOfWorkAsync(async () =>
{
List<OrganizationUnit> testDatas = new List<OrganizationUnit>()
{
new OrganizationUnit(){DisplayName="1" },
new OrganizationUnit(){DisplayName="2" }
new OrganizationUnit(_guidGenerator.Create()){DisplayName="1" },
new OrganizationUnit(_guidGenerator.Create()){DisplayName="2" }
};

await _treeRepository.InsertManyAsync(testDatas);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>EasyAbp.Abp.Trees</RootNamespace>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<RootNamespace>EasyAbp.Abp.Trees</RootNamespace>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ namespace EasyAbp.Abp.Trees.TestApp.Domain
{
public class OrganizationUnit : AggregateRoot<Guid>, ITree<OrganizationUnit>
{
public OrganizationUnit() { }
public OrganizationUnit(Guid id)
: base(id)
{
Children = new List<OrganizationUnit>();
}
public virtual string DisplayName { get; set; }
public virtual string Code { get; set; }
public virtual string DisplayName { get; set; } = null!;
public virtual string Code { get; set; } = null!;
public virtual int Level { get; set; }
public virtual OrganizationUnit Parent { get; set; }
public virtual OrganizationUnit? Parent { get; set; }
public virtual Guid? ParentId { get; set; }
public virtual ICollection<OrganizationUnit> Children { get; set; }
}
Expand Down
7 changes: 3 additions & 4 deletions test/EasyAbp.Abp.Trees.TestBase/TestApp/Domain/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ public Resource(Guid id)
{
Children = new List<Resource>();
}
public string DisplayName { get; set; }
public virtual string Code { get; set; }
public string DisplayName { get; set; } = null!;
public virtual string Code { get; set; } = null!;
public virtual int Level { get; set; }
public virtual Resource Parent { get; set; }
public virtual Resource? Parent { get; set; }
public virtual Guid? ParentId { get; set; }
public virtual ICollection<Resource> Children { get; set; }
public virtual string Path { get; set; }
}
}

0 comments on commit 1c47483

Please sign in to comment.