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
{
///
/// Base class for role.
///
[Table("Sys_Roles")]
public abstract class RoleBase : FullAuditedEntity, IMayHaveTenant
{
///
/// Maximum length of the property.
///
public const int MaxDisplayNameLength = 64;
///
/// Maximum length of the property.
///
public const int MaxNameLength = 32;
///
/// Tenant's Id, if this role is a tenant-level role. Null, if not.
///
[Index]
public int? TenantId { get; set; }
///
/// Unique name of this role.
///
[Required]
[StringLength(MaxNameLength)]
[Index]
public string Name { get; set; }
[Index]
public int RoleType { get; set; }
[Index]
public int? AccountType { get; set; }
///
/// Display name of this role.
///
[Required]
[StringLength(MaxDisplayNameLength)]
public string DisplayName { get; set; }
///
/// Is this a static role?
/// Static roles can not be deleted, can not change their name.
/// They can be used programmatically.
///
public bool IsStatic { get; set; }
///
/// Is this role will be assigned to new users as default?
///
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}]";
}
}
}