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)