Skip to content

Commit 0807375

Browse files
committed
refactor(Entity): 重构实体基类接口并添加安全过滤器
- 删除旧的IDeletedFilter接口,替换为新的ISafeDeletedFilter接口 - 新增ISafeUpdateFilter、ISafeEnabledFilter、ISafeCreatedFilter接口 - 更新EntityBase类实现新的安全过滤器接口 - 添加删除时间、创建人等新字段
1 parent c1253ca commit 0807375

6 files changed

Lines changed: 164 additions & 24 deletions

File tree

GameFrameX.Foundation.Orm.Entity/EntityBase.cs

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace GameFrameX.Foundation.Orm.Entity;
1313
/// <summary>
1414
/// 框架实体基类
1515
/// </summary>
16-
public abstract class EntityBase : EntityBaseId, IAuditableEntity, IDeletedFilter, IVersionedEntity, IEnabledFilter
16+
public abstract class EntityBase : EntityBaseId, IAuditableEntity, ISafeDeletedFilter, IVersionedEntity, ISafeEnabledFilter, ISafeCreatedFilter
1717
{
1818
/// <summary>
1919
/// 创建时间
@@ -56,7 +56,13 @@ public abstract class EntityBase : EntityBaseId, IAuditableEntity, IDeletedFilte
5656
/// 软删除
5757
/// </summary>
5858
[Description("软删除标记,true:删除,false:未删除,null:未设置(未删除)")]
59-
public virtual bool? IsDelete { get; set; } = false;
59+
public virtual bool? IsDeleted { get; set; } = false;
60+
61+
/// <summary>
62+
/// 删除时间
63+
/// </summary>
64+
[Description("删除时间")]
65+
public virtual long DeleteTime { get; set; }
6066

6167
/// <summary>
6268
/// 版本号(用于乐观锁)
@@ -72,14 +78,38 @@ public abstract class EntityBase : EntityBaseId, IAuditableEntity, IDeletedFilte
7278
/// </value>
7379
[Description("是否启用,true:启用,false:禁用,null:未设置(启用)")]
7480
public virtual bool? IsEnabled { get; set; }
81+
82+
/// <summary>
83+
/// 创建人
84+
/// </summary>
85+
[Description("创建人")]
86+
public virtual long CreatedId { get; set; }
87+
88+
/// <summary>
89+
/// 创建时间
90+
/// </summary>
91+
[Description("创建时间")]
92+
public virtual long CreatedTime { get; set; }
7593
}
7694

7795
/// <summary>
7896
/// 泛型框架实体基类
7997
/// </summary>
8098
/// <typeparam name="TKey">主键类型</typeparam>
81-
public abstract class EntityBase<TKey> : EntityBaseId<TKey>, IAuditableEntity, IDeletedFilter, IVersionedEntity
99+
public abstract class EntityBase<TKey> : EntityBaseId<TKey>, IAuditableEntity, ISafeDeletedFilter, IVersionedEntity, ISafeEnabledFilter, ISafeCreatedFilter
82100
{
101+
/// <summary>
102+
/// 创建人
103+
/// </summary>
104+
[Description("创建人")]
105+
public virtual long CreatedId { get; set; }
106+
107+
/// <summary>
108+
/// 创建时间
109+
/// </summary>
110+
[Description("创建时间")]
111+
public virtual long CreatedTime { get; set; }
112+
83113
/// <summary>
84114
/// 创建时间
85115
/// </summary>
@@ -121,11 +151,26 @@ public abstract class EntityBase<TKey> : EntityBaseId<TKey>, IAuditableEntity, I
121151
/// 软删除
122152
/// </summary>
123153
[Description("软删除标记,true:删除,false:未删除,null:未设置(未删除)")]
124-
public virtual bool? IsDelete { get; set; } = false;
154+
public virtual bool? IsDeleted { get; set; } = false;
155+
156+
/// <summary>
157+
/// 删除时间
158+
/// </summary>
159+
[Description("删除时间")]
160+
public virtual long DeleteTime { get; set; }
125161

126162
/// <summary>
127163
/// 版本号(用于乐观锁)
128164
/// </summary>
129165
[Description("版本号(用于乐观锁)")]
130166
public virtual long? Version { get; set; } = 0;
167+
168+
/// <summary>
169+
/// 是否启用该实体或功能的标识
170+
/// </summary>
171+
/// <value>
172+
/// true表示启用,false表示禁用,null表示未设置
173+
/// </value>
174+
[Description("是否启用,true:启用,false:禁用,null:未设置(启用)")]
175+
public virtual bool? IsEnabled { get; set; }
131176
}

