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.

93 lines
2.2 KiB
C#

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
{
/// <summary>
/// 创建者
/// </summary>
[Column("create_by")]
[StringLength(32)]
[MySqlCollation("utf8mb4_bin")]
public string CreateBy { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Column("create_at", TypeName = "datetime")]
public DateTime? CreateAt { get; set; }
/// <summary>
/// 修改者
/// </summary>
[Column("update_by")]
[StringLength(32)]
[MySqlCollation("utf8mb4_bin")]
public string UpdateBy { get; set; }
/// <summary>
/// 修改时间
/// </summary>
[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
{
/// <summary>
/// 删除者
/// </summary>
[Column("delete_by")]
[StringLength(32)]
[MySqlCollation("utf8mb4_bin")]
public string DeleteBy { get; set; }
/// <summary>
/// 删除时间
/// </summary>
[Column("delete_at", TypeName = "datetime")]
public DateTime? DeleteAt { get; set; }
/// <summary>
/// 是否删除
/// </summary>
[Column("is_delete", TypeName = "bit(1)")]
public bool IsDelete { get; set; }
public void Delete()
{
DeleteAt = DateTime.Now;
DeleteBy = "1";
IsDelete = true;
}
}
}