You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.5 KiB
C#
101 lines
2.5 KiB
C#
using DS.Module.Core.Extensions;
|
|
using DS.Module.Core.Modules;
|
|
|
|
namespace DS.Module.Core.Data;
|
|
|
|
/// <summary>
|
|
/// 实体类基类
|
|
/// </summary>
|
|
public abstract class BaseModel<TKey>
|
|
{
|
|
/// <summary>
|
|
/// 主键ID
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(IsPrimaryKey = true,Length = 100,ColumnDescription="主键ID")]
|
|
public TKey Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 备注
|
|
/// </summary>
|
|
public string Note { get; set; }
|
|
|
|
/// <summary>
|
|
/// 创建时间
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(ColumnDescription="创建时间")]
|
|
public DateTime AddTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 创建人
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(IsNullable = true,ColumnDescription="创建人")]
|
|
public string AddBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// 修改人
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(IsNullable = true,ColumnDescription="修改人")]
|
|
public string UpdateBy { get; set; }
|
|
|
|
/// <summary>
|
|
/// 更新时间
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(ColumnDescription="更新时间")]
|
|
public DateTime UpdateTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(ColumnDescription="是否删除")]
|
|
public bool Deleted { get; set; }
|
|
|
|
/// <summary>
|
|
/// 删除时间
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(ColumnDescription="删除时间")]
|
|
public DateTime DeleteTime { get; set; }
|
|
|
|
/// <summary>
|
|
/// 删除人
|
|
/// </summary>
|
|
[SqlSugar.SugarColumn(IsNullable = true,ColumnDescription="删除人")]
|
|
public string DeleteBy { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public virtual void Create()
|
|
{
|
|
var user = DSIocManage.Instance.GetService<UserInfo>();
|
|
if (typeof(TKey) == typeof(Guid))
|
|
{
|
|
this.Id = Guid.NewGuid().AsTo<TKey>();
|
|
}
|
|
|
|
if (typeof(TKey) == typeof(string))
|
|
{
|
|
this.Id = GuidHelper.GetSnowflakeId().AsTo<TKey>();
|
|
}
|
|
|
|
this.AddTime = DateTime.Now;
|
|
this.AddBy = user?.UserId;
|
|
this.UpdateTime = DateTime.Now;
|
|
this.UpdateBy = user?.UserId;
|
|
this.Deleted = false;
|
|
}
|
|
|
|
public virtual void Update()
|
|
{
|
|
var user = DSIocManage.Instance.GetService<UserInfo>();
|
|
this.UpdateTime = DateTime.Now;
|
|
this.UpdateBy = user?.UserId;
|
|
}
|
|
|
|
public virtual void Delete()
|
|
{
|
|
var user = DSIocManage.Instance.GetService<UserInfo>();
|
|
this.DeleteTime = DateTime.Now;
|
|
this.DeleteBy = user?.UserId;
|
|
this.Deleted = true;
|
|
}
|
|
} |