Browse Source

Merge pull request #23623 from abpframework/mapperly-tenant-management

Replace `AutoMapper` with `Mapperly` inTenant Management module
pull/23638/head
Ma Liming 1 year ago
committed by GitHub
parent
commit
fdb639770b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 12
      modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/AbpTenantManagementApplicationAutoMapperProfile.cs
  2. 13
      modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/AbpTenantManagementApplicationMapperlyMappers.cs
  3. 7
      modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/AbpTenantManagementApplicationModule.cs
  4. 12
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorAutoMapperProfile.cs
  5. 16
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorMapperlyMappers.cs
  6. 11
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorModule.cs
  7. 2
      modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Volo.Abp.TenantManagement.Blazor.csproj
  8. 2
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo.Abp.TenantManagement.Domain.csproj
  9. 47
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMapperlyMappers.cs
  10. 36
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs
  11. 11
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainModule.cs
  12. 22
      modules/tenant-management/src/Volo.Abp.TenantManagement.Web/AbpTenantManagementWebAutoMapperProfile.cs
  13. 50
      modules/tenant-management/src/Volo.Abp.TenantManagement.Web/AbpTenantManagementWebMapperlyMappers.cs
  14. 12
      modules/tenant-management/src/Volo.Abp.TenantManagement.Web/AbpTenantManagementWebModule.cs
  15. 2
      modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Volo.Abp.TenantManagement.Web.csproj

12
modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/AbpTenantManagementApplicationAutoMapperProfile.cs

@ -1,12 +0,0 @@
using AutoMapper;
namespace Volo.Abp.TenantManagement;
public class AbpTenantManagementApplicationAutoMapperProfile : Profile
{
public AbpTenantManagementApplicationAutoMapperProfile()
{
CreateMap<Tenant, TenantDto>()
.MapExtraProperties();
}
}

13
modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/AbpTenantManagementApplicationMapperlyMappers.cs

@ -0,0 +1,13 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace Volo.Abp.TenantManagement.Application.Volo.Abp.TenantManagement;
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
[MapExtraProperties]
public partial class TenantToTenantDtoMapper
: MapperBase<Tenant, TenantDto>
{
public override partial TenantDto Map(Tenant source);
public override partial void Map(Tenant source, TenantDto destination);
}

7
modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/AbpTenantManagementApplicationModule.cs

@ -1,6 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Application;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
namespace Volo.Abp.TenantManagement;
@ -12,10 +11,6 @@ public class AbpTenantManagementApplicationModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<AbpTenantManagementApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpTenantManagementApplicationAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<AbpTenantManagementApplicationModule>();
}
}

12
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorAutoMapperProfile.cs

@ -1,12 +0,0 @@
using AutoMapper;
namespace Volo.Abp.TenantManagement.Blazor;
public class AbpTenantManagementBlazorAutoMapperProfile : Profile
{
public AbpTenantManagementBlazorAutoMapperProfile()
{
CreateMap<TenantDto, TenantUpdateDto>()
.MapExtraProperties();
}
}

16
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorMapperlyMappers.cs

@ -0,0 +1,16 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace Volo.Abp.TenantManagement.Blazor;
[Mapper]
[MapExtraProperties]
public partial class TenantDtoToTenantUpdateDtoMapper
: MapperBase<TenantDto, TenantUpdateDto>
{
[MapperIgnoreSource(nameof(TenantDto.Id))]
public override partial TenantUpdateDto Map(TenantDto source);
[MapperIgnoreSource(nameof(TenantDto.Id))]
public override partial void Map(TenantDto source, TenantUpdateDto destination);
}

11
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/AbpTenantManagementBlazorModule.cs

