Browse Source

Merge pull request #23436 from abpframework/Mapperly-maliming

[Identity & Account] Replace AutoMapper with Mapperly.
pull/23456/head
Engincan VESKE 1 year ago
committed by GitHub
parent
commit
6a8a5bc5dc
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      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
  13. 2
      modules/identity/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.csproj
  14. 19
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationMappers.cs
  15. 11
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs
  16. 15
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModuleAutoMapperProfile.cs
  17. 18
      modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorAutoMapperProfile.cs
  18. 25
      modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMappers.cs
  19. 13
      modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs
  20. 2
      modules/identity/src/Volo.Abp.Identity.Blazor/Volo.Abp.Identity.Blazor.csproj
  21. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj
  22. 11
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs
  23. 33
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappers.cs
  24. 15
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappingProfile.cs
  25. 57
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs
  26. 94
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebMappers.cs
  27. 11
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs
  28. 2
      modules/identity/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj

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

@ -21,6 +21,7 @@
<ProjectReference Include="..\..\..\identity\src\Volo.Abp.Identity.Application\Volo.Abp.Identity.Application.csproj" /> <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.UI.Navigation\Volo.Abp.UI.Navigation.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Emailing\Volo.Abp.Emailing.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Emailing\Volo.Abp.Emailing.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Mapperly\Volo.Abp.Mapperly.csproj" />
</ItemGroup> </ItemGroup>
<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.Emailing;
using Volo.Abp.Identity; using Volo.Abp.Identity;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
@ -12,7 +12,8 @@ namespace Volo.Abp.Account;
typeof(AbpAccountApplicationContractsModule), typeof(AbpAccountApplicationContractsModule),
typeof(AbpIdentityApplicationModule), typeof(AbpIdentityApplicationModule),
typeof(AbpUiNavigationModule), typeof(AbpUiNavigationModule),
typeof(AbpEmailingModule) typeof(AbpEmailingModule),
typeof(AbpMapperlyModule)
)] )]
public class AbpAccountApplicationModule : AbpModule public class AbpAccountApplicationModule : AbpModule
{ {
@ -23,11 +24,6 @@ public class AbpAccountApplicationModule : AbpModule
options.FileSets.AddEmbedded<AbpAccountApplicationModule>(); options.FileSets.AddEmbedded<AbpAccountApplicationModule>();
}); });
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpAccountApplicationModuleAutoMapperProfile>(validate: true);
});
Configure<AppUrlOptions>(options => Configure<AppUrlOptions>(options =>
{ {
options.Applications["MVC"].Urls[AccountUrlNames.PasswordReset] = "Account/ResetPassword"; 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.Account.Blazor.Pages.Account;
using Volo.Abp.AspNetCore.Components.Web.Theming; using Volo.Abp.AspNetCore.Components.Web.Theming;
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
using Volo.Abp.AutoMapper; using Volo.Abp.Mapperly;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending;
using Volo.Abp.ObjectExtending.Modularity; using Volo.Abp.ObjectExtending.Modularity;
@ -13,21 +13,16 @@ namespace Volo.Abp.Account.Blazor;
[DependsOn( [DependsOn(
typeof(AbpAspNetCoreComponentsWebThemingModule), typeof(AbpAspNetCoreComponentsWebThemingModule),
typeof(AbpAutoMapperModule), typeof(AbpMapperlyModule),
typeof(AbpAccountApplicationContractsModule) typeof(AbpAccountApplicationContractsModule)
)] )]
public class AbpAccountBlazorModule : AbpModule public class AbpAccountBlazorModule : AbpModule
{ {
private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner(); private readonly static OneTimeRunner OneTimeRunner = new OneTimeRunner();
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAutoMapperObjectMapper<AbpAccountBlazorModule>(); context.Services.AddMapperlyObjectMapper<AbpAccountBlazorModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpAccountBlazorAutoMapperProfile>(validate: true);
});
Configure<AbpNavigationOptions>(options => Configure<AbpNavigationOptions>(options =>
{ {
@ -39,7 +34,7 @@ public class AbpAccountBlazorModule : AbpModule
options.AdditionalAssemblies.Add(typeof(AbpAccountBlazorModule).Assembly); options.AdditionalAssemblies.Add(typeof(AbpAccountBlazorModule).Assembly);
}); });
} }
public override void PostConfigureServices(ServiceConfigurationContext context) public override void PostConfigureServices(ServiceConfigurationContext context)
{ {
OneTimeRunner.Run(() => OneTimeRunner.Run(() =>

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

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

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

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

2
modules/identity/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.csproj

@ -18,7 +18,7 @@
<ProjectReference Include="..\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.csproj" />
<ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Domain\Volo.Abp.Identity.Domain.csproj" />
<ProjectReference Include="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Application\Volo.Abp.PermissionManagement.Application.csproj" /> <ProjectReference Include="..\..\..\permission-management\src\Volo.Abp.PermissionManagement.Application\Volo.Abp.PermissionManagement.Application.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>
</Project> </Project>

19
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationMappers.cs

@ -0,0 +1,19 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Identity;
using Volo.Abp.Mapperly;
[Mapper]
[MapExtraProperties]
public partial class IdentityUserToIdentityUserDtoMapper : MapperBase<IdentityUser, IdentityUserDto>
{
public override partial IdentityUserDto Map(IdentityUser source);
public override partial void Map(IdentityUser source, IdentityUserDto destination);
}
[Mapper]
[MapExtraProperties]
public partial class IdentityRoleToIdentityRoleDtoMapper : MapperBase<IdentityRole, IdentityRoleDto>
{
public override partial IdentityRoleDto Map(IdentityRole source);
public override partial void Map(IdentityRole source, IdentityRoleDto destination);
}

11
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs

@ -1,5 +1,5 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper; using Volo.Abp.Mapperly;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement; using Volo.Abp.PermissionManagement;
@ -8,18 +8,13 @@ namespace Volo.Abp.Identity;
[DependsOn( [DependsOn(
typeof(AbpIdentityDomainModule), typeof(AbpIdentityDomainModule),
typeof(AbpIdentityApplicationContractsModule), typeof(AbpIdentityApplicationContractsModule),
typeof(AbpAutoMapperModule), typeof(AbpMapperlyModule),
typeof(AbpPermissionManagementApplicationModule) typeof(AbpPermissionManagementApplicationModule)
)] )]
public class AbpIdentityApplicationModule : AbpModule public class AbpIdentityApplicationModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAutoMapperObjectMapper<AbpIdentityApplicationModule>(); context.Services.AddMapperlyObjectMapper<AbpIdentityApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpIdentityApplicationModuleAutoMapperProfile>(validate: true);
});
} }
} }

