2023-09-12 18:28:18 +02:00
|
|
|
package models
|
|
|
|
|
|
|
|
|
|
import "github.com/jinzhu/gorm"
|
|
|
|
|
|
|
|
|
|
// Location holds latitude and longitude.
|
|
|
|
|
type Location struct {
|
|
|
|
|
Lat float64 `json:"lat"`
|
|
|
|
|
Lon float64 `json:"lon"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ImportantInfo holds fields that are important for quick access.
|
|
|
|
|
type SensorData struct {
|
2023-09-18 12:27:40 +02:00
|
|
|
IMEI string `json:"imei"`
|
|
|
|
|
IMSI string `json:"imsi"`
|
|
|
|
|
Timestamp int64 `json:"timestamp"`
|
|
|
|
|
Lat float64 `json:"lat"`
|
|
|
|
|
Lon float64 `json:"lon"`
|
|
|
|
|
WifiLoc Location `json:"wifi_location"`
|
|
|
|
|
CellLoc Location `json:"cell_location"`
|
|
|
|
|
Temperature float64 `json:"temperature"`
|
2023-09-19 08:15:42 +02:00
|
|
|
// Used to parse incoming json data
|
|
|
|
|
AccInfo AccelerometerInfo `json:"accelerometerInfo"`
|
|
|
|
|
// Used to store coordinates of accelerometer to DB
|
|
|
|
|
AccelerometerInfo
|
2023-09-12 18:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type DeviceInfo struct {
|
|
|
|
|
gorm.Model
|
|
|
|
|
RawJSON string `json:"raw_json" gorm:"type:json"`
|
2023-09-18 12:27:40 +02:00
|
|
|
SensorData
|
|
|
|
|
DeviceID uint
|
2023-09-19 08:15:42 +02:00
|
|
|
ExternalDeviceID string `json:"deviceId"`
|
2023-09-12 18:28:18 +02:00
|
|
|
}
|
|
|
|
|
|
2023-09-19 08:15:42 +02:00
|
|
|
|
|
|
|
|
type AccelerometerInfo struct {
|
|
|
|
|
X int64
|
|
|
|
|
Y int64
|
|
|
|
|
Z int64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GeoJSONFeatureCollection struct {
|
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
Features []GeoJSONFeature `json:"features"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GeoJSONFeature struct {
|
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
Geometry GeoJSONGeometry `json:"geometry"`
|
|
|
|
|
DeviceInfo *DeviceInfo `json:",omitempty"`
|
|
|
|
|
Properties map[string]interface{} `json:"properties"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GeoJSONGeometry struct {
|
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
Coordinates []float64 `json:"coordinates"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-09-18 12:27:40 +02:00
|
|
|
func (DeviceInfo) Update() (bool, error) {
|
2023-09-12 18:28:18 +02:00
|
|
|
return false, nil
|
|
|
|
|
}
|
2023-09-18 12:27:40 +02:00
|
|
|
func (DeviceInfo) Create() (bool, error) {
|
2023-09-12 18:28:18 +02:00
|
|
|
return false, nil
|
|
|
|
|
}
|
2023-09-18 12:27:40 +02:00
|
|
|
func (DeviceInfo) Delete() (bool, error) {
|
2023-09-12 18:28:18 +02:00
|
|
|
return false, nil
|
|
|
|
|
}
|
2023-09-19 08:15:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|