add mapping for radio call signs
This commit is contained in:
parent
fc486d981f
commit
e13a00c42a
3 changed files with 19 additions and 2 deletions
|
|
@ -40,6 +40,6 @@ func Init() {
|
|||
|
||||
if os.Getenv("DB_MIGRATE") != "false" {
|
||||
log.Log.Info("Executing database migrations")
|
||||
Db.AutoMigrate(&tables.StatusMessage{})
|
||||
Db.AutoMigrate(&tables.StatusMessage{}, &tables.RadioCallSign{})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
7
database/tables/radioCallSign.go
Normal file
7
database/tables/radioCallSign.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package tables
|
||||
|
||||
type RadioCallSign struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
RadioName string
|
||||
RadioCallSign string
|
||||
}
|
||||
|
|
@ -79,8 +79,18 @@ func getFmsListe(messageParts []string) string {
|
|||
response := ""
|
||||
log.Log.Debug("Received ", len(statusMessages), " entries")
|
||||
for _, status := range statusMessages {
|
||||
var radioCallSign tables.RadioCallSign
|
||||
err = database.Db.Where("radio_name = ?", status.Name).First(&radioCallSign).Error
|
||||
if err != nil {
|
||||
log.Log.Error("Failed retreiving radio call sign: ", err.Error())
|
||||
return "Internal error"
|
||||
}
|
||||
if radioCallSign.RadioName == "" {
|
||||
log.Log.Info("No radio definition for ", status.Name, " skipping")
|
||||
continue
|
||||
}
|
||||
response += fmt.Sprintf("SetFMSListe\t%s\tBF/FF\tSTATE\tCITY\t%s\tFZ->LST\t%s\t\t%d\tman\t%s\t0,0\n",
|
||||
status.Date.Format("02.01.06 / 15:04:05"), status.Name, getFmsName(status.Status), status.Status, status.FmsId)
|
||||
status.Date.Format("02.01.06 / 15:04:05"), status.Name, getFmsName(status.Status), status.Status, radioCallSign.RadioCallSign)
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue