Files
juipnet/Infrastructure/Hncore.Infrastructure/DDD/Entity.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2020-12-28 14:55:48 +08:00
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Hncore.Infrastructure.DDD
{
/// <summary>
/// 实现模型抽象基类
/// </summary>
/// <typeparam name="TId">主键数据类型</typeparam>
public abstract class Entity<TId> : IEntity<TId>
{
/// <summary>
/// 记录数据库主键ID
/// </summary>
[JsonProperty("Id")]
public virtual TId Id { get; set; }
}
public abstract class EntityWithTime<TId> : Entity<TId>
{
/// <summary>
/// 记录添加(创建)时间
/// </summary>
public virtual DateTime CreateTime { get; set; } = DateTime.Now;
/// <summary>
/// 记录最后更新时间
/// </summary>
public virtual DateTime UpdateTime { get; set; } = DateTime.Now;
/// <summary>
/// 记录软删除标记0.代表正常1.代表已删除
/// </summary>
public virtual int DeleteTag { get; set; }
}
public abstract class EntityWithDelete<TId> : Entity<TId>,ISoftDelete
{
/// <summary>
/// 记录软删除标记0.代表正常1.代表已删除
/// </summary>
public virtual int DeleteTag { get; set; } = 0;
}
2020-10-07 20:25:03 +08:00
}