Browse Source

Replace AutoMapper with Mapperly in the account module.

pull/23436/head
maliming 10 months ago
parent
commit
25f8983c2b
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      modules/account/src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.csproj
  2. 21
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationMappers.cs
  3. 10
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationModule.cs
  4. 15
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationModuleAutoMapperProfile.cs
  5. 20
      modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorAutoMapperProfile.cs
  6. 27
      modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorMappers.cs
  7. 15
      modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorModule.cs
  8. 2
      modules/account/src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.csproj
  9. 15
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs
  10. 13
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebMappers.cs
  11. 14
      modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
  12. 2
      modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj

2
modules/account/src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.csproj

@ -21,7 +21,7 @@
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.Application\Volo.Abp.Identity.Application.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.UI.Navigation\Volo.Abp.UI.Navigation.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Emailing\Volo.Abp.Emailing.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>

21
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationMappers.cs

@ -0,0 +1,21 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Identity;
using Volo.Abp.Mapperly;
namespace Volo.Abp.Account;
[Mapper]
[MapExtraProperties]
public partial class IdentityUserToProfileDtoMapper : MapperBase<IdentityUser, ProfileDto>
{
[MapperIgnoreTarget(nameof(ProfileDto.HasPassword))]
public override partial ProfileDto Map(IdentityUser source);
[MapperIgnoreTarget(nameof(ProfileDto.HasPassword))]
public override partial void Map(IdentityUser source, ProfileDto destination);
public override void AfterMap(IdentityUser source, ProfileDto destination)
{
destination.HasPassword = source.PasswordHash != null;
}
}

10
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationModule.cs

@ -1,4 +1,4 @@
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Emailing;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
@ -12,7 +12,8 @@ namespace Volo.Abp.Account;
typeof(AbpAccountApplicationContractsModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpUiNavigationModule),
typeof(AbpEmailingModule)
typeof(AbpEmailingModule),
typeof(AbpMapperlyModule)
)]
public class AbpAccountApplicationModule : AbpModule
{
@ -23,11 +24,6 @@ public class AbpAccountApplicationModule : AbpModule
options.FileSets.AddEmbedded<AbpAccountApplicationModule>();
});
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpAccountApplicationModuleAutoMapperProfile>(validate: true);
});
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].Urls[AccountUrlNames.PasswordReset] = "Account/ResetPassword";

15
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AbpAccountApplicationModuleAutoMapperProfile.cs

@ -1,15 +0,0 @@
using AutoMapper;
using Volo.Abp.Identity;
namespace Volo.Abp.Account;
public class AbpAccountApplicationModuleAutoMapperProfile : Profile
{
public AbpAccountApplicationModuleAutoMapperProfile()
{
CreateMap<IdentityUser, ProfileDto>()
.ForMember(dest => dest.HasPassword,
op => op.MapFrom(src => src.PasswordHash != null))
.MapExtraProperties();
}
}

20
modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorAutoMapperProfile.cs

@ -1,20 +0,0 @@
using AutoMapper;
using Volo.Abp.Account.Blazor.Pages.Account;
using Volo.Abp.AutoMapper;
using Volo.Abp.Identity;
namespace Volo.Abp.Account.Blazor;
public class AbpAccountBlazorAutoMapperProfile : Profile
{
public AbpAccountBlazorAutoMapperProfile()
{
CreateMap<ProfileDto, PersonalInfoModel>()
.MapExtraProperties()
.Ignore(x => x.PhoneNumberConfirmed)
.Ignore(x => x.EmailConfirmed);
CreateMap<PersonalInfoModel, UpdateProfileDto>()
.MapExtraProperties();
}
}

27
modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorMappers.cs

@ -0,0 +1,27 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Account.Blazor.Pages.Account;
using Volo.Abp.Mapperly;
using Volo.Abp.Identity;
namespace Volo.Abp.Account.Blazor;
[Mapper]
[MapExtraProperties]
public partial class ProfileDtoToPersonalInfoModelMapper : MapperBase<ProfileDto, PersonalInfoModel>
{
[MapperIgnoreTarget(nameof(PersonalInfoModel.PhoneNumberConfirmed))]
[MapperIgnoreTarget(nameof(PersonalInfoModel.EmailConfirmed))]
public override partial PersonalInfoModel Map(ProfileDto source);
[MapperIgnoreTarget(nameof(PersonalInfoModel.PhoneNumberConfirmed))]
[MapperIgnoreTarget(nameof(PersonalInfoModel.EmailConfirmed))]
public override partial void Map(ProfileDto source, PersonalInfoModel destination);
}
[Mapper]
[MapExtraProperties]
public partial class PersonalInfoModelToUpdateProfileDtoMapper : MapperBase<PersonalInfoModel, UpdateProfileDto>
{
public override partial UpdateProfileDto Map(PersonalInfoModel source);
public override partial void Map(PersonalInfoModel source, UpdateProfileDto destination);
}

