CreateUserDto.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Abp.Auditing;
  2. using Abp.AutoMapper;
  3. using Abp.Runtime.Validation;
  4. using System.ComponentModel.DataAnnotations;
  5. using VberZero.AppService.Base.Dto;
  6. using VberZero.BaseSystem.Users;
  7. namespace VberZero.AppService.Users.Dto;
  8. [AutoMapTo(typeof(User))]
  9. public class CreateUserDto : VzEntityDto<long?>, IShouldNormalize
  10. {
  11. public CreateUserDto()
  12. {
  13. Gender = VzDefinition.GenderType.Man;
  14. AccountType = VzDefinition.AccountType.Client;
  15. UserType = VzDefinition.UserType.Ordinary;
  16. }
  17. [StringLength(User.MaxUserNameLength)]
  18. public string UserName { get; set; }
  19. [StringLength(User.MaxNameLength)]
  20. public string Name { get; set; } = "";
  21. [Required]
  22. [StringLength(User.MaxSurnameLength)]
  23. public string Surname { get; set; }
  24. [Required]
  25. [EmailAddress]
  26. [StringLength(User.MaxEmailAddressLength)]
  27. public string EmailAddress { get; set; }
  28. [StringLength(User.MaxPhoneNumberLength)]
  29. public string PhoneNumber { get; set; }
  30. public VzDefinition.GenderType Gender { get; set; }
  31. public VzDefinition.UserType UserType { get; set; }
  32. public VzDefinition.AccountType AccountType { get; set; }
  33. public string AccountNo { get; set; }
  34. public bool IsActive { get; set; }
  35. public string[] RoleNames { get; set; }
  36. public string[] PermissionNames { get; set; }
  37. [StringLength(User.MaxPlainPasswordLength)]
  38. [DisableAuditing]
  39. public string Password { get; set; }
  40. public void Normalize()
  41. {
  42. if (RoleNames != null) return;
  43. RoleNames = Array.Empty<string>();
  44. }
  45. }