using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using Masuit.Tools.Systems;
namespace CVDEMCS.Services.Repositories.Entities.BaseEntity
{
public abstract class BaseEntity
{
[Key]
[Column("id")]
[StringLength(64)]
public string Id { get; set; }
}
public abstract class CUBaseEntity : BaseEntity
{
///
/// 创建者
///
[Column("create_by")]
[StringLength(32)]
[MySqlCollation("utf8mb4_bin")]
public string CreateBy { get; set; }
///
/// 创建时间
///
[Column("create_at", TypeName = "datetime")]
public DateTime? CreateAt { get; set; }
///
/// 修改者
///
[Column("update_by")]
[StringLength(32)]
[MySqlCollation("utf8mb4_bin")]
public string UpdateBy { get; set; }
///
/// 修改时间
///
[Column("update_at", TypeName = "datetime")]
public DateTime? UpdateAt { get; set; }
public void Update()
{
UpdateAt = DateTime.Now;
UpdateBy = "1";
}
public void Create()
{
Id = SnowFlakeNew.LongId.ToString();
CreateAt = DateTime.Now;
CreateBy = "1";
Update();
}
}
public abstract class CUDBaseEntity: CUBaseEntity
{
///
/// 删除者
///
[Column("delete_by")]
[StringLength(32)]
[MySqlCollation("utf8mb4_bin")]
public string DeleteBy { get; set; }
///
/// 删除时间
///
[Column("delete_at", TypeName = "datetime")]
public DateTime? DeleteAt { get; set; }
///
/// 是否删除
///
[Column("is_delete", TypeName = "bit(1)")]
public bool IsDelete { get; set; }
public void Delete()
{
DeleteAt = DateTime.Now;
DeleteBy = "1";
IsDelete = true;
}
}
}