Files
Yi.Framework/Yi.Doc.Md/02.框架功能模块/09.审计日志.md
2023-12-15 23:44:35 +08:00

42 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 简介
审计日志是对数据的操作记录
例如:
1. 数据的创建者
2. 数据的创建时间
3. 数据的更新者
4. 数据的更新时间
对于重要的数据,我们应该提供审计日志功能,方便进行数据追溯
框架内部已`自动集成`,使用起来非常简单
## 如何使用
我们把全部的审计日志封装一个对象
你的**实体**可直接继继承或者实现接口
AuditedObject与IAuditedObject
它包含4个属性字段
``` cs
public DateTime CreationTime { get; set; }= DateTime.Now;
public Guid? CreatorId { get; set; }
public Guid? LastModifierId { get; set; }
public DateTime? LastModificationTime { get; set; }
```
**在执行插入的时候:**
会自动为`CreationTime` 与 `CreatorId` 赋值
**在执行更新的时候:**
会自动为`LastModificationTime` 与 `LastModifierId` 赋值
当然,如果只需要部分的审计日志,你完全可以实现单独的接口
分别为:
``` cs
IHasCreationTime
IMayHaveCreator
IModificationAuditedObject
IHasModificationTime
```