| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System;
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- using Abp.Domain.Entities;
- using Abp.Domain.Entities.Auditing;
- namespace IwbZero.Authorization.Base.Roles
- {
- /// <summary>
- /// Base class for role.
- /// </summary>
- [Table("Sys_Roles")]
- public abstract class RoleBase : FullAuditedEntity<int>, IMayHaveTenant
- {
- /// <summary>
- /// Maximum length of the <see cref="DisplayName"/> property.
- /// </summary>
- public const int MaxDisplayNameLength = 64;
- /// <summary>
- /// Maximum length of the <see cref="Name"/> property.
- /// </summary>
- public const int MaxNameLength = 32;
- /// <summary>
- /// Tenant's Id, if this role is a tenant-level role. Null, if not.
- /// </summary>
- [Index]
- public int? TenantId { get; set; }
- /// <summary>
- /// Unique name of this role.
- /// </summary>
- [Required]
- [StringLength(MaxNameLength)]
- [Index]
- public string Name { get; set; }
- [Index]
- public int RoleType { get; set; }
- [Index]
- public int? AccountType { get; set; }
- /// <summary>
- /// Display name of this role.
- /// </summary>
- [Required]
- [StringLength(MaxDisplayNameLength)]
- public string DisplayName { get; set; }
- /// <summary>
- /// Is this a static role?
- /// Static roles can not be deleted, can not change their name.
- /// They can be used programmatically.
- /// </summary>
- public bool IsStatic { get; set; }
- /// <summary>
- /// Is this role will be assigned to new users as default?
- /// </summary>
- public bool IsDefault { get; set; }
- protected RoleBase()
- {
- Name = Guid.NewGuid().ToString("N");
- }
- protected RoleBase(int? tenantId, string displayName)
- : this()
- {
- TenantId = tenantId;
- DisplayName = displayName;
- }
- protected RoleBase(int? tenantId, string name, string displayName)
- : this(tenantId, displayName)
- {
- Name = name;
- }
- public override string ToString()
- {
- return $"[Role {Id}, Name={Name}]";
- }
- }
- }
|