@ -1,7 +1,7 @@
using Localization.Resources.AbpUi;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.FeatureManagement.Blazor;
using Volo.Abp.FeatureManagement.Localization;
using Volo.Abp.Localization;
@ -16,7 +16,7 @@ using Volo.Abp.UI.Navigation;
namespace Volo.Abp.TenantManagement.Blazor;
[DependsOn(
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpTenantManagementApplicationContractsModule),
typeof(AbpFeatureManagementBlazorModule)
)]
@ -26,12 +26,7 @@ public class AbpTenantManagementBlazorModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<AbpTenantManagementBlazorModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpTenantManagementBlazorAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<AbpTenantManagementBlazorModule>();
Configure<AbpNavigationOptions>(options =>
{

2
modules/tenant-management/src/Volo.Abp.TenantManagement.Blazor/Volo.Abp.TenantManagement.Blazor.csproj

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Mapperly\Volo.Abp.Mapperly.csproj" />
</ItemGroup>
<ItemGroup>

2
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo.Abp.TenantManagement.Domain.csproj

@ -17,7 +17,7 @@
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.TenantManagement.Domain.Shared\Volo.Abp.TenantManagement.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Mapperly\Volo.Abp.Mapperly.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Data\Volo.Abp.Data.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.MultiTenancy\Volo.Abp.MultiTenancy.csproj" />

47
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMapperlyMappers.cs

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Data;
using Volo.Abp.Mapperly;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.TenantManagement.Domain.Volo.Abp.TenantManagement;
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class TenantToTenantConfigurationMapper
: MapperBase<Tenant, TenantConfiguration>
{
[MapperIgnoreTarget(nameof(TenantConfiguration.EditionId))]
[MapperIgnoreTarget(nameof(TenantConfiguration.IsActive))]
public override partial TenantConfiguration Map(Tenant source);
[MapperIgnoreTarget(nameof(TenantConfiguration.EditionId))]
[MapperIgnoreTarget(nameof(TenantConfiguration.IsActive))]
public override partial void Map(Tenant source, TenantConfiguration destination);
protected virtual ConnectionStrings Map(List<TenantConnectionString> source)
{
var connStrings = new ConnectionStrings();
if (source == null)
{
return connStrings;
}
foreach (var connectionString in source)
{
connStrings[connectionString.Name] = connectionString.Value;
}
return connStrings;
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class TenantToTenantEtoMapper
: MapperBase<Tenant, TenantEto>
{
public override partial TenantEto Map(Tenant source);
public override partial void Map(Tenant source, TenantEto destination);
}

36
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMappingProfile.cs

@ -1,36 +0,0 @@
using AutoMapper;
using Volo.Abp.Data;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.TenantManagement;
public class AbpTenantManagementDomainMappingProfile : Profile
{
public AbpTenantManagementDomainMappingProfile()
{
CreateMap<Tenant, TenantConfiguration>()
.ForMember(ti => ti.ConnectionStrings, opts =>
{
opts.MapFrom((tenant, ti) =>
{
var connStrings = new ConnectionStrings();
if (tenant.ConnectionStrings == null)
{
return connStrings;
}
foreach (var connectionString in tenant.ConnectionStrings)
{
connStrings[connectionString.Name] = connectionString.Value;
}
return connStrings;
});
})
.ForMember(x => x.IsActive, x => x.Ignore())
.ForMember(x => x.EditionId, x => x.Ignore());
CreateMap<Tenant, TenantEto>();
}
}

11
modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainModule.cs

@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Abp.Domain;
@ -16,7 +16,7 @@ namespace Volo.Abp.TenantManagement;
[DependsOn(typeof(AbpTenantManagementDomainSharedModule))]
[DependsOn(typeof(AbpDataModule))]
[DependsOn(typeof(AbpDddDomainModule))]
[DependsOn(typeof(AbpAutoMapperModule))]
[DependsOn(typeof(AbpMapperlyModule))]
[DependsOn(typeof(AbpCachingModule))]
public class AbpTenantManagementDomainModule : AbpModule
{
@ -24,12 +24,7 @@ public class AbpTenantManagementDomainModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<AbpTenantManagementDomainModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpTenantManagementDomainMappingProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<AbpTenantManagementDomainModule>();
Configure<AbpDistributedEntityEventOptions>(options =>
{

22
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/AbpTenantManagementWebAutoMapperProfile.cs

@ -1,22 +0,0 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.Abp.TenantManagement.Web.Pages.TenantManagement.Tenants;
namespace Volo.Abp.TenantManagement.Web;
public class AbpTenantManagementWebAutoMapperProfile : Profile
{
public AbpTenantManagementWebAutoMapperProfile()
{
//List
CreateMap<TenantDto, EditModalModel.TenantInfoModel>();
//CreateModal
CreateMap<CreateModalModel.TenantInfoModel, TenantCreateDto>()
.MapExtraProperties();
//EditModal
CreateMap<EditModalModel.TenantInfoModel, TenantUpdateDto>()
.MapExtraProperties();
}
}

50
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/AbpTenantManagementWebMapperlyMappers.cs

@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Riok.Mapperly.Abstractions;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Mapperly;
using Volo.Abp.TenantManagement.Web.Pages.TenantManagement.Tenants;
namespace Volo.Abp.TenantManagement.Web;
[Mapper]
[MapExtraProperties]
public partial class TenantDtoToTenantInfoModelMapper
: MapperBase<TenantDto, EditModalModel.TenantInfoModel>
{
public override partial EditModalModel.TenantInfoModel Map(TenantDto source);
public override partial void Map(TenantDto source, EditModalModel.TenantInfoModel destination);
}
[Mapper]
[MapExtraProperties]
public partial class CreateTenantInfoModelToTenantCreateDtoMapper
: TwoWayMapperBase<CreateModalModel.TenantInfoModel, TenantCreateDto>
{
public override partial TenantCreateDto Map(CreateModalModel.TenantInfoModel source);
public override partial void Map(CreateModalModel.TenantInfoModel source, TenantCreateDto destination);
public override partial CreateModalModel.TenantInfoModel ReverseMap(TenantCreateDto source);
public override partial void ReverseMap(TenantCreateDto source, CreateModalModel.TenantInfoModel destination);
}
[Mapper]
[MapExtraProperties]
public partial class TenantInfoModelToTenantUpdateDtoMapper
: MapperBase<EditModalModel.TenantInfoModel, TenantUpdateDto>
{
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.Id))]
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.ConcurrencyStamp))]
[MapperIgnoreTarget(nameof(TenantUpdateDto.ConcurrencyStamp))]
public override partial TenantUpdateDto Map(EditModalModel.TenantInfoModel source);
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.Id))]
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.ConcurrencyStamp))]
[MapperIgnoreTarget(nameof(TenantUpdateDto.ConcurrencyStamp))]
public override partial void Map(EditModalModel.TenantInfoModel source, TenantUpdateDto destination);
}