15
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModuleAutoMapperProfile.cs

@ -1,15 +0,0 @@
using AutoMapper;
namespace Volo.Abp.Identity;
public class AbpIdentityApplicationModuleAutoMapperProfile : Profile
{
public AbpIdentityApplicationModuleAutoMapperProfile()
{
CreateMap<IdentityUser, IdentityUserDto>()
.MapExtraProperties();
CreateMap<IdentityRole, IdentityRoleDto>()
.MapExtraProperties();
}
}

18
modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorAutoMapperProfile.cs

@ -1,18 +0,0 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
namespace Volo.Abp.Identity.Blazor;
public class AbpIdentityBlazorAutoMapperProfile : Profile
{
public AbpIdentityBlazorAutoMapperProfile()
{
CreateMap<IdentityUserDto, IdentityUserUpdateDto>()
.MapExtraProperties()
.Ignore(x => x.Password)
.Ignore(x => x.RoleNames);
CreateMap<IdentityRoleDto, IdentityRoleUpdateDto>()
.MapExtraProperties();
}
}

25
modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorMappers.cs

@ -0,0 +1,25 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
namespace Volo.Abp.Identity.Blazor;
[Mapper]
[MapExtraProperties]
public partial class IdentityUserDtoToIdentityUserUpdateDtoMapper : MapperBase<IdentityUserDto, IdentityUserUpdateDto>
{
[MapperIgnoreTarget(nameof(IdentityUserUpdateDto.Password))]
[MapperIgnoreTarget(nameof(IdentityUserUpdateDto.RoleNames))]
public override partial IdentityUserUpdateDto Map(IdentityUserDto source);
[MapperIgnoreTarget(nameof(IdentityUserUpdateDto.Password))]
[MapperIgnoreTarget(nameof(IdentityUserUpdateDto.RoleNames))]
public override partial void Map(IdentityUserDto source, IdentityUserUpdateDto destination);
}
[Mapper]
[MapExtraProperties]
public partial class IdentityRoleDtoToIdentityRoleUpdateDtoMapper : MapperBase<IdentityRoleDto, IdentityRoleUpdateDto>
{
public override partial IdentityRoleUpdateDto Map(IdentityRoleDto source);
public override partial void Map(IdentityRoleDto source, IdentityRoleUpdateDto destination);
}

