UserLoginInfoDto.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Collections.Generic;
  2. using Abp.Application.Services.Dto;
  3. using Abp.AutoMapper;
  4. using WeApp.Authorization.Users;
  5. using IwbZero.Runtime.Session;
  6. namespace WeApp.BaseSystem.Sessions.Dto
  7. {
  8. [AutoMapFrom(typeof(User))]
  9. public class UserLoginInfoDto : EntityDto<long>
  10. {
  11. public string Name { get; set; }
  12. public string Surname { get; set; }
  13. public string UserName { get; set; }
  14. public string EmailAddress { get; set; }
  15. public string AvatarImagePath { get; set; }
  16. public int? AccountType { get; set; }
  17. public string AccountNo { get; set; }
  18. public int? UserType { get; set; }
  19. public List<string> UserRoles { get; set; }
  20. public List<string> UserRoleIds { get; set; }
  21. }
  22. public static class UserLoginInfoDtoExtensions
  23. {
  24. public static UserLoginInfoDto GetCurrentUser(this IIwbSession abpSession)
  25. {
  26. if (!abpSession.UserId.HasValue)
  27. {
  28. return null;
  29. }
  30. var dto = new UserLoginInfoDto()
  31. {
  32. Name = abpSession.RealName,
  33. UserName = abpSession.UserName,
  34. EmailAddress = abpSession.EmailAddress,
  35. AvatarImagePath = abpSession.AvatarImagePath,
  36. UserType = abpSession.UserType,
  37. AccountType = abpSession.AccountType,
  38. AccountNo = abpSession.AccountNo,
  39. UserRoles = abpSession.UserRoles,
  40. UserRoleIds = abpSession.UserRoleIds,
  41. };
  42. return dto;
  43. }
  44. }
  45. }