This commit is contained in:
Nedim
2023-09-19 08:15:42 +02:00
parent c2d6923375
commit 85e695b2d8
7 changed files with 287 additions and 49 deletions

View File

@@ -5,21 +5,10 @@ import "github.com/jinzhu/gorm"
type Company struct {
gorm.Model
Name string
Password string
Email string
Avatar string
Users []User
Devices []Device
}
// func FetchCompanies(companies *[]Company) (err error) {
// db := gorm.GetDb()
// if err = db.Find(companies).Error; err != nil {
// return err
// }
// return nil
// }
func (Company) Update() (bool, error) {
return false, nil

View File

@@ -23,6 +23,9 @@ type Contract struct {
ContractInfos []ContractInfo
}
const ContractStatusActive = "active"
const ContractStatusPending = "pending"
func (Contract) Update() (bool, error) {
return false, nil
}

View File

@@ -6,6 +6,7 @@ import (
type Device struct {
gorm.Model
DeviceID string `json:"deviceId"`
DeviceName string
IMEI string `json:"imei"`
IMSI string `json:"imsi"`

View File

@@ -18,6 +18,10 @@ type SensorData struct {
WifiLoc Location `json:"wifi_location"`
CellLoc Location `json:"cell_location"`
Temperature float64 `json:"temperature"`
// Used to parse incoming json data
AccInfo AccelerometerInfo `json:"accelerometerInfo"`
// Used to store coordinates of accelerometer to DB
AccelerometerInfo
}
type DeviceInfo struct {
@@ -25,8 +29,34 @@ type DeviceInfo struct {
RawJSON string `json:"raw_json" gorm:"type:json"`
SensorData
DeviceID uint
ExternalDeviceID string `json:"deviceId"`
}
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"`
}
func (DeviceInfo) Update() (bool, error) {
return false, nil
}
@@ -36,3 +66,6 @@ func (DeviceInfo) Create() (bool, error) {
func (DeviceInfo) Delete() (bool, error) {
return false, nil
}