IczpNet.AbpTrees.Application.Contracts 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package IczpNet.AbpTrees.Application.Contracts --version 0.1.0                
NuGet\Install-Package IczpNet.AbpTrees.Application.Contracts -Version 0.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IczpNet.AbpTrees.Application.Contracts" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IczpNet.AbpTrees.Application.Contracts --version 0.1.0                
#r "nuget: IczpNet.AbpTrees.Application.Contracts, 0.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install IczpNet.AbpTrees.Application.Contracts as a Cake Addin
#addin nuget:?package=IczpNet.AbpTrees.Application.Contracts&version=0.1.0

// Install IczpNet.AbpTrees.Application.Contracts as a Cake Tool
#tool nuget:?package=IczpNet.AbpTrees.Application.Contracts&version=0.1.0                

IczpNet.AbpTrees

Create project by Abp Cli

abp new IczpNet.AbpTreesDemo -t module --no-ui

An abp module that provides standard tree structure entity implement.

Installation

Install the following NuGet packages. (see how)

  • IczpNet.AbpTrees.Domain
  • IczpNet.AbpTrees.Application
  • IczpNet.AbpTrees.Application.Contracts
  • IczpNet.AbpTrees.Domain.Shared

Add DependsOn(typeof(AbpTreesXxxModule)) attribute to configure the module dependencies.

  1. IczpNet.AbpTreesDemo.Domain

    F:\Dev\abpvnext\Iczp.AbpTrees\Example\src\IczpNet.AbpTreesDemo.Domain\AbpTreesDemoDomainModule.cs

    [DependsOn(typeof(AbpTreesDomainModule))]
    
  2. IczpNet.AbpTreesDemo.Domain.Shared

    [DependsOn(typeof(AbpTreesDomainSharedModule))]
    
  3. IczpNet.AbpTreesDemo.Application.Contracts

    [DependsOn(typeof(AbpTreesApplicationContractsModule))]
    
  4. IczpNet.AbpTreesDemo.Application

    [DependsOn(typeof(AbpTreesApplicationModule))]
    

Usage

Create a entity

  1. Create a entity [Department] and implement TreeEntity<T>.

    using IczpNet.AbpTrees;
    
    namespace IczpNet.AbpTreesDemo.Departments
    {
        public class Department : TreeEntity<Department>
        {
        }
    }
    
    

Create Model

  1. Create DepartmentInfo and implement TreeInfo in project IczpNet.AbpTreesDemo.Domain.Shared
using IczpNet.AbpTrees;

namespace IczpNet.AbpTreesDemo.Departments
{
    public class DepartmentInfo : TreeInfo
    {
    }
}

Repository

  1. IczpNet.AbpTreesDemo.EntityFrameworkCore AbpTreesDemoDbContext.cs
public DbSet<Department> Department { get; }
using IczpNet.AbpTreesDemo.Departments;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;

namespace IczpNet.AbpTreesDemo.EntityFrameworkCore;

[ConnectionStringName(AbpTreesDemoDbProperties.ConnectionStringName)]
public class AbpTreesDemoDbContext : AbpDbContext<AbpTreesDemoDbContext>, IAbpTreesDemoDbContext
{
    /* Add DbSet for each Aggregate Root here. Example:
     * public DbSet<Question> Questions { get; set; }
     */

    public AbpTreesDemoDbContext(DbContextOptions<AbpTreesDemoDbContext> options)
        : base(options)
    {

    }
    /// <summary>
    /// Department
    /// </summary>
    public DbSet<Department> Department { get; }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        builder.ConfigureAbpTreesDemo();
    }
}

  1. AbpTreesDemoDbContextModelCreatingExtensions.cs
using IczpNet.AbpTreesDemo.Departments;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace IczpNet.AbpTreesDemo.EntityFrameworkCore;

public static class AbpTreesDemoDbContextModelCreatingExtensions
{
    public static void ConfigureAbpTreesDemo(
        this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));

        builder.Entity<Department>(b =>
        {
            //Configure table & schema name
            b.ToTable(AbpTreesDemoDbProperties.DbTablePrefix + nameof(Department), AbpTreesDemoDbProperties.DbSchema);

            b.ConfigureByConvention();

            //Indexes
            b.HasIndex(q => q.CreationTime);

        });
    }
}

Create Dto

IczpNet.AbpTreesDemo.Application.Contracts

  1. DepartmentCreateInput
using IczpNet.AbpTrees.Dtos;
namespace IczpNet.AbpTreesDemo.Departments.Dtos;

/// <summary>
/// DepartmentCreateInput
/// </summary>
public class DepartmentCreateInput : DepartmentUpdateInput, ITreeInput
{

}

  1. DepartmentDto.cs
using IczpNet.AbpTreesDemo.Departments;
using System;
using Volo.Abp.Application.Dtos;

namespace IczpNet.AbpTreesDemo.Departments.Dtos
{
    /// <summary>
    /// DepartmentDto
    /// </summary>
    public class DepartmentDto : DepartmentInfo, IEntityDto<Guid>
    {
        /// <summary>
        /// 排序(越大越前面) DESC
        /// </summary>
        public virtual long Sorting { get; set; }
        /// <summary>
        /// 说明
        /// </summary>

        public virtual string Description { get; set; }
    }
}

  1. DepartmentGetAllListWithChildsInput.cs
using System;
using System.ComponentModel;

namespace IczpNet.AbpTreesDemo.Departments.Dtos;

/// <summary>
/// DepartmentGetListInput
/// </summary>
public class DepartmentGetAllListWithChildsInput 
{

    /// <summary>
    /// 上级部门
    /// </summary>
    [DefaultValue(null)]
    public virtual Guid? ParentId { get; set; }
    /// <summary>
    /// 是否包含所有子集
    /// </summary>
    public virtual bool IsImportAllChilds { get; set; }
}

  1. DepartmentGetListInput.cs
using IczpNet.AbpTrees;
using System;
using System.ComponentModel;
using Volo.Abp.Application.Dtos;

namespace IczpNet.AbpTreesDemo.Departments.Dtos;

/// <summary>
/// DepartmentGetListInput
/// </summary>
public class DepartmentGetListInput : PagedAndSortedResultRequestDto, ITreeGetListInput
{
    /// <summary>
    /// 
    /// </summary>
    [DefaultValue(false)]
    public virtual bool IsEnabledParentId { get; set; }
    /// <summary>
    /// 层级
    /// </summary>
    [DefaultValue(null)]
    public virtual int? Depth { get; set; }
    /// <summary>
    /// 上级部门
    /// </summary>
    [DefaultValue(null)]
    public virtual Guid? ParentId { get; set; }
    /// <summary>
    /// 关键字(支持拼音)
    /// </summary>
    [DefaultValue(null)]
    public virtual string Keyword { get; set; }
}

  1. DepartmentUpdateInput.cs
using IczpNet.AbpTrees.Dtos;
using System;

namespace IczpNet.AbpTreesDemo.Departments.Dtos;

/// <summary>
/// DepartmentUpdateInput
/// </summary>
public class DepartmentUpdateInput : ITreeInput
{

    /// <summary>
    /// 上级部门
    /// </summary>
    public virtual Guid? ParentId { get; set; }
    /// <summary>
    /// 名称
    /// </summary>
    public virtual string Name { get; set; }
    /// <summary>
    /// 排序(越大越前面) DESC
    /// </summary>
    public virtual long Sorting { get; set; }
    /// <summary>
    /// 说明
    /// </summary>
    public virtual string Description { get; set; }

}

  1. DepartmentWithChildsDto.cs
using IczpNet.AbpTrees;

namespace IczpNet.AbpTreesDemo.Departments.Dtos;

/// <summary>
/// DepartmentWithChildsDto
/// </summary>
public class DepartmentWithChildsDto : TreeWithChildsInfo<DepartmentWithChildsDto>
{
    public virtual int ChildsCount { get; set; }
}

  1. DepartmentWithParentDto.cs
using IczpNet.AbpTrees;

namespace IczpNet.AbpTreesDemo.Departments.Dtos;

/// <summary>
/// DepartmentWithParentDto
/// </summary>
public class DepartmentWithParentDto : TreeWithParentInfo<DepartmentWithParentDto>
{
    /// <summary>
    /// 排序(越大越前面) DESC
    /// </summary>
    public virtual long Sorting { get; set; }
    /// <summary>
    /// 说明
    /// </summary>
    public virtual string Description { get; set; }
}

interface CRUD

IDepartmentAppSevice and implement ICrudAppService, ITreeAppService

using IczpNet.AbpTrees;
using System;
using Volo.Abp.Application.Services;

namespace IczpNet.AbpTreesDemo.Departments
{
    public interface IDepartmentAppSevice<TGetOutputDto, TGetListOutputDto, TGetListInput, TCreateInput, TUpdateInput, TTreeInfo, TTreeWithChildsDto, TTreeWithParentDto>
        : ICrudAppService<TGetOutputDto, TGetListOutputDto, Guid, TGetListInput, TCreateInput, TUpdateInput>
        , ITreeAppService<TTreeInfo, TTreeWithChildsDto, TTreeWithParentDto>
         where TTreeInfo : ITreeInfo
        where TTreeWithChildsDto : ITreeWithChildsInfo<TTreeWithChildsDto>
        where TTreeWithParentDto : ITreeWithParentInfo<TTreeWithParentDto>
    {
    }
}