GameFrameX.Foundation.Orm.Entity/Filter/IDeletedFilter.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ==========================================================================================
2+
// GameFrameX 组织及其衍生项目的版权、商标、专利及其他相关权利
3+
// GameFrameX organization and its derivative projects' copyrights, trademarks, patents, and related rights
4+
// 均受中华人民共和国及相关国际法律法规保护。
5+
// are protected by the laws of the People's Republic of China and relevant international regulations.
6+
//
7+
// 使用本项目须严格遵守相应法律法规及开源许可证之规定。
8+
// Usage of this project must strictly comply with applicable laws, regulations, and open-source licenses.
9+
//
10+
// 本项目采用 MIT 许可证与 Apache License 2.0 双许可证分发,
11+
// This project is dual-licensed under the MIT License and Apache License 2.0,
12+
// 完整许可证文本请参见源代码根目录下的 LICENSE 文件。
13+
// please refer to the LICENSE file in the root directory of the source code for the full license text.
14+
//
15+
// 禁止利用本项目实施任何危害国家安全、破坏社会秩序、
16+
// It is prohibited to use this project to engage in any activities that endanger national security, disrupt social order,
17+
// 侵犯他人合法权益等法律法规所禁止的行为!
18+
// or infringe upon the legitimate rights and interests of others, as prohibited by laws and regulations!
19+
// 因基于本项目二次开发所产生的一切法律纠纷与责任,
20+
// Any legal disputes and liabilities arising from secondary development based on this project
21+
// 本项目组织与贡献者概不承担。
22+
// shall be borne solely by the developer; the project organization and contributors assume no responsibility.
23+
//
24+
// GitHub 仓库:https://github.com/GameFrameX
25+
// GitHub Repository: https://github.com/GameFrameX
26+
// Gitee 仓库:https://gitee.com/GameFrameX
27+
// Gitee Repository: https://gitee.com/GameFrameX
28+
// 官方文档:https://gameframex.doc.alianblank.com/
29+
// Official Documentation: https://gameframex.doc.alianblank.com/
30+
// ==========================================================================================
31+
32+
namespace GameFrameX.Foundation.Orm.Entity.Filter;
33+
34+
/// <summary>
35+
/// 创建标记
36+
/// </summary>
37+
public interface ISafeCreatedFilter
38+
{
39+
/// <summary>
40+
/// 创建人
41+
/// </summary>
42+
public long CreatedId { get; set; }
43+
44+
/// <summary>
45+
/// 创建时间
46+
/// </summary>
47+
public long CreatedTime { get; set; }
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// ==========================================================================================
2+
// GameFrameX 组织及其衍生项目的版权、商标、专利及其他相关权利
3+
// GameFrameX organization and its derivative projects' copyrights, trademarks, patents, and related rights
4+
// 均受中华人民共和国及相关国际法律法规保护。
5+
// are protected by the laws of the People's Republic of China and relevant international regulations.
6+
//
7+
// 使用本项目须严格遵守相应法律法规及开源许可证之规定。
8+
// Usage of this project must strictly comply with applicable laws, regulations, and open-source licenses.
9+
//
10+
// 本项目采用 MIT 许可证与 Apache License 2.0 双许可证分发,
11+
// This project is dual-licensed under the MIT License and Apache License 2.0,
12+
// 完整许可证文本请参见源代码根目录下的 LICENSE 文件。
13+
// please refer to the LICENSE file in the root directory of the source code for the full license text.
14+
//
15+
// 禁止利用本项目实施任何危害国家安全、破坏社会秩序、
16+
// It is prohibited to use this project to engage in any activities that endanger national security, disrupt social order,
17+
// 侵犯他人合法权益等法律法规所禁止的行为!
18+
// or infringe upon the legitimate rights and interests of others, as prohibited by laws and regulations!
19+
// 因基于本项目二次开发所产生的一切法律纠纷与责任,
20+
// Any legal disputes and liabilities arising from secondary development based on this project
21+
// 本项目组织与贡献者概不承担。
22+
// shall be borne solely by the developer; the project organization and contributors assume no responsibility.
23+
//
24+
// GitHub 仓库:https://github.com/GameFrameX
25+
// GitHub Repository: https://github.com/GameFrameX
26+
// Gitee 仓库:https://gitee.com/GameFrameX
27+
// Gitee Repository: https://gitee.com/GameFrameX
28+
// 官方文档:https://gameframex.doc.alianblank.com/
29+
// Official Documentation: https://gameframex.doc.alianblank.com/
30+
// ==========================================================================================
31+
32+
namespace GameFrameX.Foundation.Orm.Entity.Filter;
33+
34+
/// <summary>
35+
/// 软删除标记
36+
/// </summary>
37+
public interface ISafeDeletedFilter
38+
{
39+
/// <summary>
40+
/// 是否删除
41+
/// </summary>
42+
bool? IsDeleted { get; set; }
43+
44+
/// <summary>
45+
/// 删除时间
46+
/// </summary>
47+
long DeleteTime { get; set; }
48+
}

GameFrameX.Foundation.Orm.Entity/Filter/IEnabledFilter.cs renamed to GameFrameX.Foundation.Orm.Entity/Filter/ISafeEnabledFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ namespace GameFrameX.Foundation.Orm.Entity.Filter;
99
/// <summary>
1010
/// 数据启用状态接口过滤器
1111
/// </summary>
12-
public interface IEnabledFilter
12+
public interface ISafeEnabledFilter
1313
{
1414
/// <summary>
15-
/// 是否启用
15+
/// 是否启用,true:启用,false:禁用,null:未设置(启用)
1616
/// </summary>
1717
bool? IsEnabled { get; set; }
1818
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace GameFrameX.Foundation.Orm.Entity.Filter;
2+
3+
/// <summary>
4+
/// 更新标记
5+
/// </summary>
6+
public interface ISafeUpdateFilter
7+
{
8+
/// <summary>
9+
/// 更新次数
10+
/// </summary>
11+
public int UpdateCount { get; set; }
12+
13+
/// <summary>
14+
/// 更新时间
15+
/// </summary>
16+
public long UpdateTime { get; set; }
17+
}

0 commit comments

Comments
 (0)