15
modules/account/src/Volo.Abp.Account.Blazor/AbpAccountBlazorModule.cs

@ -2,7 +2,7 @@
using Volo.Abp.Account.Blazor.Pages.Account;
using Volo.Abp.AspNetCore.Components.Web.Theming;
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectExtending.Modularity;
@ -13,21 +13,16 @@ namespace Volo.Abp.Account.Blazor;
[DependsOn(
typeof(AbpAspNetCoreComponentsWebThemingModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpAccountApplicationContractsModule)
)]
public class AbpAccountBlazorModule : AbpModule
{
private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner();
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<AbpAccountBlazorModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpAccountBlazorAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<AbpAccountBlazorModule>();
Configure<AbpNavigationOptions>(options =>
{
@ -39,7 +34,7 @@ public class AbpAccountBlazorModule : AbpModule
options.AdditionalAssemblies.Add(typeof(AbpAccountBlazorModule).Assembly);
});
}
public override void PostConfigureServices(ServiceConfigurationContext context)
{
OneTimeRunner.Run(() =>

2
modules/account/src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.csproj

@ -10,7 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Components.Web.Theming\Volo.Abp.AspNetCore.Components.Web.Theming.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>

15
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebAutomapperProfile.cs

@ -1,15 +0,0 @@
using Volo.Abp.Account.Web.Pages.Account;
using Volo.Abp.Identity;
using AutoMapper;
using Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo;
namespace Volo.Abp.Account.Web;
public class AbpAccountWebAutoMapperProfile : Profile
{
public AbpAccountWebAutoMapperProfile()
{
CreateMap<ProfileDto, AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel>()
.MapExtraProperties();
}
}

13
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebMappers.cs

@ -0,0 +1,13 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Account.Web.Pages.Account.Components.ProfileManagementGroup.PersonalInfo;
using Volo.Abp.Mapperly;
namespace Volo.Abp.Account.Web;
[Mapper]
[MapExtraProperties]
public partial class ProfileDtoToPersonalInfoModelMapper : MapperBase<ProfileDto, AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel>
{
public override partial AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel Map(ProfileDto source);
public override partial void Map(ProfileDto source, AccountProfilePersonalInfoManagementGroupViewComponent.PersonalInfoModel destination);
}

14
modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs

@ -8,7 +8,7 @@ using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
using Volo.Abp.AutoMapper;
using Volo.Abp.Mapperly;
using Volo.Abp.ExceptionHandling;
using Volo.Abp.Http.ProxyScripting.Generators.JQuery;
using Volo.Abp.Identity.AspNetCore;
@ -24,14 +24,14 @@ namespace Volo.Abp.Account.Web;
[DependsOn(
typeof(AbpAccountApplicationContractsModule),
typeof(AbpIdentityAspNetCoreModule),
typeof(AbpAutoMapperModule),
typeof(AbpMapperlyModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpExceptionHandlingModule)
)]
public class AbpAccountWebModule : AbpModule
{
private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner();
public override void PreConfigureServices(ServiceConfigurationContext context)
{
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
@ -59,11 +59,7 @@ public class AbpAccountWebModule : AbpModule
ConfigureProfileManagementPage();
context.Services.AddAutoMapperObjectMapper<AbpAccountWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpAccountWebAutoMapperProfile>(validate: true);
});
context.Services.AddMapperlyObjectMapper<AbpAccountWebModule>();
Configure<DynamicJavaScriptProxyOptions>(options =>
{
@ -96,7 +92,7 @@ public class AbpAccountWebModule : AbpModule
});
}
public override void PostConfigureServices(ServiceConfigurationContext context)
{
OneTimeRunner.Run(() =>

2
modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj

@ -39,7 +39,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.AspNetCore\Volo.Abp.Identity.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared\Volo.Abp.AspNetCore.Mvc.UI.Theme.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="..\Volo.Abp.Account.Application.Contracts\Volo.Abp.Account.Application.Contracts.csproj" />
</ItemGroup>

Loading…
Cancel
Save