feat: complete SOP execution workflow
This commit is contained in:
@@ -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...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user