This commit is contained in:
@@ -55,12 +55,15 @@ func (s *Service) logDeviceOperation(
|
||||
OperationType: operationType,
|
||||
OperationDesc: operationDesc,
|
||||
ResultStatus: resultStatus,
|
||||
BeforeData: beforeData,
|
||||
AfterData: afterData,
|
||||
BatchTotal: batchTotal,
|
||||
SuccessCount: successCount,
|
||||
FailCount: failCount,
|
||||
}
|
||||
snapshot := deviceSnapshot(device)
|
||||
beforeContent := stripDeviceOperationMeta(beforeData)
|
||||
afterContent := stripDeviceOperationMeta(afterData)
|
||||
params.BeforeData, params.AfterData = assetAuditSvc.WrapOperationContent(beforeContent, afterContent, snapshot)
|
||||
|
||||
if device != nil {
|
||||
params.AssetID = device.ID
|
||||
params.AssetIdentifier = device.VirtualNo
|
||||
@@ -72,6 +75,23 @@ func (s *Service) logDeviceOperation(
|
||||
s.logDeviceAudit(ctx, params)
|
||||
}
|
||||
|
||||
func stripDeviceOperationMeta(data map[string]any) map[string]any {
|
||||
if len(data) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make(map[string]any, len(data))
|
||||
for k, v := range data {
|
||||
if k == "device" || k == "card" || k == "cards" || k == "asset_snapshot" || k == "operation_content" {
|
||||
continue
|
||||
}
|
||||
out[k] = v
|
||||
}
|
||||
if len(out) == 0 {
|
||||
return nil
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func deviceSnapshot(device *model.Device) map[string]any {
|
||||
if device == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user