From 8582adbe46f32976b1e8168734fbf5fea62f1561 Mon Sep 17 00:00:00 2001 From: Cornelius Rautenbach <cornel.rautenbach@gmail.com> Date: Mon, 29 Nov 2021 09:49:48 +0200 Subject: [PATCH] Audit - GetChanges method --- audit/audit.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/audit/audit.go b/audit/audit.go index 70666b3..6146f09 100644 --- a/audit/audit.go +++ b/audit/audit.go @@ -4,23 +4,12 @@ import ( "reflect" "regexp" "strings" - "time" "github.com/r3labs/diff/v2" "gitlab.com/uafrica/go-utils/reflection" "gitlab.com/uafrica/go-utils/string_utils" ) -type Event struct { - ID int64 `json:"id"` - ObjectID string `json:"object_id"` - Type string `json:"type"` - ProviderID int64 `json:"provider_id"` - Source string `json:"source"` - Timestamp time.Time `json:"timestamp"` - Change map[string]interface{} `json:"change"` -} - type FieldChange struct { From interface{} `json:"change_from"` To interface{} `json:"change_to"` @@ -131,7 +120,7 @@ func ToSnakeCase(str string) string { return strings.ToLower(snake) } -func getIntValue(object interface{}, key string) int64 { +func GetIntValue(object interface{}, key string) int64 { structValue := reflect.ValueOf(object) if structValue.Kind() == reflect.Struct { field := structValue.FieldByName(key) @@ -141,7 +130,7 @@ func getIntValue(object interface{}, key string) int64 { return 0 } -func getStringValue(object interface{}, key string) string { +func GetStringValue(object interface{}, key string) string { structValue := reflect.ValueOf(object) if structValue.Kind() == reflect.Struct { field := structValue.FieldByName(key) -- GitLab