12
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/AbpTenantManagementWebModule.cs

@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.FeatureManagement;
using Volo.Abp.Http.ProxyScripting.Generators.JQuery;
using Volo.Abp.Localization;
@ -21,7 +21,7 @@ namespace Volo.Abp.TenantManagement.Web;
[DependsOn(typeof(AbpTenantManagementApplicationContractsModule))]
[DependsOn(typeof(AbpAspNetCoreMvcUiBootstrapModule))]
[DependsOn(typeof(AbpFeatureManagementWebModule))]
[DependsOn(typeof(AbpAutoMapperModule))]
[DependsOn(typeof(AbpMapperlyModule))]
public class AbpTenantManagementWebModule : AbpModule
{
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
@ -41,6 +41,8 @@ public class AbpTenantManagementWebModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddMapperlyObjectMapper<AbpTenantManagementWebModule>();
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new AbpTenantManagementWebMainMenuContributor());
@ -51,12 +53,6 @@ public class AbpTenantManagementWebModule : AbpModule
options.FileSets.AddEmbedded<AbpTenantManagementWebModule>();
});
context.Services.AddAutoMapperObjectMapper<AbpTenantManagementWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpTenantManagementWebAutoMapperProfile>(validate: true);
});
Configure<RazorPagesOptions>(options =>
{
options.Conventions.AuthorizePage("/TenantManagement/Tenants/Index", TenantManagementPermissions.Tenants.Default);

2
modules/tenant-management/src/Volo.Abp.TenantManagement.Web/Volo.Abp.TenantManagement.Web.csproj

@ -35,7 +35,7 @@
<ProjectReference Include="..\..\..\feature-management\src\Volo.Abp.FeatureManagement.Web\Volo.Abp.FeatureManagement.Web.csproj" />
<ProjectReference Include="..\Volo.Abp.TenantManagement.Application.Contracts\Volo.Abp.TenantManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AutoMapper\Volo.Abp.AutoMapper.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Mapperly\Volo.Abp.Mapperly.csproj" />
</ItemGroup>
<ItemGroup>

Loading…
Cancel
Save