Files
KinginfoGateway/src/Admin/ThingsGateway.DB/Entity/BaseEntity.cs

159 lines
5.3 KiB
C#
Raw Normal View History

2025-01-24 22:42:26 +08:00
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://thingsgateway.cn/
// QQ群605534569
//------------------------------------------------------------------------------
using BootstrapBlazor.Components;
2025-07-13 22:47:14 +08:00
namespace ThingsGateway.DB;
2025-01-24 22:42:26 +08:00
/// <summary>
/// 主键id基类
/// </summary>
public abstract class PrimaryIdEntity : IPrimaryIdEntity
{
/// <summary>
/// 主键Id
/// </summary>
[SugarColumn(ColumnDescription = "Id", IsPrimaryKey = true)]
[IgnoreExcel]
[AutoGenerateColumn(Visible = false, IsVisibleWhenEdit = false, IsVisibleWhenAdd = false, Sortable = true, DefaultSort = true, DefaultSortOrder = SortOrder.Asc)]
2025-08-05 09:22:11 +00:00
[System.ComponentModel.DataAnnotations.Key]
2025-01-24 22:42:26 +08:00
public virtual long Id { get; set; }
}
2025-09-23 01:22:02 +08:00
public interface IPrimaryKeyEntity
{
string ExtJson { get; set; }
}
2025-01-24 22:42:26 +08:00
/// <summary>
/// 主键实体基类
/// </summary>
2025-09-23 01:22:02 +08:00
public abstract class PrimaryKeyEntity : PrimaryIdEntity, IPrimaryKeyEntity
2025-01-24 22:42:26 +08:00
{
/// <summary>
/// 拓展信息
/// </summary>
[SugarColumn(ColumnDescription = "扩展信息", ColumnDataType = StaticConfig.CodeFirst_BigString, IsNullable = true)]
[IgnoreExcel]
[AutoGenerateColumn(Ignore = true)]
2025-06-16 18:12:28 +08:00
public virtual string ExtJson { get; set; }
2025-01-24 22:42:26 +08:00
}
public interface IBaseEntity
{
2025-06-16 18:12:28 +08:00
DateTime CreateTime { get; set; }
string CreateUser { get; set; }
2025-01-24 22:42:26 +08:00
long CreateUserId { get; set; }
bool IsDelete { get; set; }
2025-06-16 18:12:28 +08:00
int SortCode { get; set; }
DateTime UpdateTime { get; set; }
string UpdateUser { get; set; }
long UpdateUserId { get; set; }
2025-01-24 22:42:26 +08:00
}
/// <summary>
/// 框架实体基类
/// </summary>
public abstract class BaseEntity : PrimaryKeyEntity, IBaseEntity
{
2025-06-16 18:12:28 +08:00
private long createUserId;
private long updateUserId;
private DateTime createTime;
private DateTime updateTime;
private int sortCode;
private bool isDelete = false;
private string createUser;
private string updateUser;
2025-01-24 22:42:26 +08:00
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnDescription = "创建时间", IsOnlyIgnoreUpdate = true, IsNullable = true)]
[IgnoreExcel]
[AutoGenerateColumn(Visible = false, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
2025-06-16 18:12:28 +08:00
public virtual DateTime CreateTime { get => createTime; set => createTime = value; }
2025-01-24 22:42:26 +08:00
/// <summary>
/// 创建人
/// </summary>
[SugarColumn(ColumnDescription = "创建人", IsOnlyIgnoreUpdate = true, IsNullable = true)]
[IgnoreExcel]
[NotNull]
[AutoGenerateColumn(Ignore = true)]
2025-06-16 18:12:28 +08:00
public virtual string CreateUser { get => createUser; set => createUser = value; }
2025-01-24 22:42:26 +08:00
/// <summary>
/// 创建者Id
/// </summary>
[SugarColumn(ColumnDescription = "创建者Id", IsOnlyIgnoreUpdate = true, IsNullable = true)]
[IgnoreExcel]
[AutoGenerateColumn(Ignore = true)]
2025-06-16 18:12:28 +08:00
public virtual long CreateUserId { get => createUserId; set => createUserId = value; }
2025-01-24 22:42:26 +08:00
/// <summary>
/// 软删除
/// </summary>
[SugarColumn(ColumnDescription = "软删除", IsNullable = true)]
[IgnoreExcel]
[AutoGenerateColumn(Ignore = true)]
2025-06-16 18:12:28 +08:00
public virtual bool IsDelete { get => isDelete; set => isDelete = value; }
2025-01-24 22:42:26 +08:00
/// <summary>
/// 更新时间
/// </summary>
[SugarColumn(ColumnDescription = "更新时间", IsOnlyIgnoreInsert = true, IsNullable = true)]
[IgnoreExcel]
[AutoGenerateColumn(Visible = false, IsVisibleWhenAdd = false, IsVisibleWhenEdit = false)]
2025-06-16 18:12:28 +08:00
public virtual DateTime UpdateTime { get => updateTime; set => updateTime = value; }
2025-01-24 22:42:26 +08:00
/// <summary>
/// 更新人
/// </summary>
[SugarColumn(ColumnDescription = "更新人", IsOnlyIgnoreInsert = true, IsNullable = true)]
[IgnoreExcel]
[AutoGenerateColumn(Ignore = true)]
2025-06-16 18:12:28 +08:00
public virtual string UpdateUser { get => updateUser; set => updateUser = value; }
2025-01-24 22:42:26 +08:00
/// <summary>
/// 修改者Id
/// </summary>
[SugarColumn(ColumnDescription = "修改者Id", IsOnlyIgnoreInsert = true, IsNullable = true)]
[IgnoreExcel]
[AutoGenerateColumn(Ignore = true)]
2025-06-16 18:12:28 +08:00
public virtual long UpdateUserId { get => updateUserId; set => updateUserId = value; }
2025-01-24 22:42:26 +08:00
/// <summary>
/// 排序码
///</summary>
[SugarColumn(ColumnDescription = "排序码", IsNullable = true)]
[AutoGenerateColumn(Visible = false, DefaultSort = true, Sortable = true, DefaultSortOrder = SortOrder.Asc)]
[IgnoreExcel]
2025-06-16 18:12:28 +08:00
public virtual int SortCode { get => sortCode; set => sortCode = value; }
2025-01-24 22:42:26 +08:00
}
public interface IBaseDataEntity
{
long CreateOrgId { get; set; }
}
/// <summary>
/// 业务数据实体基类(数据权限)
/// </summary>
public abstract class BaseDataEntity : BaseEntity, IBaseDataEntity
{
/// <summary>
/// 创建者部门Id
/// </summary>
[SugarColumn(ColumnDescription = "创建者部门Id", IsOnlyIgnoreUpdate = true, IsNullable = true)]
[AutoGenerateColumn(Ignore = true)]
[IgnoreExcel]
public virtual long CreateOrgId { get; set; }
}