Documentation
¶
Overview ¶
Package audit 提供写操作审计原语:审计记录与业务写在同一事务内落库, 事务回滚则审计一并消失——审计反映的是"已发生的事实"。
PSP 约定:资金相关的每次状态变更(记账、退款、改配置)都应留一条审计。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrationSQL ¶
MigrationSQL 返回审计表 DDL(幂等),域 repo 把它并入自己的基础迁移。
func MigrationSQLBare ¶
func MigrationSQLBare() string
MigrationSQLBare 返回无 schema 前缀的审计表 DDL,供分区域域 (appkit new domain -partitioned)的迁移使用:目标 schema 由 pgmigrate 在应用时经 SET LOCAL search_path 落位。两版的列定义必须保持一致。
Types ¶
type Entry ¶
type Entry struct {
Actor string // 操作者(用户 ID、服务名、"system")
Action string // 动作(如 "entry.post"、"refund.approve")
Entity string // 实体类型(如 "ledger_entry")
EntityID string
Before any
After any
Meta any
}
Entry 是一条审计记录。Before/After/Meta 会被 JSON 序列化(可为 nil)。