13
modules/identity/src/Volo.Abp.Identity.Blazor/AbpIdentityBlazorModule.cs

@ -1,7 +1,7 @@
using Localization.Resources.AbpUi; using Localization.Resources.AbpUi;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Components.Web.Theming.Routing; using Volo.Abp.AspNetCore.Components.Web.Theming.Routing;
using Volo.Abp.AutoMapper; using Volo.Abp.Mapperly;
using Volo.Abp.BlazoriseUI; using Volo.Abp.BlazoriseUI;
using Volo.Abp.Identity.Localization; using Volo.Abp.Identity.Localization;
using Volo.Abp.Localization; using Volo.Abp.Localization;
@ -16,7 +16,7 @@ namespace Volo.Abp.Identity.Blazor;
[DependsOn( [DependsOn(
typeof(AbpIdentityApplicationContractsModule), typeof(AbpIdentityApplicationContractsModule),
typeof(AbpAutoMapperModule), typeof(AbpMapperlyModule),
typeof(AbpPermissionManagementBlazorModule), typeof(AbpPermissionManagementBlazorModule),
typeof(AbpBlazoriseUIModule) typeof(AbpBlazoriseUIModule)
)] )]
@ -26,12 +26,7 @@ public class AbpIdentityBlazorModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAutoMapperObjectMapper<AbpIdentityBlazorModule>(); context.Services.AddMapperlyObjectMapper<AbpIdentityBlazorModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpIdentityBlazorAutoMapperProfile>(validate: true);
});
Configure<AbpNavigationOptions>(options => Configure<AbpNavigationOptions>(options =>
{ {
@ -42,7 +37,7 @@ public class AbpIdentityBlazorModule : AbpModule
{ {
options.AdditionalAssemblies.Add(typeof(AbpIdentityBlazorModule).Assembly); options.AdditionalAssemblies.Add(typeof(AbpIdentityBlazorModule).Assembly);
}); });
Configure<AbpLocalizationOptions>(options => Configure<AbpLocalizationOptions>(options =>
{ {
options.Resources options.Resources

2
modules/identity/src/Volo.Abp.Identity.Blazor/Volo.Abp.Identity.Blazor.csproj

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

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo.Abp.Identity.Domain.csproj

@ -23,7 +23,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Volo.Abp.Identity.Domain.Shared\Volo.Abp.Identity.Domain.Shared.csproj" /> <ProjectReference Include="..\Volo.Abp.Identity.Domain.Shared\Volo.Abp.Identity.Domain.Shared.csproj" />
<ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.Domain\Volo.Abp.Users.Domain.csproj" /> <ProjectReference Include="..\..\..\users\src\Volo.Abp.Users.Domain\Volo.Abp.Users.Domain.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.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" /> <ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Ddd.Domain\Volo.Abp.Ddd.Domain.csproj" />
</ItemGroup> </ItemGroup>

11
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityDomainModule.cs

@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp.AutoMapper; using Volo.Abp.Mapperly;
using Volo.Abp.Domain; using Volo.Abp.Domain;
using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
@ -19,7 +19,7 @@ namespace Volo.Abp.Identity;
typeof(AbpDddDomainModule), typeof(AbpDddDomainModule),
typeof(AbpIdentityDomainSharedModule), typeof(AbpIdentityDomainSharedModule),
typeof(AbpUsersDomainModule), typeof(AbpUsersDomainModule),
typeof(AbpAutoMapperModule) typeof(AbpMapperlyModule)
)] )]
public class AbpIdentityDomainModule : AbpModule public class AbpIdentityDomainModule : AbpModule
{ {
@ -35,12 +35,7 @@ public class AbpIdentityDomainModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)
{ {
context.Services.AddAutoMapperObjectMapper<AbpIdentityDomainModule>(); context.Services.AddMapperlyObjectMapper<AbpIdentityDomainModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<IdentityDomainMappingProfile>(validate: true);
});
Configure<AbpDistributedEntityEventOptions>(options => Configure<AbpDistributedEntityEventOptions>(options =>
{ {

33
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappers.cs

@ -0,0 +1,33 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
using Volo.Abp.Users;
namespace Volo.Abp.Identity;
[Mapper]
public partial class IdentityUserToUserEtoMapper : MapperBase<IdentityUser, UserEto>
{
public override partial UserEto Map(IdentityUser source);
public override partial void Map(IdentityUser source, UserEto destination);
}
[Mapper]
public partial class IdentityClaimTypeToIdentityClaimTypeEtoMapper : MapperBase<IdentityClaimType, IdentityClaimTypeEto>
{
public override partial IdentityClaimTypeEto Map(IdentityClaimType source);
public override partial void Map(IdentityClaimType source, IdentityClaimTypeEto destination);
}
[Mapper]
public partial class IdentityRoleToIdentityRoleEtoMapper : MapperBase<IdentityRole, IdentityRoleEto>
{
public override partial IdentityRoleEto Map(IdentityRole source);
public override partial void Map(IdentityRole source, IdentityRoleEto destination);
}
[Mapper]
public partial class OrganizationUnitToOrganizationUnitEtoMapper : MapperBase<OrganizationUnit, OrganizationUnitEto>
{
public override partial OrganizationUnitEto Map(OrganizationUnit source);
public override partial void Map(OrganizationUnit source, OrganizationUnitEto destination);
}

15
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDomainMappingProfile.cs

@ -1,15 +0,0 @@
using AutoMapper;
using Volo.Abp.Users;
namespace Volo.Abp.Identity;
public class IdentityDomainMappingProfile : Profile
{
public IdentityDomainMappingProfile()
{
CreateMap<IdentityUser, UserEto>();
CreateMap<IdentityClaimType, IdentityClaimTypeEto>();
CreateMap<IdentityRole, IdentityRoleEto>();
CreateMap<OrganizationUnit, OrganizationUnitEto>();
}
}

57
modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs

@ -1,57 +0,0 @@
using AutoMapper;
using Volo.Abp.AutoMapper;
using Volo.Abp.Identity.Web.Pages.Identity.Roles;
using CreateUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel;
using EditUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel;
namespace Volo.Abp.Identity.Web;
public class AbpIdentityWebAutoMapperProfile : Profile
{
public AbpIdentityWebAutoMapperProfile()
{
CreateUserMappings();
CreateRoleMappings();
}
protected virtual void CreateUserMappings()
{
//List
CreateMap<IdentityUserDto, EditUserModalModel.UserInfoViewModel>()
.Ignore(x => x.Password);
//CreateModal
CreateMap<CreateUserModalModel.UserInfoViewModel, IdentityUserCreateDto>()
.MapExtraProperties()
.ForMember(dest => dest.RoleNames, opt => opt.Ignore());
CreateMap<IdentityRoleDto, CreateUserModalModel.AssignedRoleViewModel>()
.ForMember(dest => dest.IsAssigned, opt => opt.Ignore());
//EditModal
CreateMap<EditUserModalModel.UserInfoViewModel, IdentityUserUpdateDto>()
.MapExtraProperties()
.ForMember(dest => dest.RoleNames, opt => opt.Ignore());
CreateMap<IdentityRoleDto, EditUserModalModel.AssignedRoleViewModel>()
.ForMember(dest => dest.IsAssigned, opt => opt.Ignore());
CreateMap<IdentityUserDto, EditUserModalModel.DetailViewModel>()
.ForMember(dest => dest.CreatedBy, opt => opt.Ignore())
.ForMember(dest => dest.ModifiedBy, opt => opt.Ignore());
}
protected virtual void CreateRoleMappings()
{
//List
CreateMap<IdentityRoleDto, EditModalModel.RoleInfoModel>();
//CreateModal
CreateMap<CreateModalModel.RoleInfoModel, IdentityRoleCreateDto>()
.MapExtraProperties();
//EditModal
CreateMap<EditModalModel.RoleInfoModel, IdentityRoleUpdateDto>()
.MapExtraProperties();
}
}

94
modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebMappers.cs

@ -0,0 +1,94 @@
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
using Volo.Abp.Identity.Web.Pages.Identity.Roles;
using CreateUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.CreateModalModel;
using EditUserModalModel = Volo.Abp.Identity.Web.Pages.Identity.Users.EditModalModel;
namespace Volo.Abp.Identity.Web;
[Mapper]
public partial class IdentityUserDtoToEditUserModalModelUserInfoViewModelMapper : MapperBase<IdentityUserDto, EditUserModalModel.UserInfoViewModel>
{
[MapperIgnoreTarget(nameof(EditUserModalModel.UserInfoViewModel.Password))]
public override partial EditUserModalModel.UserInfoViewModel Map(IdentityUserDto source);
[MapperIgnoreTarget(nameof(EditUserModalModel.UserInfoViewModel.Password))]
public override partial void Map(IdentityUserDto source, EditUserModalModel.UserInfoViewModel destination);
}
[Mapper]
[MapExtraProperties]
public partial class CreateUserModalModelUserInfoViewModelToIdentityUserCreateDtoMapper : MapperBase<CreateUserModalModel.UserInfoViewModel, IdentityUserCreateDto>
{
[MapperIgnoreTarget(nameof(IdentityUserCreateDto.RoleNames))]
public override partial IdentityUserCreateDto Map(CreateUserModalModel.UserInfoViewModel source);
[MapperIgnoreTarget(nameof(IdentityUserCreateDto.RoleNames))]
public override partial void Map(CreateUserModalModel.UserInfoViewModel source, IdentityUserCreateDto destination);
}
[Mapper]
[MapExtraProperties]
public partial class IdentityRoleDtoToCreateUserModalModelAssignedRoleViewModelMapper : MapperBase<IdentityRoleDto, CreateUserModalModel.AssignedRoleViewModel>
{
[MapperIgnoreTarget(nameof(CreateUserModalModel.AssignedRoleViewModel.IsAssigned))]
public override partial CreateUserModalModel.AssignedRoleViewModel Map(IdentityRoleDto source);
[MapperIgnoreTarget(nameof(CreateUserModalModel.AssignedRoleViewModel.IsAssigned))]
public override partial void Map(IdentityRoleDto source, CreateUserModalModel.AssignedRoleViewModel destination);
}
[Mapper]
public partial class EditUserModalModelUserInfoViewModelToIdentityUserUpdateDtoMapper : MapperBase<EditUserModalModel.UserInfoViewModel, IdentityUserUpdateDto>
{
[MapperIgnoreTarget(nameof(IdentityUserUpdateDto.RoleNames))]
public override partial IdentityUserUpdateDto Map(EditUserModalModel.UserInfoViewModel source);
[MapperIgnoreTarget(nameof(IdentityUserUpdateDto.RoleNames))]
public override partial void Map(EditUserModalModel.UserInfoViewModel source, IdentityUserUpdateDto destination);
}
[Mapper]
public partial class IdentityRoleDtoToEditUserModalModelAssignedRoleViewModelMapper : MapperBase<IdentityRoleDto, EditUserModalModel.AssignedRoleViewModel>
{
[MapperIgnoreTarget(nameof(EditUserModalModel.AssignedRoleViewModel.IsAssigned))]
public override partial EditUserModalModel.AssignedRoleViewModel Map(IdentityRoleDto source);
[MapperIgnoreTarget(nameof(EditUserModalModel.AssignedRoleViewModel.IsAssigned))]
public override partial void Map(IdentityRoleDto source, EditUserModalModel.AssignedRoleViewModel destination);
}
[Mapper]
public partial class IdentityUserDtoToEditUserModalModelDetailViewModelMapper : MapperBase<IdentityUserDto, EditUserModalModel.DetailViewModel>
{
[MapperIgnoreTarget(nameof(EditUserModalModel.DetailViewModel.CreatedBy))]
[MapperIgnoreTarget(nameof(EditUserModalModel.DetailViewModel.ModifiedBy))]
public override partial EditUserModalModel.DetailViewModel Map(IdentityUserDto source);
[MapperIgnoreTarget(nameof(EditUserModalModel.DetailViewModel.CreatedBy))]
[MapperIgnoreTarget(nameof(EditUserModalModel.DetailViewModel.ModifiedBy))]
public override partial void Map(IdentityUserDto source, EditUserModalModel.DetailViewModel destination);
}
[Mapper]
public partial class IdentityRoleDtoToEditModalModelRoleInfoModelMapper : MapperBase<IdentityRoleDto, EditModalModel.RoleInfoModel>
{
public override partial EditModalModel.RoleInfoModel Map(IdentityRoleDto source);
public override partial void Map(IdentityRoleDto source, EditModalModel.RoleInfoModel destination);
}
[Mapper]
[MapExtraProperties]
public partial class CreateModalModelRoleInfoModelToIdentityRoleCreateDtoMapper : MapperBase<CreateModalModel.RoleInfoModel, IdentityRoleCreateDto>
{
public override partial IdentityRoleCreateDto Map(CreateModalModel.RoleInfoModel source);
public override partial void Map(CreateModalModel.RoleInfoModel source, IdentityRoleCreateDto destination);
}
[Mapper]
[MapExtraProperties]
public partial class EditModalModelRoleInfoModelToIdentityRoleUpdateDtoMapper : MapperBase<EditModalModel.RoleInfoModel, IdentityRoleUpdateDto>
{
public override partial IdentityRoleUpdateDto Map(EditModalModel.RoleInfoModel source);
public override partial void Map(EditModalModel.RoleInfoModel source, IdentityRoleUpdateDto destination);
}

11
modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs

@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.PageToolbars;
using Volo.Abp.AutoMapper; using Volo.Abp.Mapperly;
using Volo.Abp.Http.ProxyScripting.Generators.JQuery; using Volo.Abp.Http.ProxyScripting.Generators.JQuery;
using Volo.Abp.Identity.Localization; using Volo.Abp.Identity.Localization;
using Volo.Abp.Identity.Web.Navigation; using Volo.Abp.Identity.Web.Navigation;
@ -19,7 +19,7 @@ using Volo.Abp.Threading;
namespace Volo.Abp.Identity.Web; namespace Volo.Abp.Identity.Web;
[DependsOn(typeof(AbpIdentityApplicationContractsModule))] [DependsOn(typeof(AbpIdentityApplicationContractsModule))]
[DependsOn(typeof(AbpAutoMapperModule))] [DependsOn(typeof(AbpMapperlyModule))]
[DependsOn(typeof(AbpPermissionManagementWebModule))] [DependsOn(typeof(AbpPermissionManagementWebModule))]
[DependsOn(typeof(AbpAspNetCoreMvcUiThemeSharedModule))] [DependsOn(typeof(AbpAspNetCoreMvcUiThemeSharedModule))]
public class AbpIdentityWebModule : AbpModule public class AbpIdentityWebModule : AbpModule
@ -51,12 +51,7 @@ public class AbpIdentityWebModule : AbpModule
options.FileSets.AddEmbedded<AbpIdentityWebModule>(); options.FileSets.AddEmbedded<AbpIdentityWebModule>();
}); });
context.Services.AddAutoMapperObjectMapper<AbpIdentityWebModule>(); context.Services.AddMapperlyObjectMapper<AbpIdentityWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<AbpIdentityWebAutoMapperProfile>(validate: true);
});
Configure<RazorPagesOptions>(options => Configure<RazorPagesOptions>(options =>
{ {

2
modules/identity/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj

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

Loading…
Cancel
Save