Browse Source

Convert mappers to mapperly for TenantManagement

pull/23623/head
Enis Necipoglu 1 year ago
parent
commit
17bc460156
No known key found for this signature in database GPG Key ID: 1EC55E13241E1680
  1. 12
      modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/AbpTenantManagementApplicationAutoMapperProfile.cs
  2. 33
      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. 15
      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. 89
      modules/tenant-management/src/Volo.Abp.TenantManagement.Domain/Volo/Abp/TenantManagement/AbpTenantManagementDomainMapperlyMappers.cs
  10. 44
      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. 10
      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();
}
}

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

@ -0,0 +1,33 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace Volo.Abp.TenantManagement.Application.Volo.Abp.TenantManagement;
[Mapper]
public partial class TenantToTenantDtoMapper
: MapperBase<Tenant, TenantDto>
{
[MapperIgnoreSource(nameof(Tenant.EntityVersion))]
[MapperIgnoreSource(nameof(Tenant.ConnectionStrings))]
[MapperIgnoreSource(nameof(Tenant.IsDeleted))]
[MapperIgnoreSource(nameof(Tenant.NormalizedName))]
[MapperIgnoreSource(nameof(Tenant.DeleterId))]
[MapperIgnoreSource(nameof(Tenant.DeletionTime))]
[MapperIgnoreSource(nameof(Tenant.LastModificationTime))]
[MapperIgnoreSource(nameof(Tenant.LastModifierId))]
[MapperIgnoreSource(nameof(Tenant.CreationTime))]
[MapperIgnoreSource(nameof(Tenant.CreatorId))]
public override partial TenantDto Map(Tenant source);
[MapperIgnoreSource(nameof(Tenant.EntityVersion))]
[MapperIgnoreSource(nameof(Tenant.ConnectionStrings))]
[MapperIgnoreSource(nameof(Tenant.IsDeleted))]
[MapperIgnoreSource(nameof(Tenant.NormalizedName))]
[MapperIgnoreSource(nameof(Tenant.DeleterId))]
[MapperIgnoreSource(nameof(Tenant.DeletionTime))]
[MapperIgnoreSource(nameof(Tenant.LastModificationTime))]
[MapperIgnoreSource(nameof(Tenant.LastModifierId))]
[MapperIgnoreSource(nameof(Tenant.CreationTime))]
[MapperIgnoreSource(nameof(Tenant.CreatorId))]
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();
}
}

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

@ -0,0 +1,15 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace Volo.Abp.TenantManagement.Blazor;
[Mapper]
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" />

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

