固化七月迭代审计治理进展以隔离线上热修
Constraint: 切换 main 前必须保存当前七月分支全部项目进展,套餐生效提案仅属于 Iteration/7-11。 Rejected: 将七月套餐修复直接移植到 main | 两个分支的可靠投递架构不同。 Confidence: medium Scope-risk: broad Directive: 不得将本提交整体 cherry-pick 到 main;main 套餐热修必须基于其纯 Asynq 代码独立实施。 Tested: git diff --check;openspec validate fix-package-activation-starvation --strict。 Not-tested: 按用户要求未运行自动化测试;go build ./... 因当前审计改造中的 Enterprise 模型字面量和 role.recordFailure 参数类型错误未通过。
This commit is contained in:
41
internal/infrastructure/audit/batch.go
Normal file
41
internal/infrastructure/audit/batch.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
pkgerrors "github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
)
|
||||
|
||||
// BatchInput 描述一条批次根事件及每个已识别资源的子事件。
|
||||
type BatchInput struct {
|
||||
Root AppendInput
|
||||
Children []AppendInput
|
||||
}
|
||||
|
||||
// AppendBatch 在同一事务内追加批次根事件和资源子事件。
|
||||
func (w *Writer) AppendBatch(ctx context.Context, tx *gorm.DB, input BatchInput) error {
|
||||
if input.Root.EventID == "" {
|
||||
return pkgerrors.New(pkgerrors.CodeInvalidParam, "批次根事件缺少稳定事件ID")
|
||||
}
|
||||
if err := w.Append(ctx, tx, input.Root); err != nil {
|
||||
return err
|
||||
}
|
||||
for index := range input.Children {
|
||||
child := input.Children[index]
|
||||
if child.EventID == "" {
|
||||
return pkgerrors.New(pkgerrors.CodeInvalidParam, "批次子事件缺少稳定事件ID")
|
||||
}
|
||||
if child.ParentEventID == "" {
|
||||
child.ParentEventID = input.Root.EventID
|
||||
}
|
||||
if child.CorrelationID == "" {
|
||||
child.CorrelationID = input.Root.CorrelationID
|
||||
}
|
||||
if err := w.Append(ctx, tx, child); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user