Application CRUD

IczpNet.AbpTreesDemo.Application > DepartmentAppsevice.cs

using IczpNet.AbpTrees;
using IczpNet.AbpTreesDemo.Departments;
using IczpNet.AbpTreesDemo.Departments.Dtos;
using System;
using Volo.Abp.Domain.Repositories;

namespace IczpNet.AbpTreesDemo.Departments
{
    public class DepartmentAppService : TreeAppService<Department, DepartmentDto, DepartmentDto, DepartmentGetListInput, DepartmentCreateInput, DepartmentUpdateInput, DepartmentInfo, DepartmentWithChildsDto, DepartmentWithParentDto>, IDepartmentAppSevice<DepartmentDto, DepartmentDto, DepartmentGetListInput, DepartmentCreateInput, DepartmentUpdateInput, DepartmentInfo, DepartmentWithChildsDto, DepartmentWithParentDto>
    {
        public DepartmentAppService(IRepository<Department, Guid> repository) : base(repository)
        {
        }
    }
}

Dto Mapper

AbpTreesDemoApplicationAutoMapperProfile

using AutoMapper;
using IczpNet.AbpTreesDemo.Departments;
using IczpNet.AbpTreesDemo.Departments.Dtos;
using Volo.Abp.AutoMapper;

namespace IczpNet.AbpTreesDemo;

public class AbpTreesDemoApplicationAutoMapperProfile : Profile
{
    public AbpTreesDemoApplicationAutoMapperProfile()
    {
        /* You can configure your AutoMapper mapping configuration here.
         * Alternatively, you can split your mapping configurations
         * into multiple profile classes for a better organization. */

        CreateMap<Department, DepartmentDto>(MemberList.Destination);
        CreateMap<Department, DepartmentWithParentDto>(MemberList.Destination);
        CreateMap<Department, DepartmentWithChildsDto>(MemberList.Destination)
             .ForMember(s => s.ChildsCount, map => map.MapFrom(d => d.GetChildsCount()))
             //.ForMember(s => s.UserCount, map => map.MapFrom(d => d.GetUserCount()))
             ;
        CreateMap<DepartmentCreateInput, Department>(MemberList.Source).IgnoreAllPropertiesWithAnInaccessibleSetter();
        CreateMap<DepartmentUpdateInput, Department>(MemberList.Source).IgnoreAllPropertiesWithAnInaccessibleSetter();


        CreateMap<Department, DepartmentInfo>();
        CreateMap<DepartmentInfo, DepartmentWithChildsDto>()
            .Ignore(x => x.ChildsCount)
            .Ignore(x => x.Childs);
    }
}

Add-Migration IczpNet.AbpTreesDemo.HttpApi.Host

  1. Select Project IczpNet.AbpTreesDemo.HttpApi.Host, Set Run Start.

  2. Open PM

    PM> Add-Migration Department_Init
    
    PM> Update-Database
    
  3. Add Controller AbpTreesDemoHttpApiHostModule.cs

    ...
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
    //...
            Configure<AbpAspNetCoreMvcOptions>(options =>
            {
                options
                    .ConventionalControllers
                    .Create(typeof(AbpTreesDemoApplicationModule).Assembly);
            });
      //...
    }
    
    ...
    
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on IczpNet.AbpTrees.Application.Contracts:

Package Downloads
IczpNet.AbpTrees.Application

copyright (c) www.iczp.net

IczpNet.Organization.Application.Contracts

Package Description

IczpNet.Chat.Application.Contracts

IczpNet.Chat

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.2.0.2 21 7/17/2024
8.2.0.1 33 7/16/2024
0.2.4 127 2/7/2024
0.2.3 94 2/6/2024
0.2.2 90 2/5/2024
0.2.1 211 7/14/2023
0.2.0 175 7/14/2023
0.1.21 155 6/28/2023
0.1.20 182 6/21/2023
0.1.19 165 6/21/2023
0.1.18 186 6/20/2023
0.1.17 177 6/19/2023
0.1.16 205 6/7/2023
0.1.15 165 6/7/2023
0.1.14 194 5/30/2023
0.1.13 165 5/23/2023
0.1.12 228 4/21/2023
0.1.11 232 4/21/2023
0.1.10 204 4/8/2023
0.1.9 232 4/3/2023
0.1.8 239 3/24/2023
0.1.7 266 3/3/2023
0.1.6 416 11/24/2022
0.1.5 408 11/19/2022
0.1.4 608 11/18/2022
0.1.3 439 11/14/2022
0.1.2 436 11/14/2022
0.1.1 454 11/14/2022
0.1.0 472 11/14/2022