@ -0,0 +1,89 @@
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]
public partial class TenantToTenantConfigurationMapper
: MapperBase<Tenant, TenantConfiguration>
{
[MapperIgnoreSource(nameof(Tenant.DeleterId))]
[MapperIgnoreSource(nameof(Tenant.DeletionTime))]
[MapperIgnoreSource(nameof(Tenant.LastModificationTime))]
[MapperIgnoreSource(nameof(Tenant.CreationTime))]
[MapperIgnoreSource(nameof(Tenant.CreatorId))]
[MapperIgnoreSource(nameof(Tenant.LastModifierId))]
[MapperIgnoreSource(nameof(Tenant.ExtraProperties))]
[MapperIgnoreSource(nameof(Tenant.ConcurrencyStamp))]
[MapperIgnoreSource(nameof(Tenant.IsDeleted))]
[MapperIgnoreSource(nameof(Tenant.EntityVersion))]
[MapperIgnoreTarget(nameof(TenantConfiguration.EditionId))]
[MapperIgnoreTarget(nameof(TenantConfiguration.IsActive))]
public override partial TenantConfiguration Map(Tenant source);
[MapperIgnoreSource(nameof(Tenant.DeleterId))]
[MapperIgnoreSource(nameof(Tenant.DeletionTime))]
[MapperIgnoreSource(nameof(Tenant.IsDeleted))]
[MapperIgnoreSource(nameof(Tenant.LastModificationTime))]
[MapperIgnoreSource(nameof(Tenant.LastModifierId))]
[MapperIgnoreSource(nameof(Tenant.CreationTime))]
[MapperIgnoreSource(nameof(Tenant.CreatorId))]
[MapperIgnoreSource(nameof(Tenant.ExtraProperties))]
[MapperIgnoreSource(nameof(Tenant.ConcurrencyStamp))]
[MapperIgnoreSource(nameof(Tenant.EntityVersion))]
[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]
public partial class TenantToTenantEtoMapper
: MapperBase<Tenant, TenantEto>
{
[MapperIgnoreSource(nameof(Tenant.ConnectionStrings))]
[MapperIgnoreSource(nameof(Tenant.IsDeleted))]
[MapperIgnoreSource(nameof(Tenant.NormalizedName))]
[MapperIgnoreSource(nameof(Tenant.DeleterId))]
[MapperIgnoreSource(nameof(Tenant.DeletionTime))]
[MapperIgnoreSource(nameof(Tenant.LastModificationTime))]
[MapperIgnoreSource(nameof(Tenant.LastModifierId))]
[MapperIgnoreSource(nameof(Tenant.CreationTime))]
[MapperIgnoreSource(nameof(Tenant.CreatorId))]
[MapperIgnoreSource(nameof(Tenant.ExtraProperties))]
[MapperIgnoreSource(nameof(Tenant.ConcurrencyStamp))]
public override partial TenantEto Map(Tenant source);
[MapperIgnoreSource(nameof(Tenant.ConnectionStrings))]
[MapperIgnoreSource(nameof(Tenant.IsDeleted))]
[MapperIgnoreSource(nameof(Tenant.NormalizedName))]
[MapperIgnoreSource(nameof(Tenant.DeleterId))]
[MapperIgnoreSource(nameof(Tenant.DeletionTime))]
[MapperIgnoreSource(nameof(Tenant.LastModificationTime))]
[MapperIgnoreSource(nameof(Tenant.LastModifierId))]
[MapperIgnoreSource(nameof(Tenant.CreationTime))]
[MapperIgnoreSource(nameof(Tenant.CreatorId))]
[MapperIgnoreSource(nameof(Tenant.ExtraProperties))]
[MapperIgnoreSource(nameof(Tenant.ConcurrencyStamp))]
public override partial void Map(Tenant source, TenantEto destination);
}

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

@ -1,36 +1,36 @@
using AutoMapper;
// using AutoMapper;
using Volo.Abp.Data;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.TenantManagement;
public class AbpTenantManagementDomainMappingProfile : Profile
public class AbpTenantManagementDomainMappingProfile //: Profile
{
public AbpTenantManagementDomainMappingProfile()
{
CreateMap<Tenant, TenantConfiguration>()
.ForMember(ti => ti.ConnectionStrings, opts =>
{
opts.MapFrom((tenant, ti) =>
{
var connStrings = new ConnectionStrings();
// CreateMap<Tenant, TenantConfiguration>()
// .ForMember(ti => ti.ConnectionStrings, opts =>
// {
// opts.MapFrom((tenant, ti) =>
// {
// var connStrings = new ConnectionStrings();
if (tenant.ConnectionStrings == null)
{
return connStrings;
}
// if (tenant.ConnectionStrings == null)
// {
// return connStrings;
// }
foreach (var connectionString in tenant.ConnectionStrings)
{
connStrings[connectionString.Name] = connectionString.Value;
}
// 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());
// return connStrings;
// });
// })
// .ForMember(x => x.IsActive, x => x.Ignore())
// .ForMember(x => x.EditionId, x => x.Ignore());
CreateMap<Tenant, TenantEto>();
// 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.Mapperly;
using Volo.Abp.TenantManagement.Web.Pages.TenantManagement.Tenants;
namespace Volo.Abp.TenantManagement.Web;
[Mapper]
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]
public partial class TenantInfoModelToTenantCreateDtoMapper
: MapperBase<EditModalModel.TenantInfoModel, TenantCreateDto>
{
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.Id))]
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.ConcurrencyStamp))]
[MapperIgnoreTarget(nameof(TenantCreateDto.AdminEmailAddress))]
[MapperIgnoreTarget(nameof(TenantCreateDto.AdminPassword))]
public override partial TenantCreateDto Map(EditModalModel.TenantInfoModel source);
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.Id))]
[MapperIgnoreSource(nameof(EditModalModel.TenantInfoModel.ConcurrencyStamp))]
[MapperIgnoreTarget(nameof(TenantCreateDto.AdminEmailAddress))]
[MapperIgnoreTarget(nameof(TenantCreateDto.AdminPassword))]
public override partial void Map(EditModalModel.TenantInfoModel source, TenantCreateDto destination);
}
[Mapper]
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);
}

10
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();
@ -51,11 +51,7 @@ public class AbpTenantManagementWebModule : AbpModule
options.FileSets.AddEmbedded<AbpTenantManagementWebModule>();
});
context.Services.AddAutoMapperObjectMapper<AbpTenantManagementWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpTenantManagementWebAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<AbpTenantManagementWebModule>();
Configure<RazorPagesOptions>(options =>
{

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