2023-12-01 09:32:45 +01:00
|
|
|
package database
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
|
2023-12-01 18:57:56 +01:00
|
|
|
|
|
|
|
type VariableType struct {
|
|
|
|
Label string `json:"label"`
|
|
|
|
Variable string `json:"variable"`
|
|
|
|
Unit string `json:"unit"`
|
|
|
|
Value interface{} `json:"value,omitempty"`
|
2025-02-10 14:07:25 +01:00
|
|
|
Status string `json:"status,omitempty"`
|
2023-12-01 18:57:56 +01:00
|
|
|
}
|
|
|
|
|
2023-12-01 09:32:45 +01:00
|
|
|
type Measurement struct {
|
|
|
|
Time time.Time `gorm:"not null;primary_key"`
|
|
|
|
Application string `gorm:"not null"`
|
2023-12-01 18:57:56 +01:00
|
|
|
Device string
|
2023-12-03 21:57:27 +01:00
|
|
|
Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"`
|
2023-12-01 18:57:56 +01:00
|
|
|
Values map[string]VariableType `gorm:"serializer:json;type:jsonb"`
|
2023-12-01 09:32:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Application struct {
|
|
|
|
gorm.Model
|
|
|
|
Label string `gorm:"not null"`
|
2023-12-03 21:57:27 +01:00
|
|
|
Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"`
|
2023-12-01 09:32:45 +01:00
|
|
|
}
|
|
|
|
|
2023-12-01 18:57:56 +01:00
|
|
|
|
|
|
|
type DeviceType struct {
|
2023-12-01 09:32:45 +01:00
|
|
|
gorm.Model
|
|
|
|
Label string `gorm:"not null"`
|
2023-12-01 18:57:56 +01:00
|
|
|
ModelIdentifier string
|
2023-12-03 21:57:27 +01:00
|
|
|
Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"`
|
2023-12-01 09:32:45 +01:00
|
|
|
}
|
|
|
|
|
2023-12-01 18:57:56 +01:00
|
|
|
type Device struct {
|
2023-12-01 09:32:45 +01:00
|
|
|
gorm.Model
|
2023-12-08 17:13:56 +01:00
|
|
|
Label string `gorm:"not null;uniqueIndex:idx_label_application_id"`
|
|
|
|
ApplicationID int `gorm:"not null;uniqueIndex:idx_label_application_id"`
|
2023-12-01 09:32:45 +01:00
|
|
|
Application Application
|
2023-12-01 18:57:56 +01:00
|
|
|
DeviceTypeID int `gorm:"not null"`
|
|
|
|
DeviceType DeviceType
|
2023-12-03 21:57:27 +01:00
|
|
|
Attributes map[string]interface{} `gorm:"serializer:json;type:jsonb"`
|
2023-12-01 09:32:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|