Added create contact ednpoint
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package models
|
||||
|
||||
import "github.com/jinzhu/gorm"
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
)
|
||||
|
||||
// Location holds latitude and longitude.
|
||||
type Location struct {
|
||||
@@ -10,17 +12,15 @@ type Location struct {
|
||||
|
||||
// ImportantInfo holds fields that are important for quick access.
|
||||
type SensorData struct {
|
||||
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"`
|
||||
// Used to parse incoming json data
|
||||
AccInfo AccelerometerInfo `json:"accelerometerInfo"`
|
||||
// Used to store coordinates of accelerometer to DB
|
||||
IMEI string `json:"imei"`
|
||||
IMSI string `json:"imsi"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Lat float64 `json:"lat"`
|
||||
Lon float64 `json:"lon"`
|
||||
WifiLoc Location `json:"wifiLocation"`
|
||||
CellLoc Location `json:"cellLocation"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
AccInfo AccelerometerInfo `json:"accelerometerInfo"`
|
||||
AccelerometerInfo
|
||||
}
|
||||
|
||||
@@ -33,12 +33,38 @@ type DeviceInfo struct {
|
||||
}
|
||||
|
||||
|
||||
type AccelerometerInfo struct {
|
||||
X int64
|
||||
Y int64
|
||||
Z int64
|
||||
type DeviceInfoResponse struct {
|
||||
BaseModel
|
||||
RawJSON string `json:"rawJson" gorm:"type:json"`
|
||||
SensorData
|
||||
DeviceID uint `json:"deviceId"`
|
||||
ExternalDeviceID string `json:"externalDeviceId"`
|
||||
}
|
||||
|
||||
func ConvertDeviceInfoToResponse(deviceInfos []DeviceInfo) []DeviceInfoResponse {
|
||||
var deviceInfoResponses []DeviceInfoResponse
|
||||
for _, deviceInfo := range deviceInfos {
|
||||
deviceInfoResponse := DeviceInfoResponse{
|
||||
BaseModel: BaseModel{
|
||||
ID: deviceInfo.ID,
|
||||
CreatedAt: deviceInfo.CreatedAt,
|
||||
UpdatedAt: deviceInfo.UpdatedAt,
|
||||
},
|
||||
RawJSON: deviceInfo.RawJSON,
|
||||
SensorData: deviceInfo.SensorData,
|
||||
DeviceID: deviceInfo.DeviceID,
|
||||
ExternalDeviceID: deviceInfo.ExternalDeviceID,
|
||||
}
|
||||
deviceInfoResponses = append(deviceInfoResponses, deviceInfoResponse)
|
||||
}
|
||||
return deviceInfoResponses
|
||||
}
|
||||
|
||||
type AccelerometerInfo struct {
|
||||
X int64 `json:"x"`
|
||||
Y int64 `json:"y"`
|
||||
Z int64 `json:"z"`
|
||||
}
|
||||
type GeoJSONFeatureCollection struct {
|
||||
Type string `json:"type"`
|
||||
Features []GeoJSONFeature `json:"features"`
|
||||
@@ -47,7 +73,7 @@ type GeoJSONFeatureCollection struct {
|
||||
type GeoJSONFeature struct {
|
||||
Type string `json:"type"`
|
||||
Geometry GeoJSONGeometry `json:"geometry"`
|
||||
DeviceInfo *DeviceInfo `json:",omitempty"`
|
||||
DeviceInfoResponse *DeviceInfoResponse `json:"deviceInfo,omitempty"`
|
||||
Properties map[string]interface{} `json:"properties"`
|
||||
}
|
||||
|
||||
@@ -56,7 +82,6 @@ type GeoJSONGeometry struct {
|
||||
Coordinates []float64 `json:"coordinates"`
|
||||
}
|
||||
|
||||
|
||||
func (DeviceInfo) Update() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user