66 lines
2.2 KiB
C#
66 lines
2.2 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace Core.Blueprint.SQLServer.Entities
|
|
{
|
|
/// <summary>
|
|
/// Represents the base class for SQL Server entities, providing common properties for auditing and state management.
|
|
/// </summary>
|
|
public abstract class BaseSQLAdapter : IBaseSQLAdapter
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the identifier for the entity.
|
|
/// </summary>
|
|
[Key]
|
|
[JsonPropertyName("id")]
|
|
public int Id { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the unique identifier for the entity.
|
|
/// </summary>
|
|
[JsonPropertyName("guid")]
|
|
public string Guid { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the timestamp when the entity was created.
|
|
/// Default value is the current UTC time at the moment of instantiation.
|
|
/// </summary>
|
|
[JsonPropertyName("createdAt")]
|
|
public DateTime? CreatedAt { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the identifier of the user or system that created the entity.
|
|
/// </summary>
|
|
[JsonPropertyName("createdBy")]
|
|
public string? CreatedBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the timestamp when the entity was last updated.
|
|
/// Null if the entity has not been updated.
|
|
/// </summary>
|
|
[JsonPropertyName("updatedAt")]
|
|
public DateTime? UpdatedAt { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the identifier of the user or system that last updated the entity.
|
|
/// Null if the entity has not been updated.
|
|
/// </summary>
|
|
[JsonPropertyName("updatedBy")]
|
|
public string? UpdatedBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the status of the entity, indicating whether it is active, inactive, or in another state.
|
|
/// Default value is <see cref="StatusEnum.Active"/>.
|
|
/// </summary>
|
|
[JsonPropertyName("status")]
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
public StatusEnum Status { get; set; }
|
|
|
|
protected BaseSQLAdapter()
|
|
{
|
|
Guid = System.Guid.NewGuid().ToString();
|
|
CreatedAt = DateTime.UtcNow;
|
|
}
|
|
}
|
|
}
|