feat: complete SOP execution workflow

This commit is contained in:
Eric 1549169735@qq.com
2026-08-09 00:29:26 +08:00
parent e32025d2ca
commit c5ab886b70
63 changed files with 1229 additions and 215 deletions

View File

@@ -5,6 +5,7 @@ import (
"git.iwork-ai.com/xdc/iqudo-top1/internal/auth"
"git.iwork-ai.com/xdc/iqudo-top1/internal/model"
"go.uber.org/zap"
"gorm.io/datatypes"
"gorm.io/gorm"
)
@@ -14,5 +15,21 @@ func Record(db *gorm.DB, principal auth.Principal, action, resource string, reso
if err != nil {
return err
}
return db.Create(&model.AuditLog{TenantID: principal.TenantID, UserID: principal.UserID, Action: action, Resource: resource, ResourceID: resourceID, Payload: datatypes.JSON(data)}).Error
fields := []zap.Field{
zap.Uint64("tenant_id", principal.TenantID),
zap.Uint64("user_id", principal.UserID),
zap.String("action", action),
zap.String("resource", resource),
zap.Uint64("resource_id", resourceID),
}
if err := db.Create(&model.AuditLog{TenantID: principal.TenantID, UserID: principal.UserID, Action: action, Resource: resource, ResourceID: resourceID, Payload: datatypes.JSON(data)}).Error; err != nil {
zap.L().Error("persist business event", append(fields, zap.Error(err))...)
return err
}
logBusinessEvent(fields)
return nil
}
func logBusinessEvent(fields []zap.Field) {
zap.L().Info("business event", fields...)
}