自定义公共实体类
公共实体基类
/// <summary>
/// 实体基类
/// </summary>
public class BaseEntity<TKey> : IEntity<TKey>, ICreatedAudit, IUpdatedAudit, IDeletedAudit
{
/// <summary>
/// 主键
/// </summary>
public virtual TKey Id { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 创建人
/// </summary>
public long? CreatedUserId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreatedDate { get; set; }
/// <summary>
/// 修改人
/// </summary>
public long? UpdatedUserId { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? UpdatedDate { get; set; }
/// <summary>
/// 删除人
/// </summary>
public long? DeletedUserId { get; set; }
/// <summary>
/// 删除时间
/// </summary>
public DateTime? DeletedDate { get; set; }
/// <summary>
/// 是否删除
/// </summary>
public bool? IsDeleted { get; set; }
}
实体基类接口
/// <summary>
/// 实体基类接口
/// </summary>
public interface IEntity<TKey>
{
/// <summary>
/// 主键Id
/// </summary>
TKey Id { get; set; }
}
创建基类接口
/// <summary>
/// 创建基类接口
/// </summary>
public interface ICreatedAudit
{
/// <summary>
/// 创建人
/// </summary>
long? CreatedUserId { get; set; }
/// <summary>
/// 创建时间
/// </summary>
DateTime? CreatedDate { get; set; }
}
更新基类接口
/// <summary>
/// 更新基类接口
/// </summary>
public interface IUpdatedAudit
{
/// <summary>
/// 更新人
/// </summary>
long? UpdatedUserId { get; set; }
/// <summary>
/// 更新时间
/// </summary>
DateTime? UpdatedDate { get; set; }
}
删除基类接口
/// <summary>
/// 删除基类接口
/// </summary>
public interface IDeletedAudit
{
/// <summary>
/// 删除人
/// </summary>
long? DeletedUserId { get; set; }
/// <summary>
/// 删除时间
/// </summary>
DateTime? DeletedDate { get; set; }
/// <summary>
/// 是否删除 0-否 1-是
/// </summary>
bool? IsDeleted { get; set; }
}
排序基类接口(可选)
/// <summary>
/// 排序基类接口
/// </summary>
public interface ISortAudit
{
/// <summary>
/// 排序字段 数字越小越靠前
/// </summary>
public int? Seq { get; set; }
}
租户基类接口(可选)
/// <summary>
/// 租户基类接口
/// </summary>
public interface ITenantAudit
{
/// <summary>
/// 租户Id
/// </summary>
long? TenantId { get; set; }
}