MapperConfigs.cs 803 B

123456789101112131415161718192021222324252627
  1. using Hotline.CallCenter.BlackLists;
  2. using Hotline.Identity.Accounts;
  3. using Hotline.Identity.Roles;
  4. using Hotline.Share.Dtos.CallCenter;
  5. using Hotline.Share.Dtos.Role;
  6. using Hotline.Share.Dtos.User;
  7. using Hotline.Users;
  8. using Mapster;
  9. namespace Hotline.Application.Mappers
  10. {
  11. public class MapperConfigs : IRegister
  12. {
  13. public void Register(TypeAdapterConfig config)
  14. {
  15. config.NewConfig<AddBlacklistDto, Blacklist>()
  16. .Ignore(d => d.Expired)
  17. .AfterMapping((s, t) => t.InitExpired());
  18. config.NewConfig<AddUserDto, User>()
  19. .Map(d => d.Name, x => x.Name ?? x.UserName);
  20. config.NewConfig<Role, RoleDto>()
  21. .Map(d => d.AccountIds, x => x.Accounts.Select(d => d.Id));
  22. }
  23. }
  24. }