From 0aa77f2a21585c898501a0ee191b49f456d3db68 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 22 Jul 2023 09:01:45 +0100 Subject: [PATCH] Add support for 'Update' transaction type --- src/vstp/actions.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/vstp/actions.go b/src/vstp/actions.go index 15369e4..39cfb36 100644 --- a/src/vstp/actions.go +++ b/src/vstp/actions.go @@ -10,12 +10,16 @@ import ( // Decide, based on the DB Formatted message type, what action needs taking // then either insert, or delete from the database as required func processEntryType(entry database.Service) { - if entry.TransactionType == "Create" { + + switch entry.TransactionType { + case "Create": createEntry(entry) - } else if entry.TransactionType == "Delete" { + case "Update": + updateEntry(entry) + case "Delete": deleteEntry(entry) - } else { - log.Msg.Error("Unknown TransactionType: " + entry.TransactionType) + default: + log.Msg.Error("Unknown transaction type: " + entry.TransactionType) } } @@ -23,6 +27,10 @@ func createEntry(entry database.Service) { log.Msg.Info("Entry Creation requested for: " + entry.TrainUid + " - " + entry.Headcode + " - " + entry.Operator) } +func updateEntry(entry database.Service) { + log.Msg.Info("Entry UPDATE requested for: " + entry.TrainUid + " - " + entry.Headcode + " - " + entry.Operator) +} + func deleteEntry(entry database.Service) { log.Msg.Info("Entry DELETE requested for: " + entry.TrainUid + " - " + entry.Headcode) fmt.Printf("%+v\n", entry)