实现多商户履约平台基础

This commit is contained in:
yml2213
2026-07-30 12:02:32 +08:00
parent dde6f2c269
commit 83429456a6
41 changed files with 5487 additions and 504 deletions
+27
View File
@@ -0,0 +1,27 @@
package service
import (
"encoding/json"
"affiliate_dash/internal/model"
"gorm.io/gorm"
)
func writeAudit(tx *gorm.DB, merchantID, actorUserID, apiClientID *uint, action, entityType, entityID string, metadata interface{}) error {
raw := ""
if metadata != nil {
if bytes, err := json.Marshal(metadata); err == nil {
raw = string(bytes)
}
}
return tx.Create(&model.AuditLog{
MerchantID: merchantID,
ActorUserID: actorUserID,
APIClientID: apiClientID,
Action: action,
EntityType: entityType,
EntityID: entityID,
Metadata: raw,
}).Error
}